LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [BUG] jfs: possible uninitialized-variable access in xtSplitUp()
@ 2021-07-31 6:31 Li Tuo
2021-08-02 19:04 ` Dave Kleikamp
0 siblings, 1 reply; 3+ messages in thread
From: Li Tuo @ 2021-07-31 6:31 UTC (permalink / raw)
To: shaggy; +Cc: jfs-discussion, linux-kernel, baijiaju1990
Hello,
Our static analysis tool finds a possible uninitialized-variable access
in the jfs driver in Linux 5.14.0-rc3:
At the beginning of the function xtSplitUp(), the variable rbn is not
initialized.
If sp->header.flag & BT_ROOT is true,
780: rc = (sp->header.flag & BT_ROOT) ? xtSplitRoot(tid, ip, split,
&rmp) : xtSplitPage(tid, ip, split, &rmp, &rbn);
the varialbe rbn will remain uninitialized.
However, it is accessed through:
814: rcbn = rbn;
I am not quite sure whether this possible uninitialized-variable access
is real and how to fix it if it is real.
Any feedback would be appreciated, thanks!
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Best wishes,
Tuo Li
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] jfs: possible uninitialized-variable access in xtSplitUp()
2021-07-31 6:31 [BUG] jfs: possible uninitialized-variable access in xtSplitUp() Li Tuo
@ 2021-08-02 19:04 ` Dave Kleikamp
2021-08-03 2:46 ` Li Tuo
0 siblings, 1 reply; 3+ messages in thread
From: Dave Kleikamp @ 2021-08-02 19:04 UTC (permalink / raw)
To: Li Tuo; +Cc: jfs-discussion, linux-kernel, baijiaju1990
On 7/31/21 1:31 AM, Li Tuo wrote:
> Hello,
>
> Our static analysis tool finds a possible uninitialized-variable access
> in the jfs driver in Linux 5.14.0-rc3:
>
> At the beginning of the function xtSplitUp(), the variable rbn is not
> initialized.
> If sp->header.flag & BT_ROOT is true,
> 780: rc = (sp->header.flag & BT_ROOT) ? xtSplitRoot(tid, ip, split,
> &rmp) : xtSplitPage(tid, ip, split, &rmp, &rbn);
>
> the varialbe rbn will remain uninitialized.
> However, it is accessed through:
> 814: rcbn = rbn;
>
> I am not quite sure whether this possible uninitialized-variable access
> is real and how to fix it if it is real.
> Any feedback would be appreciated, thanks!
I think the logic that protects us is that in the case where rbn is
uninitialized, sp->header.flag & BT_ROOT, which means it SHOULD BE the
last entry in btstack, so we shouldn't enter the loop:
while ((parent = BT_POP(btstack)) != NULL) {
It does seem that some type of sanity check is warranted. I'll take a
closer look and see if I can add some kind of error path if things are
out of sync.
>
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
>
> Best wishes,
> Tuo Li
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] jfs: possible uninitialized-variable access in xtSplitUp()
2021-08-02 19:04 ` Dave Kleikamp
@ 2021-08-03 2:46 ` Li Tuo
0 siblings, 0 replies; 3+ messages in thread
From: Li Tuo @ 2021-08-03 2:46 UTC (permalink / raw)
To: Dave Kleikamp; +Cc: jfs-discussion, linux-kernel, baijiaju1990
Thanks for your feedback, and any feedback about the further check would
be appreciated!
Best wishes,
Tuo Li
On 2021/8/3 3:04, Dave Kleikamp wrote:
> On 7/31/21 1:31 AM, Li Tuo wrote:
>> Hello,
>>
>> Our static analysis tool finds a possible uninitialized-variable
>> access in the jfs driver in Linux 5.14.0-rc3:
>>
>> At the beginning of the function xtSplitUp(), the variable rbn is not
>> initialized.
>> If sp->header.flag & BT_ROOT is true,
>> 780: rc = (sp->header.flag & BT_ROOT) ? xtSplitRoot(tid, ip,
>> split, &rmp) : xtSplitPage(tid, ip, split, &rmp, &rbn);
>>
>> the varialbe rbn will remain uninitialized.
>> However, it is accessed through:
>> 814: rcbn = rbn;
>>
>> I am not quite sure whether this possible uninitialized-variable
>> access is real and how to fix it if it is real.
>> Any feedback would be appreciated, thanks!
>
> I think the logic that protects us is that in the case where rbn is
> uninitialized, sp->header.flag & BT_ROOT, which means it SHOULD BE the
> last entry in btstack, so we shouldn't enter the loop:
> while ((parent = BT_POP(btstack)) != NULL) {
>
> It does seem that some type of sanity check is warranted. I'll take a
> closer look and see if I can add some kind of error path if things are
> out of sync.
>
>>
>> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
>>
>> Best wishes,
>> Tuo Li
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-03 2:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31 6:31 [BUG] jfs: possible uninitialized-variable access in xtSplitUp() Li Tuo
2021-08-02 19:04 ` Dave Kleikamp
2021-08-03 2:46 ` Li Tuo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).