• NeilBrown's avatar
    [PATCH] Fix overflow tests for compat_sys_fcntl64 locking · 2520f14c
    NeilBrown authored
    When making an fctl locking call through compat_sys_fcntl64 (i.e.  a 32bit
    app on a 64bit kernel), the syscall can return a locking range that is in
    conflict with the queried lock.
    
    If some aspect of this range does not fit in the 32bit structure, something
    needs to be done.
    
    The current code is wrong in several respects:
    
    - It returns data to userspace even if no conflict was found
       i.e. it should check l_type for F_UNLCK
    - It returns -EOVERFLOW too agressively.   A lock range covering
      the last possible byte of the file (start = COMPAT_OFF_T_MAX,
      len = 1) should be possible, but is rejected with the current test.
    - A extra-long 'len' should not be a problem.  If only that part
      of the conflicting lock that would be visible to the 32bit
      app needs to be reported to the 32bit app anyway.
    
    This patch addresses those three issues and adds a comment to (hopefully)
    record it for posterity.
    
    Note: this patch mainly affects test-cases.  Real applications rarely is
    ever see the problems.
    
    This patch has been tested (LSB test suite), and works.
    Signed-off-by: default avatarNeil Brown <neilb@suse.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Matthew Wilcox <willy@debian.org>
    Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    2520f14c
compat.c 45.8 KB