[PATCH] jfs: Issue a warning when leafidx is too large

Edward Adam Davis posted 1 patch 3 months, 3 weeks ago
fs/jfs/jfs_dmap.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] jfs: Issue a warning when leafidx is too large
Posted by Edward Adam Davis 3 months, 3 weeks ago
When it is clear that leafidx is too large, a warn is triggered to
distinguish it from other sizes.

Reported-by: syzbot+077d9ebda84f426a6a1e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=077d9ebda84f426a6a1e
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/jfs/jfs_dmap.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 35e063c9f3a4..7e3c5f6826d8 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2856,9 +2856,13 @@ static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl)
 static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
 {
 	int lp, pp, k;
-	int max, size;
+	int max, size, max_idx;
 
 	size = is_ctl ? CTLTREESIZE : TREESIZE;
+	max_idx = is_ctl ? LPERCTL : LPERDMAP;
+
+	if (WARN_ON_ONCE(le32_to_cpu(tp->dmt_leafidx) >= max_idx))
+		return;
 
 	/* pick up the index of the leaf for this leafno.
 	 */
-- 
2.43.0
Re: [PATCH] jfs: Issue a warning when leafidx is too large
Posted by Dave Kleikamp 2 months, 4 weeks ago
On 6/16/25 10:19PM, Edward Adam Davis wrote:
> When it is clear that leafidx is too large, a warn is triggered to
> distinguish it from other sizes.

I'm not convinced this is useful. Without this patch, we will still 
return with a WARN_ON_ONCE a couple lines of code later.

> 
> Reported-by: syzbot+077d9ebda84f426a6a1e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=077d9ebda84f426a6a1e
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
>   fs/jfs/jfs_dmap.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
> index 35e063c9f3a4..7e3c5f6826d8 100644
> --- a/fs/jfs/jfs_dmap.c
> +++ b/fs/jfs/jfs_dmap.c
> @@ -2856,9 +2856,13 @@ static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl)
>   static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
>   {
>   	int lp, pp, k;
> -	int max, size;
> +	int max, size, max_idx;
>   
>   	size = is_ctl ? CTLTREESIZE : TREESIZE;
> +	max_idx = is_ctl ? LPERCTL : LPERDMAP;
> +
> +	if (WARN_ON_ONCE(le32_to_cpu(tp->dmt_leafidx) >= max_idx))
> +		return;
>   
>   	/* pick up the index of the leaf for this leafno.
>   	 */