---1463800575-1742948922-1000021617=:4681
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: 8BIT
Content-ID: <Pine.LNX.4.30.0109090413231.4681@toy.mandrakesoft.com>
Also affects: 2.4.7, 2.4.9-ac{4,6,9}, probably others.
Problem: in locks_mandatory_area(), fcntl_setlk(), fcntl_setlk64(), no
check whether locks_alloc_lock() succeeds. Attached patch fixes that.
Not sure about one thing, though: what error code to return for
locks_mandatory_area() on failure. It's invoked from some of the
{do,sys}_*{read,write}*() routines and nowhere else AFAICT. I set it to
-ENOMEM, maybe this is not the right thing to do.
Patch follows and is attached. Made over 2.4.9-ac10, applies cleanly
over -ac's mentioned above and with offests (1 to 3 lines) on 2.4.7 and
2.4.9.
diff -urN linux-old/fs/locks.c linux/fs/locks.c
--- linux-old/fs/locks.c Sun Sep 9 09:00:06 2001
+++ linux/fs/locks.c Sun Sep 9 09:21:07 2001
@@ -698,6 +698,9 @@
struct file_lock *new_fl = locks_alloc_lock(0);
int error;
+ if (new_fl == NULL)
+ return -ENOMEM;
+
new_fl->fl_owner = current->files;
new_fl->fl_pid = current->pid;
new_fl->fl_file = filp;
@@ -1411,6 +1414,9 @@
struct inode *inode;
int error;
+ if (file_lock == NULL)
+ return -ENOLCK;
+
/*
* This might block, so we do it before checking the inode.
*/
@@ -1563,6 +1569,9 @@
struct flock64 flock;
struct inode *inode;
int error;
+
+ if (file_lock == NULL)
+ return -ENOLCK;
/*
* This might block, so we do it before checking the inode.
-- Francis Galiegue, fg@mandrakesoft.com - Normand et fier de l'être "Programming is a race between programmers, who try and make more and more idiot-proof software, and universe, which produces more and more remarkable idiots. Until now, universe leads the race" -- R. Cook---1463800575-1742948922-1000021617=:4681 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="patch-2.4.9-ac10-locks_allock_check" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.4.30.0109090346570.4681@toy.mandrakesoft.com> Content-Description: Content-Disposition: ATTACHMENT; FILENA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g0K ---1463800575-1742948922-1000021617=:4681-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/