mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dave Jones <davej@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	"J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH] locks: fix checking of fcntl_setlease argument
Date: Mon, 23 Jul 2012 15:17:17 -0400	[thread overview]
Message-ID: <20120723191717.GB2703@fieldses.org> (raw)
In-Reply-To: <CA+55aFwteHEnWm9ejmPoWZXTqjum1pC9fM6sKV_mRHGo2oorpA@mail.gmail.com>

The only checks of the long argument passed to fcntl(fd,F_SETLEASE,.)
are done after converting the long to an int.  Thus some illegal values
may be let through and cause problems in later code.

(They actually *don't* cause problems in mainline, as of Dave Jones's
8d657eb3b43861064d36241e88d9d61c709f33f0 "Remove easily user-triggerable
BUG from generic_setlease", but we should fix this anyway.  And this
patch will be necessary to fix real bugs on earlier kernels.)

Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/locks.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

On Mon, Jul 23, 2012 at 12:09:21PM -0700, Linus Torvalds wrote:
> NEVER EVER add BUG() as a "well, that was unexpected". That way lies
> exactly the kinds of denial-of-service attacks that that BUG() caused.

OK, makes sense.  Resending the patch to make it clear it's intended for
mainline as well.--b.

diff --git a/fs/locks.c b/fs/locks.c
index 43797a9..ad1de47 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -311,7 +311,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,
 	return 0;
 }
 
-static int assign_type(struct file_lock *fl, int type)
+static int assign_type(struct file_lock *fl, long type)
 {
 	switch (type) {
 	case F_RDLCK:
@@ -448,7 +448,7 @@ static const struct lock_manager_operations lease_manager_ops = {
 /*
  * Initialize a lease, use the default lock manager operations
  */
-static int lease_init(struct file *filp, int type, struct file_lock *fl)
+static int lease_init(struct file *filp, long type, struct file_lock *fl)
  {
 	if (assign_type(fl, type) != 0)
 		return -EINVAL;
@@ -466,7 +466,7 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl)
 }
 
 /* Allocate a file_lock initialised to this type of lease */
-static struct file_lock *lease_alloc(struct file *filp, int type)
+static struct file_lock *lease_alloc(struct file *filp, long type)
 {
 	struct file_lock *fl = locks_alloc_lock();
 	int error = -ENOMEM;
-- 
1.7.9.5


      reply	other threads:[~2012-07-23 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 17:35 Remove easily user-triggerable BUG from generic_setlease Dave Jones
2012-07-13 17:47 ` Linus Torvalds
2012-07-13 17:50   ` Dave Jones
2012-07-23 15:20   ` J. Bruce Fields
2012-07-23 18:34     ` Linus Torvalds
2012-07-23 19:04       ` J. Bruce Fields
2012-07-23 19:09         ` Linus Torvalds
2012-07-23 19:17           ` J. Bruce Fields [this message]

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=20120723191717.GB2703@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=bfields@redhat.com \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®