* [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage
@ 2023-10-02 9:56 Juntong Deng
2023-10-02 15:56 ` Ricardo B. Marliere
2023-10-03 23:27 ` Dave Kleikamp
0 siblings, 2 replies; 4+ messages in thread
From: Juntong Deng @ 2023-10-02 9:56 UTC (permalink / raw)
To: shaggy, wonguk.lee1023, liushixin2, andrew.kanner, wuhoipok
Cc: jfs-discussion, linux-kernel, linux-kernel-mentees,
syzbot+debee9ab7ae2b34b0307
l2nbperpage is log2(number of blks per page), and the minimum legal
value should be 0, not negative.
In the case of l2nbperpage being negative, an error will occur
when subsequently used as shift exponent.
Syzbot reported this bug:
UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:799:12
shift exponent -16777216 is negative
Reported-by: syzbot+debee9ab7ae2b34b0307@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=debee9ab7ae2b34b0307
Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
---
fs/jfs/jfs_dmap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 88afd108c2dd..3a1842348112 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -180,7 +180,8 @@ int dbMount(struct inode *ipbmap)
bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
- if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE) {
+ if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE ||
+ bmp->db_l2nbperpage < 0) {
err = -EINVAL;
goto err_release_metapage;
}
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage
2023-10-02 9:56 [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage Juntong Deng
@ 2023-10-02 15:56 ` Ricardo B. Marliere
2023-10-02 18:24 ` Juntong Deng
2023-10-03 23:27 ` Dave Kleikamp
1 sibling, 1 reply; 4+ messages in thread
From: Ricardo B. Marliere @ 2023-10-02 15:56 UTC (permalink / raw)
To: Juntong Deng
Cc: shaggy, wonguk.lee1023, liushixin2, andrew.kanner, wuhoipok,
jfs-discussion, linux-kernel-mentees, linux-kernel,
syzbot+debee9ab7ae2b34b0307
On 23/10/02 05:56PM, Juntong Deng wrote:
> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
> ---
> fs/jfs/jfs_dmap.c | 3 ++-
Hey there, looks like you forgot to add a changelog for v1->v2? I see
you just changed the commit tags ordering but you should have that in
mind for next time :)
- Ricardo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage
2023-10-02 15:56 ` Ricardo B. Marliere
@ 2023-10-02 18:24 ` Juntong Deng
0 siblings, 0 replies; 4+ messages in thread
From: Juntong Deng @ 2023-10-02 18:24 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: shaggy, wonguk.lee1023, liushixin2, andrew.kanner, wuhoipok,
jfs-discussion, linux-kernel-mentees, linux-kernel,
syzbot+debee9ab7ae2b34b0307
On 2023/10/2 23:56, Ricardo B. Marliere wrote:
> On 23/10/02 05:56PM, Juntong Deng wrote:
>> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
>> ---
>> fs/jfs/jfs_dmap.c | 3 ++-
>
> Hey there, looks like you forgot to add a changelog for v1->v2? I see
> you just changed the commit tags ordering but you should have that in
> mind for next time :)
>
> - Ricardo
Hi, Ricardo.
I just made a mistake in the order of the tags, I should have
put Signed-off-by last, I did not change any code so I did not
add the changelog.
I am not sure if the changelog should be added if the code of
the patch is not changed.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage
2023-10-02 9:56 [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage Juntong Deng
2023-10-02 15:56 ` Ricardo B. Marliere
@ 2023-10-03 23:27 ` Dave Kleikamp
1 sibling, 0 replies; 4+ messages in thread
From: Dave Kleikamp @ 2023-10-03 23:27 UTC (permalink / raw)
To: Juntong Deng, shaggy, wonguk.lee1023, liushixin2, andrew.kanner,
wuhoipok
Cc: jfs-discussion, linux-kernel, linux-kernel-mentees,
syzbot+debee9ab7ae2b34b0307
On 10/2/23 4:56AM, Juntong Deng wrote:
> l2nbperpage is log2(number of blks per page), and the minimum legal
> value should be 0, not negative.
>
> In the case of l2nbperpage being negative, an error will occur
> when subsequently used as shift exponent.
>
> Syzbot reported this bug:
>
> UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:799:12
> shift exponent -16777216 is negative
Looks good. (A little part of me wants to go through the code and make a
lot of signed ints unsigned, but not today.)
Applied to jfs-next
Thanks,
Shaggy
>
> Reported-by: syzbot+debee9ab7ae2b34b0307@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=debee9ab7ae2b34b0307
> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
> ---
> fs/jfs/jfs_dmap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
> index 88afd108c2dd..3a1842348112 100644
> --- a/fs/jfs/jfs_dmap.c
> +++ b/fs/jfs/jfs_dmap.c
> @@ -180,7 +180,8 @@ int dbMount(struct inode *ipbmap)
> bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
>
> bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
> - if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE) {
> + if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE ||
> + bmp->db_l2nbperpage < 0) {
> err = -EINVAL;
> goto err_release_metapage;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-03 23:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-02 9:56 [PATCH v2] fs/jfs: Add check for negative db_l2nbperpage Juntong Deng
2023-10-02 15:56 ` Ricardo B. Marliere
2023-10-02 18:24 ` Juntong Deng
2023-10-03 23:27 ` Dave Kleikamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®