From: "Joseph D. Wagner" <theman@josephdwagner.info>
To: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: "'Matthew Wilcox'" <willy@debian.org>,
"'Jamie Lokier'" <jamie@shareable.org>
Subject: [PATCH] fs/locks.c fcntl_setlease did not check if a file was opened for writing before granting a read lease
Date: Thu, 27 Nov 2003 10:35:02 -0600 [thread overview]
Message-ID: <000301c3b504$689afbf0$0201a8c0@joe> (raw)
Gee, that seemed simple enough.
Keep in mind that I'm new to this whole 'kernel development' thing, and I offer no assurance that my patch actually works. I only know that it compiles without errors or warnings.
But I THINK this is how a patch would fix the problem, in theory.
This is where the 'theory of a thousand eyes' is going to have to help me out.
TIA guys.
BTW, this patch should be applied to both the 2.4 and 2.6 series of kernels (if it works).
Joseph D. Wagner
--- /old/linux-2.4.22/fs/locks.c 2003-08-25 17:44:43.000000000 +0600
+++ /new/linux-2.4.22/fs/locks.c 2003-11-27 10:08:41.000000000 +0600
@@ -111,10 +111,16 @@
* Matthew Wilcox <willy@thepuffingroup.com>, March, 2000.
*
* Leases and LOCK_MAND
* Matthew Wilcox <willy@linuxcare.com>, June, 2000.
* Stephen Rothwell <sfr@canb.auug.org.au>, June, 2000.
+ *
+ * FIXED Leases Issue -- Function fcntl_setlease would only check if a
+ * file had been opened before granting a F_WRLCK, a.k.a. a write lease.
+ * It would not check if the file had be opened for writing before
+ * granting a F_RDLCK, a.k.a. a read lease. This issue is now resolved.
+ * Joseph D. Wagner <wagnerjd@users.sourceforge.net> November 2003
*/
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/smp_lock.h>
@@ -1287,18 +1293,25 @@
lock_kernel();
time_out_leases(inode);
- /*
- * FIXME: What about F_RDLCK and files open for writing?
- */
error = -EAGAIN;
if ((arg == F_WRLCK)
&& ((atomic_read(&dentry->d_count) > 1)
|| (atomic_read(&inode->i_count) > 1)))
goto out_unlock;
+ if ((arg == F_RDLCK)
+ && ((dentry->d_flags & O_WRONLY)
+ || (dentry->d_flags & O_RDWR)
+ || (dentry->d_flags & O_CREAT)
+ || (dentry->d_flags & O_TRUNC)
+ || (inode->i_flags & O_WRONLY)
+ || (inode->i_flags & O_RDWR)
+ || (inode->i_flags & O_CREAT)
+ || (inode->i_flags & O_TRUNC)))
+ goto out_unlock;
/*
* At this point, we know that if there is an exclusive
* lease on this file, then we hold it on this filp
* (otherwise our open of this file would have blocked).
next reply other threads:[~2003-11-27 16:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-27 16:35 Joseph D. Wagner [this message]
2003-11-27 16:50 ` [PATCH] fs/locks.c fcntl_setlease did not check if a file was opened for writing before granting a read lease Jamie Lokier
2003-11-27 17:45 ` Nikita Danilov
2003-11-27 18:03 ` Jamie Lokier
2003-11-27 8:49 ` Joseph D. Wagner
2003-11-28 1:15 ` Jamie Lokier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000301c3b504$689afbf0$0201a8c0@joe' \
--to=theman@josephdwagner.info \
--cc=jamie@shareable.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox