[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_67C442B763577226C3F37EE367896923AA05@qq.com>
Date: Wed, 15 Jan 2025 00:21:55 +0800
From: Edward Adam Davis <eadavis@...com>
To: axboe@...nel.dk
Cc: eadavis@...com,
hare@...e.de,
linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org,
syzbot+fcee6b76cf2e261c51a4@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH V3] block: no show partitions if partno corrupted
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
Powered by blists - more mailing lists