History

locks: fix posix lock range overflow handling

In the 32-bit case fcntl assigns the 64-bit f_pos and i_size to a 32-bit off_t. The existing range checks also seem to depend on signed arithmetic wrapping when it overflows. In practice maybe that works, but we can be more careful. That also allows us to make a more reliable distinction between -EINVAL and -EOVERFLOW. Note that in the 32-bit case SEEK_CUR or SEEK_END might allow the caller to set a lock with starting point no longer representable as a 32-bit value. We could return -EOVERFLOW in such cases, but the locks code is capable of handling such ranges, so we choose to be lenient here. The only problem is that subsequent GETLK calls on such a lock will fail with EOVERFLOW. While we're here, do some cleanup including consolidating code for the flock and flock64 cases.

J. Bruce Fields committed 12 years ago

Commit ef12e721 parent 8c3cac52 files · +32 −71Browse files

Showing the changes to include/uapi/asm-generic (1 of 2 files). Show all

Unified · Split

include/uapi/asm-generic/fcntl.h+0−3
@@ -186,8 +186,6 @@ struct flock { · 185 unmodified lines
186186 };
187187 #endif
188188
189−#ifndef CONFIG_64BIT
190−
191189 #ifndef HAVE_ARCH_STRUCT_FLOCK64
192190 #ifndef __ARCH_FLOCK64_PAD
193191 #define __ARCH_FLOCK64_PAD
@@ -202,6 +200,5 @@ struct flock64 { · 8 unmodified lines
202200 __ARCH_FLOCK64_PAD
203201 };
204202 #endif
205−#endif /* !CONFIG_64BIT */
206203
207204 #endif /* _ASM_GENERIC_FCNTL_H */