From: Bart Van Assche <bvanassche@acm.org>
To: Khazhismel Kumykov <khazhy@google.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block/compat_ioctl: fix range check in BLKGETSIZE
Date: Sat, 9 Apr 2022 14:33:45 -0700 [thread overview]
Message-ID: <d41e3238-d7d9-16f8-38bd-2608844d7831@acm.org> (raw)
In-Reply-To: <20220408234707.2562835-1-khazhy@google.com>
On 4/8/22 16:47, Khazhismel Kumykov wrote:
> 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));
A nit: the "UL" and two parentheses can be left out. Anyway:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
next prev parent reply other threads:[~2022-04-09 21:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 23:47 Khazhismel Kumykov
2022-04-09 21:33 ` Bart Van Assche [this message]
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=d41e3238-d7d9-16f8-38bd-2608844d7831@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=khazhy@google.com \
--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®