From: Edward Adam Davis <eadavis@qq.com>
To: axboe@kernel.dk
Cc: eadavis@qq.com, hare@suse.de, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+fcee6b76cf2e261c51a4@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH V3] block: no show partitions if partno corrupted
Date: Wed, 15 Jan 2025 00:21:55 +0800 [thread overview]
Message-ID: <tencent_67C442B763577226C3F37EE367896923AA05@qq.com> (raw)
In-Reply-To: <2df5c0d7-cf9e-49ce-a39a-4e3d50c6df0c@kernel.dk>
On Tue, 14 Jan 2025 08:25:13 -0700, Jens Axboe wrote:
>> On Tue, 14 Jan 2025 08:02:15 -0700, Jens Axboe wrote:
>>>> diff --git a/block/genhd.c b/block/genhd.c
>>>> index 9130e163e191..3a9c36ad6bbd 100644
>>>> --- a/block/genhd.c
>>>> +++ b/block/genhd.c
>>>> @@ -890,6 +890,9 @@ static int show_partition(struct seq_file *seqf, void *v)
>>>>
>>>> rcu_read_lock();
>>>> xa_for_each(&sgp->part_tbl, idx, part) {
>>>> + int partno = bdev_partno(part);
>>>> +
>>>> + WARN_ON_ONCE(partno >= DISK_MAX_PARTS);
>>>> if (!bdev_nr_sectors(part))
>>>> continue;
>>>> seq_printf(seqf, "%4d %7d %10llu %pg\n",
>>>
>>> Surely you still want to continue for that condition?
>> No.
>
>No?
>
>> But like following, ok?
>> diff --git a/block/genhd.c b/block/genhd.c
>> index 9130e163e191..142b13620f0c 100644
>> --- a/block/genhd.c
>> +++ b/block/genhd.c
>> @@ -890,7 +890,10 @@ static int show_partition(struct seq_file *seqf, void *v)
>>
>> rcu_read_lock();
>> xa_for_each(&sgp->part_tbl, idx, part) {
>> - if (!bdev_nr_sectors(part))
>> + int partno = bdev_partno(part);
>> +
>> + WARN_ON_ONCE(partno >= DISK_MAX_PARTS);
>> + if (!bdev_nr_sectors(part) || partno >= DISK_MAX_PARTS)
>> continue;
>> seq_printf(seqf, "%4d %7d %10llu %pg\n",
>> MAJOR(part->bd_dev), MINOR(part->bd_dev),
>
>That's just silly...
I checked WARN_ON_ONCE(), and when the condition is met, the subsequent
WARN_ON_ONCE() will still return true, so adding it will not affect the
judgment of the condition.
It just issues a warning the first time the condition is met, and it will
still return true if the condition is true.
>
> xa_for_each(&sgp->part_tbl, idx, part) {
> int partno = bdev_partno(part);
>
> if (!bdev_nr_sectors(part))
> continue;
> if (WARN_ON_ONCE(partno >= DISK_MAX_PARTS))
> continue;
>
> ...
> }
Edward
next prev parent reply other threads:[~2025-01-14 16:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 18:56 [syzbot] [fs?] KASAN: global-out-of-bounds Read in number syzbot
2025-01-13 12:21 ` Edward Adam Davis
2025-01-13 22:19 ` syzbot
2025-01-14 1:05 ` Edward Adam Davis
2025-01-14 1:38 ` syzbot
2025-01-14 1:30 ` Edward Adam Davis
2025-01-14 2:13 ` syzbot
2025-01-14 2:28 ` [PATCH] block: no show partitions if partno corrupted Edward Adam Davis
2025-01-14 7:21 ` Hannes Reinecke
2025-01-14 8:51 ` [PATCH V2] " Edward Adam Davis
2025-01-14 14:16 ` Jens Axboe
2025-01-14 14:58 ` [PATCH V3] " Edward Adam Davis
2025-01-14 15:02 ` Jens Axboe
2025-01-14 15:15 ` Edward Adam Davis
2025-01-14 15:25 ` Jens Axboe
2025-01-14 15:34 ` [PATCH V4] " Edward Adam Davis
2025-01-14 16:21 ` Edward Adam Davis [this message]
2025-01-15 6:46 ` [PATCH V2] " Christoph Hellwig
2025-01-14 5:29 ` [syzbot] [fs?] KASAN: global-out-of-bounds Read in number syzbot
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=tencent_67C442B763577226C3F37EE367896923AA05@qq.com \
--to=eadavis@qq.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+fcee6b76cf2e261c51a4@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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®