public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix null reference error when checking end of zone
       [not found] <CGME20240704010121epcms2p4cff8b25d976d4a1b820ba18f1eb5aa90@epcms2p4>
@ 2024-07-04  1:01 ` Daejun Park
  2024-07-04  6:26   ` Markus Elfring
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daejun Park @ 2024-07-04  1:01 UTC (permalink / raw)
  To: jaegeuk@kernel.org, chao@kernel.org, daehojeong@google.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Daejun Park, Seokhwan Kim, Dongjin Kim, Yonggil Song,
	Jaeyoon Choi, Nayeon Kim, Siwoo Jung

This patch fixes a potentially null pointer being accessed by
is_end_zone_blkaddr() that checks the last block of a zone
when f2fs is mounted as a single device.

Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices")
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
 fs/f2fs/data.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b6dcb3bcaef7..1aa7eefa659c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
 #ifdef CONFIG_BLK_DEV_ZONED
 static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
 {
+	struct block_device *bdev = sbi->sb->s_bdev;
 	int devi = 0;
 
 	if (f2fs_is_multi_device(sbi)) {
@@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
 			return false;
 		}
 		blkaddr -= FDEV(devi).start_blk;
+		bdev = FDEV(devi).bdev;
 	}
-	return bdev_is_zoned(FDEV(devi).bdev) &&
+	return bdev_is_zoned(bdev) &&
 		f2fs_blkz_is_seq(sbi, devi, blkaddr) &&
 		(blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: fix null reference error when checking end of zone
  2024-07-04  1:01 ` [PATCH] f2fs: fix null reference error when checking end of zone Daejun Park
@ 2024-07-04  6:26   ` Markus Elfring
  2024-07-04  7:15   ` Chao Yu
  2024-07-15 14:40   ` patchwork-bot+f2fs
  2 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2024-07-04  6:26 UTC (permalink / raw)
  To: Daejun Park, linux-f2fs-devel, Chao Yu, Daeho Jeong, Jaegeuk Kim
  Cc: LKML, Dongjin Kim, Jaeyoon Choi, Nayeon Kim, Seokhwan Kim,
	Siwoo Jung, Yonggil Song

> This patch fixes a potentially null pointer being accessed by
…

Please improve such a change description with imperative wordings.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc6#n94


How do you think about to use a summary phrase like
“Prevent null pointer dereference in is_end_zone_blkaddr()”?

Regards,
Markus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] f2fs: fix null reference error when checking end of zone
  2024-07-04  1:01 ` [PATCH] f2fs: fix null reference error when checking end of zone Daejun Park
  2024-07-04  6:26   ` Markus Elfring
@ 2024-07-04  7:15   ` Chao Yu
  2024-07-04  7:55     ` Daejun Park
  2024-07-09 22:20     ` [f2fs-dev] " Daeho Jeong
  2024-07-15 14:40   ` patchwork-bot+f2fs
  2 siblings, 2 replies; 7+ messages in thread
From: Chao Yu @ 2024-07-04  7:15 UTC (permalink / raw)
  To: daejun7.park, jaegeuk@kernel.org, daehojeong@google.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Seokhwan Kim, Dongjin Kim, Yonggil Song, Jaeyoon Choi, Nayeon Kim,
	Siwoo Jung

On 2024/7/4 9:01, Daejun Park wrote:
> This patch fixes a potentially null pointer being accessed by
> is_end_zone_blkaddr() that checks the last block of a zone
> when f2fs is mounted as a single device.

blkzoned feature depends on multiple device feature? One regular
device and one seq-zone device?

Thanks,

> 
> Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices")
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> ---
>   fs/f2fs/data.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index b6dcb3bcaef7..1aa7eefa659c 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>   #ifdef CONFIG_BLK_DEV_ZONED
>   static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
>   {
> +	struct block_device *bdev = sbi->sb->s_bdev;
>   	int devi = 0;
>   
>   	if (f2fs_is_multi_device(sbi)) {
> @@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
>   			return false;
>   		}
>   		blkaddr -= FDEV(devi).start_blk;
> +		bdev = FDEV(devi).bdev;
>   	}
> -	return bdev_is_zoned(FDEV(devi).bdev) &&
> +	return bdev_is_zoned(bdev) &&
>   		f2fs_blkz_is_seq(sbi, devi, blkaddr) &&
>   		(blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1);
>   }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE:(2) [PATCH] f2fs: fix null reference error when checking end of zone
  2024-07-04  7:15   ` Chao Yu
@ 2024-07-04  7:55     ` Daejun Park
  2024-07-04  9:32       ` (2) " Chao Yu
  2024-07-09 22:20     ` [f2fs-dev] " Daeho Jeong
  1 sibling, 1 reply; 7+ messages in thread
From: Daejun Park @ 2024-07-04  7:55 UTC (permalink / raw)
  To: Chao Yu, jaegeuk@kernel.org, daehojeong@google.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Seokhwan Kim, Dongjin Kim, Yonggil Song, Jaeyoon Choi, Nayeon Kim,
	Siwoo Jung, Daejun Park

Hi Chao Yu,
> 
>--------- Original Message ---------
>Sender : Chao Yu <chao@kernel.org>
>Date : 2024-07-04 16:16 (GMT+9)
>Title : Re: [PATCH] f2fs: fix null reference error when checking end of zone
> 
>On 2024/7/4 9:01, Daejun Park wrote:
>> This patch fixes a potentially null pointer being accessed by
>> is_end_zone_blkaddr() that checks the last block of a zone
>> when f2fs is mounted as a single device.
>
>blkzoned feature depends on multiple device feature? One regular
>device and one seq-zone device?

According to mkfs.f2fs, if there are a sufficient number of
conventional zones, a single zoned device can be used.

Thanks,
Daejun

>
>Thanks,
>
>>
>> Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices")
>> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
>> ---
>>  fs/f2fs/data.c 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>> index b6dcb3bcaef7..1aa7eefa659c 100644
>> --- a/fs/f2fs/data.c
>> +++ b/fs/f2fs/data.c
>> @@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>>  #ifdef CONFIG_BLK_DEV_ZONED
>>  static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
>>  {
>> +        struct block_device *bdev = sbi->sb->s_bdev;
>>           int devi = 0;
>> 
>>           if (f2fs_is_multi_device(sbi)) {
>> @@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
>>                           return false;
>>                   }
>>                   blkaddr -= FDEV(devi).start_blk;
>> +                bdev = FDEV(devi).bdev;
>>           }
>> -        return bdev_is_zoned(FDEV(devi).bdev) &&
>> +        return bdev_is_zoned(bdev) &&
>>                   f2fs_blkz_is_seq(sbi, devi, blkaddr) &&
>>                   (blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1);
>>  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: (2) [PATCH] f2fs: fix null reference error when checking end of zone
  2024-07-04  7:55     ` Daejun Park
@ 2024-07-04  9:32       ` Chao Yu
  0 siblings, 0 replies; 7+ messages in thread
From: Chao Yu @ 2024-07-04  9:32 UTC (permalink / raw)
  To: daejun7.park, jaegeuk@kernel.org, daehojeong@google.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Seokhwan Kim, Dongjin Kim, Yonggil Song, Jaeyoon Choi, Nayeon Kim,
	Siwoo Jung

On 2024/7/4 15:55, Daejun Park wrote:
> Hi Chao Yu,
>>   
>> --------- Original Message ---------
>> Sender : Chao Yu <chao@kernel.org>
>> Date : 2024-07-04 16:16 (GMT+9)
>> Title : Re: [PATCH] f2fs: fix null reference error when checking end of zone
>>   
>> On 2024/7/4 9:01, Daejun Park wrote:
>>> This patch fixes a potentially null pointer being accessed by
>>> is_end_zone_blkaddr() that checks the last block of a zone
>>> when f2fs is mounted as a single device.
>>
>> blkzoned feature depends on multiple device feature? One regular
>> device and one seq-zone device?
> 
> According to mkfs.f2fs, if there are a sufficient number of
> conventional zones, a single zoned device can be used.

Correct.

Anyway, the code looks clean.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> 
> Thanks,
> Daejun
> 
>>
>> Thanks,
>>
>>>
>>> Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices")
>>> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
>>> ---
>>>    fs/f2fs/data.c 4 +++-
>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>>> index b6dcb3bcaef7..1aa7eefa659c 100644
>>> --- a/fs/f2fs/data.c
>>> +++ b/fs/f2fs/data.c
>>> @@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
>>>    #ifdef CONFIG_BLK_DEV_ZONED
>>>    static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
>>>    {
>>> +        struct block_device *bdev = sbi->sb->s_bdev;
>>>             int devi = 0;
>>>   
>>>             if (f2fs_is_multi_device(sbi)) {
>>> @@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
>>>                             return false;
>>>                     }
>>>                     blkaddr -= FDEV(devi).start_blk;
>>> +                bdev = FDEV(devi).bdev;
>>>             }
>>> -        return bdev_is_zoned(FDEV(devi).bdev) &&
>>> +        return bdev_is_zoned(bdev) &&
>>>                     f2fs_blkz_is_seq(sbi, devi, blkaddr) &&
>>>                     (blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1);
>>>    }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix null reference error when checking end of zone
  2024-07-04  7:15   ` Chao Yu
  2024-07-04  7:55     ` Daejun Park
@ 2024-07-09 22:20     ` Daeho Jeong
  1 sibling, 0 replies; 7+ messages in thread
From: Daeho Jeong @ 2024-07-09 22:20 UTC (permalink / raw)
  To: Chao Yu
  Cc: daejun7.park, jaegeuk@kernel.org, daehojeong@google.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Nayeon Kim, Siwoo Jung,
	Seokhwan Kim, Dongjin Kim

On Thu, Jul 4, 2024 at 12:17 AM Chao Yu <chao@kernel.org> wrote:
>
> On 2024/7/4 9:01, Daejun Park wrote:
> > This patch fixes a potentially null pointer being accessed by
> > is_end_zone_blkaddr() that checks the last block of a zone
> > when f2fs is mounted as a single device.
>
> blkzoned feature depends on multiple device feature? One regular
> device and one seq-zone device?
>
> Thanks,
>
> >
> > Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices")
> > Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> > ---
> >   fs/f2fs/data.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index b6dcb3bcaef7..1aa7eefa659c 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
> >   #ifdef CONFIG_BLK_DEV_ZONED
> >   static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
> >   {
> > +     struct block_device *bdev = sbi->sb->s_bdev;
> >       int devi = 0;
> >
> >       if (f2fs_is_multi_device(sbi)) {
> > @@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr)
> >                       return false;
> >               }
> >               blkaddr -= FDEV(devi).start_blk;
> > +             bdev = FDEV(devi).bdev;
> >       }
> > -     return bdev_is_zoned(FDEV(devi).bdev) &&
> > +     return bdev_is_zoned(bdev) &&
> >               f2fs_blkz_is_seq(sbi, devi, blkaddr) &&
> >               (blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1);
> >   }
>

Reviewed-by: Daeho Jeong <daehojeong@google.com>

Thanks,


>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix null reference error when checking end of zone
  2024-07-04  1:01 ` [PATCH] f2fs: fix null reference error when checking end of zone Daejun Park
  2024-07-04  6:26   ` Markus Elfring
  2024-07-04  7:15   ` Chao Yu
@ 2024-07-15 14:40   ` patchwork-bot+f2fs
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+f2fs @ 2024-07-15 14:40 UTC (permalink / raw)
  To: Daejun Park
  Cc: jaegeuk, chao, daehojeong, linux-f2fs-devel, linux-kernel,
	nayeoni.kim, siu.jung, sukka.kim, dongjin_.kim

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Thu, 04 Jul 2024 10:01:21 +0900 you wrote:
> This patch fixes a potentially null pointer being accessed by
> is_end_zone_blkaddr() that checks the last block of a zone
> when f2fs is mounted as a single device.
> 
> Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices")
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> 
> [...]

Here is the summary with links:
  - [f2fs-dev] f2fs: fix null reference error when checking end of zone
    https://git.kernel.org/jaegeuk/f2fs/c/c82bc1ab2a8a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-07-15 14:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20240704010121epcms2p4cff8b25d976d4a1b820ba18f1eb5aa90@epcms2p4>
2024-07-04  1:01 ` [PATCH] f2fs: fix null reference error when checking end of zone Daejun Park
2024-07-04  6:26   ` Markus Elfring
2024-07-04  7:15   ` Chao Yu
2024-07-04  7:55     ` Daejun Park
2024-07-04  9:32       ` (2) " Chao Yu
2024-07-09 22:20     ` [f2fs-dev] " Daeho Jeong
2024-07-15 14:40   ` patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox