public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lou Langholtz <ldl@aros.net>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@digeo.com>
Subject: [PATCH] BLKBSZSET ioctl: fixes possibly silent blocksize change failure
Date: Sat, 12 Jul 2003 23:18:12 -0600	[thread overview]
Message-ID: <3F10EB94.3060509@aros.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 692 bytes --]

Here's a small patch that fixes a failure to return -EINVAL to user when 
calling the BLKBSZSET ioctl and the requested new blocksize passed in is 
smaller than bdev_hardsect_size(bdev). This patch applies against 2.5.75 
through 2.5.75-bk2 (I have not tried applying the patch against any 
other releases). A quick glance at the 2.4.20 code shows the same bug to 
exist their too (as I suspect is in later 2.4 release also). A side 
effect of this patch is that checking is re-ordered between checking if 
busy and whether the new blocksize is valid. Programs expecting this 
ioctl to validate the new size before checking if busy would need to be 
updated to handle the new checking order.

[-- Attachment #2: blocksize.diff --]
[-- Type: text/plain, Size: 668 bytes --]

diff -urN linux-2.5.75/drivers/block/ioctl.c linux-2.5.75-patched/drivers/block/ioctl.c
--- linux-2.5.75/drivers/block/ioctl.c	2003-07-10 14:04:46.000000000 -0600
+++ linux-2.5.75-patched/drivers/block/ioctl.c	2003-07-12 16:35:27.421331789 -0600
@@ -166,13 +166,11 @@
 			return -EINVAL;
 		if (get_user(n, (int *) arg))
 			return -EFAULT;
-		if (n > PAGE_SIZE || n < 512 || (n & (n - 1)))
-			return -EINVAL;
 		if (bd_claim(bdev, &holder) < 0)
 			return -EBUSY;
-		set_blocksize(bdev, n);
+		ret = set_blocksize(bdev, n);
 		bd_release(bdev);
-		return 0;
+		return ret;
 	case BLKPG:
 		return blkpg_ioctl(bdev, (struct blkpg_ioctl_arg *) arg);
 	case BLKRRPART:

                 reply	other threads:[~2003-07-13  5:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3F10EB94.3060509@aros.net \
    --to=ldl@aros.net \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.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