From: kernel test robot <lkp@intel.com>
To: Lizhi Xu <lizhi.xu@windriver.com>,
syzbot+47ecc948aadfb2ab3efc@syzkaller.appspotmail.com
Cc: oe-kbuild-all@lists.linux.dev, kent.overstreet@linux.dev,
linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] bcachefs: Fix oob in bch2_dev_journal_init
Date: Tue, 20 Aug 2024 03:45:25 +0800 [thread overview]
Message-ID: <202408200353.I1MmR4S5-lkp@intel.com> (raw)
In-Reply-To: <20240819064754.35606-1-lizhi.xu@windriver.com>
Hi Lizhi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.11-rc4 next-20240819]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lizhi-Xu/bcachefs-Fix-oob-in-bch2_dev_journal_init/20240819-145031
base: linus/master
patch link: https://lore.kernel.org/r/20240819064754.35606-1-lizhi.xu%40windriver.com
patch subject: [PATCH] bcachefs: Fix oob in bch2_dev_journal_init
config: arc-randconfig-001-20240819 (https://download.01.org/0day-ci/archive/20240820/202408200353.I1MmR4S5-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240820/202408200353.I1MmR4S5-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408200353.I1MmR4S5-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from fs/bcachefs/vstructs.h:5,
from fs/bcachefs/bcachefs_format.h:80,
from fs/bcachefs/bcachefs.h:207,
from fs/bcachefs/journal.c:8:
fs/bcachefs/journal.c: In function 'bch2_dev_journal_init':
>> fs/bcachefs/journal.c:1316:50: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat=]
1316 | prt_printf(&buf, "journal v2 entry d[%u].nr %lu overflow!\n", i,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/bcachefs/util.h:78:63: note: in definition of macro 'prt_printf'
78 | #define prt_printf(_out, ...) bch2_prt_printf(_out, __VA_ARGS__)
| ^~~~~~~~~~~
fs/bcachefs/journal.c:1316:79: note: format string is defined here
1316 | prt_printf(&buf, "journal v2 entry d[%u].nr %lu overflow!\n", i,
| ~~^
| |
| long unsigned int
| %llu
vim +1316 fs/bcachefs/journal.c
1297
1298 int bch2_dev_journal_init(struct bch_dev *ca, struct bch_sb *sb)
1299 {
1300 struct journal_device *ja = &ca->journal;
1301 struct bch_sb_field_journal *journal_buckets =
1302 bch2_sb_field_get(sb, journal);
1303 struct bch_sb_field_journal_v2 *journal_buckets_v2 =
1304 bch2_sb_field_get(sb, journal_v2);
1305
1306 ja->nr = 0;
1307
1308 if (journal_buckets_v2) {
1309 unsigned nr = bch2_sb_field_journal_v2_nr_entries(journal_buckets_v2);
1310
1311 for (unsigned i = 0; i < nr; i++) {
1312 ja->nr += le64_to_cpu(journal_buckets_v2->d[i].nr);
1313 if (le64_to_cpu(journal_buckets_v2->d[i].nr) > UINT_MAX) {
1314 struct bch_fs *c = ca->fs;
1315 struct printbuf buf = PRINTBUF;
> 1316 prt_printf(&buf, "journal v2 entry d[%u].nr %lu overflow!\n", i,
1317 le64_to_cpu(journal_buckets_v2->d[i].nr));
1318 bch_info(c, "%s", buf.buf);
1319 printbuf_exit(&buf);
1320 return -BCH_ERR_ENOMEM_dev_journal_init;
1321 }
1322 }
1323 } else if (journal_buckets) {
1324 ja->nr = bch2_nr_journal_buckets(journal_buckets);
1325 }
1326
1327 ja->bucket_seq = kcalloc(ja->nr, sizeof(u64), GFP_KERNEL);
1328 if (!ja->bucket_seq)
1329 return -BCH_ERR_ENOMEM_dev_journal_init;
1330
1331 unsigned nr_bvecs = DIV_ROUND_UP(JOURNAL_ENTRY_SIZE_MAX, PAGE_SIZE);
1332
1333 for (unsigned i = 0; i < ARRAY_SIZE(ja->bio); i++) {
1334 ja->bio[i] = kmalloc(struct_size(ja->bio[i], bio.bi_inline_vecs,
1335 nr_bvecs), GFP_KERNEL);
1336 if (!ja->bio[i])
1337 return -BCH_ERR_ENOMEM_dev_journal_init;
1338
1339 ja->bio[i]->ca = ca;
1340 ja->bio[i]->buf_idx = i;
1341 bio_init(&ja->bio[i]->bio, NULL, ja->bio[i]->bio.bi_inline_vecs, nr_bvecs, 0);
1342 }
1343
1344 ja->buckets = kcalloc(ja->nr, sizeof(u64), GFP_KERNEL);
1345 if (!ja->buckets)
1346 return -BCH_ERR_ENOMEM_dev_journal_init;
1347
1348 if (journal_buckets_v2) {
1349 unsigned nr = bch2_sb_field_journal_v2_nr_entries(journal_buckets_v2);
1350 unsigned dst = 0;
1351
1352 for (unsigned i = 0; i < nr; i++)
1353 for (unsigned j = 0; j < le64_to_cpu(journal_buckets_v2->d[i].nr); j++)
1354 ja->buckets[dst++] =
1355 le64_to_cpu(journal_buckets_v2->d[i].start) + j;
1356 } else if (journal_buckets) {
1357 for (unsigned i = 0; i < ja->nr; i++)
1358 ja->buckets[i] = le64_to_cpu(journal_buckets->buckets[i]);
1359 }
1360
1361 return 0;
1362 }
1363
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next prev parent reply other threads:[~2024-08-19 19:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-18 17:06 [syzbot] [bcachefs?] KASAN: slab-out-of-bounds Write in bch2_dev_journal_init syzbot
2024-08-19 6:47 ` [PATCH] bcachefs: Fix oob " Lizhi Xu
2024-08-19 7:05 ` Kent Overstreet
2024-08-20 7:11 ` [PATCH V2] bcachefs: Add journal v2 entry nr value check Lizhi Xu
2024-08-20 23:34 ` Kent Overstreet
2024-08-21 2:33 ` Lizhi Xu
2024-08-21 2:55 ` Kent Overstreet
2024-08-21 2:57 ` [PATCH V3] " Lizhi Xu
2024-08-21 3:00 ` Kent Overstreet
2024-08-21 3:10 ` Lizhi Xu
2024-08-21 3:16 ` Kent Overstreet
2024-08-21 3:19 ` Kent Overstreet
2024-08-21 3:30 ` Lizhi Xu
2024-08-19 15:17 ` [PATCH] bcachefs: Fix oob in bch2_dev_journal_init kernel test robot
2024-08-19 19:45 ` kernel test robot [this message]
2024-08-22 3:03 ` [syzbot] [bcachefs?] KASAN: slab-out-of-bounds Write " 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=202408200353.I1MmR4S5-lkp@intel.com \
--to=lkp@intel.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.xu@windriver.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=syzbot+47ecc948aadfb2ab3efc@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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