public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get()
@ 2019-07-24  8:50 Jia-Ju Bai
  2019-07-24  9:04 ` [Cluster-devel] " Steven Whitehouse
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2019-07-24  8:50 UTC (permalink / raw)
  To: rpeterso, agruenba; +Cc: cluster-devel, linux-kernel

In gfs2_rgrp_bh_get, there is an if statement on line 1191 to check 
whether "rgd->rd_bits[0].bi_bh" is NULL.
When "rgd->rd_bits[0].bi_bh" is NULL, it is used on line 1216:
     gfs2_rgrp_in(rgd, (rgd->rd_bits[0].bi_bh)->b_data);
and on line 1225:
     gfs2_rgrp_ondisk2lvb(..., rgd->rd_bits[0].bi_bh->b_data);
and on line 1228:
     if (!gfs2_rgrp_lvb_valid(rgd))

Note that in gfs2_rgrp_lvb_valid(rgd), there is a statement on line 1114:
     struct gfs2_rgrp *str = (struct gfs2_rgrp 
*)rgd->rd_bits[0].bi_bh->b_data;

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 bugs.


Best wishes,
Jia-Ju Bai

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

* Re: [Cluster-devel] [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get()
  2019-07-24  8:50 [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get() Jia-Ju Bai
@ 2019-07-24  9:04 ` Steven Whitehouse
  2019-07-24  9:08   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Whitehouse @ 2019-07-24  9:04 UTC (permalink / raw)
  To: Jia-Ju Bai, rpeterso, agruenba; +Cc: cluster-devel, linux-kernel

Hi,

On 24/07/2019 09:50, Jia-Ju Bai wrote:
> In gfs2_rgrp_bh_get, there is an if statement on line 1191 to check 
> whether "rgd->rd_bits[0].bi_bh" is NULL.

That is how we detect whether the rgrp has already been read in, so the 
function is skipped in the case that we've already read in the rgrp.


> When "rgd->rd_bits[0].bi_bh" is NULL, it is used on line 1216:
>     gfs2_rgrp_in(rgd, (rgd->rd_bits[0].bi_bh)->b_data);

No it isn't. See line 1196 where bi_bh is set, and where we also bail 
out (line 1198) in case it has not been set.


> and on line 1225:
>     gfs2_rgrp_ondisk2lvb(..., rgd->rd_bits[0].bi_bh->b_data);
> and on line 1228:
>     if (!gfs2_rgrp_lvb_valid(rgd))
>
> Note that in gfs2_rgrp_lvb_valid(rgd), there is a statement on line 1114:
>     struct gfs2_rgrp *str = (struct gfs2_rgrp 
> *)rgd->rd_bits[0].bi_bh->b_data;
>
> 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 bugs.
>
>
> Best wishes,
> Jia-Ju Bai
>
So I'm not seeing how there can be a NULL deref in those later lines. I 
think this is another false positive,

Steve.




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

* Re: [Cluster-devel] [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get()
  2019-07-24  9:04 ` [Cluster-devel] " Steven Whitehouse
@ 2019-07-24  9:08   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2019-07-24  9:08 UTC (permalink / raw)
  To: Steven Whitehouse, rpeterso, agruenba; +Cc: cluster-devel, linux-kernel

Thanks for the reply :)

On 2019/7/24 17:04, Steven Whitehouse wrote:
> Hi,
>
> On 24/07/2019 09:50, Jia-Ju Bai wrote:
>> In gfs2_rgrp_bh_get, there is an if statement on line 1191 to check 
>> whether "rgd->rd_bits[0].bi_bh" is NULL.
>
> That is how we detect whether the rgrp has already been read in, so 
> the function is skipped in the case that we've already read in the rgrp.
>
>
>> When "rgd->rd_bits[0].bi_bh" is NULL, it is used on line 1216:
>>     gfs2_rgrp_in(rgd, (rgd->rd_bits[0].bi_bh)->b_data);
>
> No it isn't. See line 1196 where bi_bh is set, and where we also bail 
> out (line 1198) in case it has not been set.
>

I overlooked the operation on line 1196...
Thanks for the pointer, I am sorry for the false report...


Best wishes,
Jia-Ju Bai

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

end of thread, other threads:[~2019-07-24  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-24  8:50 [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get() Jia-Ju Bai
2019-07-24  9:04 ` [Cluster-devel] " Steven Whitehouse
2019-07-24  9:08   ` Jia-Ju Bai

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