mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Khazhismel Kumykov <khazhy@google.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Khazhismel Kumykov <khazhy@google.com>
Subject: [PATCH] block/compat_ioctl: fix range check in BLKGETSIZE
Date: Fri,  8 Apr 2022 16:47:07 -0700	[thread overview]
Message-ID: <20220408234707.2562835-1-khazhy@google.com> (raw)

kernel ulong and compat_ulong_t may not be same width. Use type directly
to eliminate mismatches.

This would result in truncation rather than EFBIG for 32bit mode for
large disks.

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
---
 block/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Noticed this one was sitting in my "not landed yet" pile, third time's
the charm? :)

diff --git a/block/ioctl.c b/block/ioctl.c
index 4a86340133e4..959e93a90b29 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -629,7 +629,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 		return compat_put_long(argp,
 			(bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512);
 	case BLKGETSIZE:
-		if (bdev_nr_sectors(bdev) > ~0UL)
+		if (bdev_nr_sectors(bdev) > ~((compat_ulong_t)0UL))
 			return -EFBIG;
 		return compat_put_ulong(argp, bdev_nr_sectors(bdev));
 
-- 
2.35.1.1178.g4f1659d476-goog


             reply	other threads:[~2022-04-08 23:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 23:47 Khazhismel Kumykov [this message]
2022-04-09 21:33 ` Bart Van Assche
2022-04-14 22:40 ` [PATCH v2] " Khazhismel Kumykov
2022-04-15  5:25   ` Chaitanya Kulkarni
2022-04-15 12:42   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2018-04-06 22:23 [PATCH] " Khazhismel Kumykov
2018-07-31 18:23 ` Khazhismel Kumykov
2018-08-02 21:31 ` Jens Axboe

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=20220408234707.2562835-1-khazhy@google.com \
    --to=khazhy@google.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®