* [PATCH] jfs: add a check to prevent array-index-out-of-bounds
@ 2024-10-08 20:21 Nihar Chaithanya
2024-10-29 22:39 ` Dave Kleikamp
0 siblings, 1 reply; 2+ messages in thread
From: Nihar Chaithanya @ 2024-10-08 20:21 UTC (permalink / raw)
To: shaggy
Cc: jfs-discussion, skhan, linux-bcachefs, linux-kernel,
Nihar Chaithanya, syzbot+412dea214d8baa3f7483
When the value of lp is 1 at the end of the iteration in the for loop,
lp is modified in the next iteration to a negative value.
Add a check to prevent this condition.
Reported-by: syzbot+412dea214d8baa3f7483@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=412dea214d8baa3f7483
Tested-by: syzbot+412dea214d8baa3f7483@syzkaller.appspotmail.com
Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
---
fs/jfs/jfs_dmap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 5713994328cb..3ebb2dfdd0b3 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2911,6 +2911,12 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
*/
tp->dmt_stree[pp] = max;
+ /* check to prevent negative value of lp on the
+ * next iteration.
+ */
+ if (lp == 1)
+ break;
+
/* parent becomes leaf for next go-round.
*/
lp = pp;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] jfs: add a check to prevent array-index-out-of-bounds
2024-10-08 20:21 [PATCH] jfs: add a check to prevent array-index-out-of-bounds Nihar Chaithanya
@ 2024-10-29 22:39 ` Dave Kleikamp
0 siblings, 0 replies; 2+ messages in thread
From: Dave Kleikamp @ 2024-10-29 22:39 UTC (permalink / raw)
To: Nihar Chaithanya, shaggy
Cc: jfs-discussion, skhan, linux-bcachefs, linux-kernel,
syzbot+412dea214d8baa3f7483
On 10/8/24 3:21PM, Nihar Chaithanya wrote:
> When the value of lp is 1 at the end of the iteration in the for loop,
> lp is modified in the next iteration to a negative value.
> Add a check to prevent this condition.
>
> Reported-by: syzbot+412dea214d8baa3f7483@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=412dea214d8baa3f7483
> Tested-by: syzbot+412dea214d8baa3f7483@syzkaller.appspotmail.com
> Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
> ---
> fs/jfs/jfs_dmap.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
> index 5713994328cb..3ebb2dfdd0b3 100644
> --- a/fs/jfs/jfs_dmap.c
> +++ b/fs/jfs/jfs_dmap.c
> @@ -2911,6 +2911,12 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
> */
> tp->dmt_stree[pp] = max;
>
> + /* check to prevent negative value of lp on the
> + * next iteration.
> + */
> + if (lp == 1)
> + break;
> +
I'm going to change this a little bit. I think it's a little cleaner to
test lp for zero at the top of the loop.
> /* parent becomes leaf for next go-round.
> */
> lp = pp;
That and rewording the commit message, I will apply this.
Thanks,
Shaggy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-29 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 20:21 [PATCH] jfs: add a check to prevent array-index-out-of-bounds Nihar Chaithanya
2024-10-29 22:39 ` Dave Kleikamp
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.