add missing argument check in ulockmgr.c
authormkmm@gmx-topmail.de <mkmm@gmx-topmail.de>
Tue, 5 Oct 2010 11:00:06 +0000 (13:00 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Thu, 11 Nov 2010 15:18:39 +0000 (16:18 +0100)
Add missing argument check in ulockmgr.c to prevent calling
ulockmgr_server with illegal arguments. This would cause an ever growing
list of ulockmgr_server processes with an endless list of open files which
finally exceeds the open file handle limit.

It appears samba is sometimes calling flock with illegal / weired values.

ChangeLog
lib/ulockmgr.c

index 2db0801df13a3be476243039d46d6964f40cec5c..c272b8120f4dde84f8f55e7d7057a177e71ccf0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-10-05  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Add missing argument check in ulockmgr.c to prevent calling
+       ulockmgr_server with illegal arguments. This would cause an ever
+       growing list of ulockmgr_server processes with an endless list of
+       open files which finally exceeds the open file handle limit.
+       Patch by Markus Ammer
+
 2010-09-28  Miklos Szeredi <miklos@szeredi.hu>
 
        * Fix ambiguous symbol version for fuse_chan_new.
index 6703cd03539f7784b89eb1cd2533a3141d2adf4c..b875c5077f78eff5a5c8977414ed8b6e95676891 100644 (file)
@@ -400,6 +400,10 @@ int ulockmgr_op(int fd, int cmd, struct flock *lock, const void *owner,
        if (cmd != F_GETLK && cmd != F_SETLK && cmd != F_SETLKW)
                return -EINVAL;
 
+       if (lock->l_type != F_RDLCK && lock->l_type != F_WRLCK &&
+           lock->l_type != F_UNLCK)
+               return -EINVAL;
+
        if (lock->l_whence != SEEK_SET && lock->l_whence != SEEK_CUR &&
            lock->l_whence != SEEK_END)
                return -EINVAL;