From: syzbot <syzbot+249018ea545364f78d04@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [syzbot] [PATCH] guard against unknown r->data_type in bch2_sb_dev_has_data()
Date: Tue, 14 May 2024 18:26:05 -0700 [thread overview]
Message-ID: <00000000000096207606187400e6@google.com> (raw)
In-Reply-To: <000000000000ebf2e0061866b102@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [PATCH] guard against unknown r->data_type in bch2_sb_dev_has_data()
Author: cam.alvarez.i@gmail.com
#syz test
Shift is perfomed only when the data type makes sense.
Fix a missing guard on r->data_type being known.
Signed-off-by: Camila Alvarez <cam.alvarez.i@gmail.com>
---
fs/bcachefs/replicas.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c
index 678b9c20e251..0fa91d0bf951 100644
--- a/fs/bcachefs/replicas.c
+++ b/fs/bcachefs/replicas.c
@@ -1006,14 +1006,14 @@ unsigned bch2_sb_dev_has_data(struct bch_sb *sb, unsigned dev)
for_each_replicas_entry(replicas, r)
for (i = 0; i < r->nr_devs; i++)
- if (r->devs[i] == dev)
+ if (r->devs[i] == dev && r->data_type < BCH_DATA_NR)
data_has |= 1 << r->data_type;
} else if (replicas_v0) {
struct bch_replicas_entry_v0 *r;
for_each_replicas_entry_v0(replicas_v0, r)
for (i = 0; i < r->nr_devs; i++)
- if (r->devs[i] == dev)
+ if (r->devs[i] == dev && r->data_type < BCH_DATA_NR)
data_has |= 1 << r->data_type;
}
--
2.34.1
next prev parent reply other threads:[~2024-05-15 1:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 9:33 [syzbot] [bcachefs?] UBSAN: shift-out-of-bounds in bch2_sb_dev_has_data syzbot
2024-05-15 1:26 ` syzbot [this message]
2024-06-23 21:05 ` Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00000000000096207606187400e6@google.com \
--to=syzbot+249018ea545364f78d04@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox