All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
@ 2019-07-25  9:49 ` Jia-Ju Bai
  0 siblings, 0 replies; 6+ messages in thread
From: Jia-Ju Bai @ 2019-07-25  9:49 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel, linux-kernel

In update_general_status(), there are two if statements to
check whether SM_I(sbi) is NULL:
LINE 70:     if (SM_I(sbi) && SM_I(sbi)->fcc_info)
LINE 78:     if (SM_I(sbi) && SM_I(sbi)->dcc_info)

When SM_I(sbi) is NULL, it is used at some places, such as:
LINE 88: reserved_segments(sbi)
                   return SM_I(sbi)->reserved_segments;
LINE 89: overprovision_segments(sbi)
                   return SM_I(sbi)->ovp_segments;
LINE 112: MAIN_SEGS(sbi)
                     (SM_I(sbi)->main_segments)

Thus, possible null-pointer dereferences may occur.

These bugs are found by a static analysis tool STCheck written by us.

I do not know how to correctly fix these bugs, so I only report them.


Best wishes,
Jia-Ju Bai

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

* [f2fs-dev] [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
@ 2019-07-25  9:49 ` Jia-Ju Bai
  0 siblings, 0 replies; 6+ messages in thread
From: Jia-Ju Bai @ 2019-07-25  9:49 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: linux-kernel, linux-f2fs-devel

In update_general_status(), there are two if statements to
check whether SM_I(sbi) is NULL:
LINE 70:     if (SM_I(sbi) && SM_I(sbi)->fcc_info)
LINE 78:     if (SM_I(sbi) && SM_I(sbi)->dcc_info)

When SM_I(sbi) is NULL, it is used at some places, such as:
LINE 88: reserved_segments(sbi)
                   return SM_I(sbi)->reserved_segments;
LINE 89: overprovision_segments(sbi)
                   return SM_I(sbi)->ovp_segments;
LINE 112: MAIN_SEGS(sbi)
                     (SM_I(sbi)->main_segments)

Thus, possible null-pointer dereferences may occur.

These bugs are found by a static analysis tool STCheck written by us.

I do not know how to correctly fix these bugs, so I only report them.


Best wishes,
Jia-Ju Bai


_______________________________________________
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] 6+ messages in thread

* Re: [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
  2019-07-25  9:49 ` [f2fs-dev] " Jia-Ju Bai
@ 2019-07-26  3:19   ` Chao Yu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2019-07-26  3:19 UTC (permalink / raw)
  To: Jia-Ju Bai, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

Hi Jiaju,

Thanks for the report, I checked the code, and found it doesn't need to check
SM_I(sbi) pointer, this is because in fill_super() and put_super(), we will call
f2fs_destroy_stats() in prior to f2fs_destroy_segment_manager(), so if current
sbi can still be visited in global stat list, SM_I(sbi) should be released yet.
So anyway, let's remove unneeded check in line 70/78. :)

Thanks,

On 2019/7/25 17:49, Jia-Ju Bai wrote:
> In update_general_status(), there are two if statements to
> check whether SM_I(sbi) is NULL:
> LINE 70:     if (SM_I(sbi) && SM_I(sbi)->fcc_info)
> LINE 78:     if (SM_I(sbi) && SM_I(sbi)->dcc_info)
> 
> When SM_I(sbi) is NULL, it is used at some places, such as:
> LINE 88: reserved_segments(sbi)
>                    return SM_I(sbi)->reserved_segments;
> LINE 89: overprovision_segments(sbi)
>                    return SM_I(sbi)->ovp_segments;
> LINE 112: MAIN_SEGS(sbi)
>                      (SM_I(sbi)->main_segments)
> 
> Thus, possible null-pointer dereferences may occur.
> 
> These bugs are found by a static analysis tool STCheck written by us.
> 
> I do not know how to correctly fix these bugs, so I only report them.
> 
> 
> Best wishes,
> Jia-Ju Bai
> .
> 

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

* Re: [f2fs-dev] [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
@ 2019-07-26  3:19   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2019-07-26  3:19 UTC (permalink / raw)
  To: Jia-Ju Bai, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Hi Jiaju,

Thanks for the report, I checked the code, and found it doesn't need to check
SM_I(sbi) pointer, this is because in fill_super() and put_super(), we will call
f2fs_destroy_stats() in prior to f2fs_destroy_segment_manager(), so if current
sbi can still be visited in global stat list, SM_I(sbi) should be released yet.
So anyway, let's remove unneeded check in line 70/78. :)

Thanks,

On 2019/7/25 17:49, Jia-Ju Bai wrote:
> In update_general_status(), there are two if statements to
> check whether SM_I(sbi) is NULL:
> LINE 70:     if (SM_I(sbi) && SM_I(sbi)->fcc_info)
> LINE 78:     if (SM_I(sbi) && SM_I(sbi)->dcc_info)
> 
> When SM_I(sbi) is NULL, it is used at some places, such as:
> LINE 88: reserved_segments(sbi)
>                    return SM_I(sbi)->reserved_segments;
> LINE 89: overprovision_segments(sbi)
>                    return SM_I(sbi)->ovp_segments;
> LINE 112: MAIN_SEGS(sbi)
>                      (SM_I(sbi)->main_segments)
> 
> Thus, possible null-pointer dereferences may occur.
> 
> These bugs are found by a static analysis tool STCheck written by us.
> 
> I do not know how to correctly fix these bugs, so I only report them.
> 
> 
> Best wishes,
> Jia-Ju Bai
> .
> 


_______________________________________________
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] 6+ messages in thread

* Re: [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
  2019-07-26  3:19   ` [f2fs-dev] " Chao Yu
@ 2019-07-26  3:39     ` Jia-Ju Bai
  -1 siblings, 0 replies; 6+ messages in thread
From: Jia-Ju Bai @ 2019-07-26  3:39 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel



On 2019/7/26 11:19, Chao Yu wrote:
> Hi Jiaju,
>
> Thanks for the report, I checked the code, and found it doesn't need to check
> SM_I(sbi) pointer, this is because in fill_super() and put_super(), we will call
> f2fs_destroy_stats() in prior to f2fs_destroy_segment_manager(), so if current
> sbi can still be visited in global stat list, SM_I(sbi) should be released yet.
> So anyway, let's remove unneeded check in line 70/78. :)

Okay, I will send a patch to remove unneeded checks.


Best wishes,
Jia-Ju Bai

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

* Re: [f2fs-dev] [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
@ 2019-07-26  3:39     ` Jia-Ju Bai
  0 siblings, 0 replies; 6+ messages in thread
From: Jia-Ju Bai @ 2019-07-26  3:39 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel



On 2019/7/26 11:19, Chao Yu wrote:
> Hi Jiaju,
>
> Thanks for the report, I checked the code, and found it doesn't need to check
> SM_I(sbi) pointer, this is because in fill_super() and put_super(), we will call
> f2fs_destroy_stats() in prior to f2fs_destroy_segment_manager(), so if current
> sbi can still be visited in global stat list, SM_I(sbi) should be released yet.
> So anyway, let's remove unneeded check in line 70/78. :)

Okay, I will send a patch to remove unneeded checks.


Best wishes,
Jia-Ju Bai


_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2019-07-26  3:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25  9:49 [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status() Jia-Ju Bai
2019-07-25  9:49 ` [f2fs-dev] " Jia-Ju Bai
2019-07-26  3:19 ` Chao Yu
2019-07-26  3:19   ` [f2fs-dev] " Chao Yu
2019-07-26  3:39   ` Jia-Ju Bai
2019-07-26  3:39     ` [f2fs-dev] " Jia-Ju Bai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.