Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block

Prithvi Tambewagh posted 1 patch 1 day, 3 hours ago
fs/ocfs2/slot_map.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
Posted by Prithvi Tambewagh 1 day, 3 hours ago
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 24172e0d79900908cf5ebf366600616d29c9b417

Signed-off-by: Prithvi Tambewagh <activprithvi@gmail.com>
---
 fs/ocfs2/slot_map.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index e544c704b583..40e5e95fd375 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -44,6 +44,9 @@ struct ocfs2_slot_info {
 static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
 				    unsigned int node_num);
 
+static int ocfs2_validate_slot_map_block(struct super_block *sb,
+					  struct buffer_head *bh)
+
 static void ocfs2_invalidate_slot(struct ocfs2_slot_info *si,
 				  int slot_num)
 {
@@ -132,7 +135,8 @@ int ocfs2_refresh_slot_info(struct ocfs2_super *osb)
 	 * this is not true, the read of -1 (UINT64_MAX) will fail.
 	 */
 	ret = ocfs2_read_blocks(INODE_CACHE(si->si_inode), -1, si->si_blocks,
-				si->si_bh, OCFS2_BH_IGNORE_CACHE, NULL);
+				si->si_bh, OCFS2_BH_IGNORE_CACHE,
+				ocfs2_validate_slot_map_block);
 	if (ret == 0) {
 		spin_lock(&osb->osb_lock);
 		ocfs2_update_slot_info(si);
@@ -332,6 +336,26 @@ int ocfs2_clear_slot(struct ocfs2_super *osb, int slot_num)
 	return ocfs2_update_disk_slot(osb, osb->slot_info, slot_num);
 }
 
+static int ocfs2_validate_slot_map_block(struct super_block *sb,
+					  struct buffer_head *bh)
+{
+	int rc;
+
+	BUG_ON(!buffer_uptodate(bh));
+
+	if (bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO) {
+		rc = ocfs2_error(sb,
+				 "Invalid Slot Map Buffer Head "
+				 "Block Number : %llu, Should be >= %d",
+				 (unsigned long long)bh->b_blocknr,
+				 OCFS2_SUPER_BLOCK_BLKNO);
+		if (!rc)
+			return -EIO;
+		return rc;
+	}
+	return 0;
+}
+
 static int ocfs2_map_slot_buffers(struct ocfs2_super *osb,
 				  struct ocfs2_slot_info *si)
 {
@@ -383,7 +407,8 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb,
 
 		bh = NULL;  /* Acquire a fresh bh */
 		status = ocfs2_read_blocks(INODE_CACHE(si->si_inode), blkno,
-					   1, &bh, OCFS2_BH_IGNORE_CACHE, NULL);
+					   1, &bh, OCFS2_BH_IGNORE_CACHE,
+					   ocfs2_validate_slot_map_block);
 		if (status < 0) {
 			mlog_errno(status);
 			goto bail;

base-commit: 24172e0d79900908cf5ebf366600616d29c9b417
-- 
2.43.0
Re: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
Posted by kernel test robot 10 hours ago
Hi Prithvi,

kernel test robot noticed the following build errors:

[auto build test ERROR on 24172e0d79900908cf5ebf366600616d29c9b417]

url:    https://github.com/intel-lab-lkp/linux/commits/Prithvi-Tambewagh/Syzbot-test-for-v3-ocfs2-fix-kernel-BUG-in-ocfs2_write_block/20251215-032310
base:   24172e0d79900908cf5ebf366600616d29c9b417
patch link:    https://lore.kernel.org/r/20251214192047.34811-1-activprithvi%40gmail.com
patch subject: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20251215/202512151209.PXAJgMVX-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151209.PXAJgMVX-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/202512151209.PXAJgMVX-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   fs/ocfs2/slot_map.c: In function 'ocfs2_validate_slot_map_block':
>> fs/ocfs2/slot_map.c:52:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      52 | {
         | ^
   fs/ocfs2/slot_map.c:59:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      59 | {
         | ^
   fs/ocfs2/slot_map.c:68:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      68 | {
         | ^
   fs/ocfs2/slot_map.c:93:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      93 | {
         | ^
   fs/ocfs2/slot_map.c:108:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     108 | {
         | ^
   fs/ocfs2/slot_map.c:120:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     120 | {
         | ^
   fs/ocfs2/slot_map.c:154:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     154 | {
         | ^
   fs/ocfs2/slot_map.c:172:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     172 | {
         | ^
   fs/ocfs2/slot_map.c:190:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     190 | {
         | ^
   fs/ocfs2/slot_map.c:215:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     215 | {
         | ^
   fs/ocfs2/slot_map.c:239:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     239 | {
         | ^
   fs/ocfs2/slot_map.c:255:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     255 | {
         | ^
   fs/ocfs2/slot_map.c:276:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     276 | {
         | ^
   fs/ocfs2/slot_map.c:289:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     289 | {
         | ^
   fs/ocfs2/slot_map.c:305:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     305 | {
         | ^
   fs/ocfs2/slot_map.c:326:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     326 | {
         | ^
   fs/ocfs2/slot_map.c:341:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     341 | {
         | ^
   fs/ocfs2/slot_map.c:361:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     361 | {
         | ^
   fs/ocfs2/slot_map.c:425:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     425 | {
         | ^
   fs/ocfs2/slot_map.c:464:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     464 | {
         | ^
   fs/ocfs2/slot_map.c:472:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     472 | {
         | ^
   fs/ocfs2/slot_map.c:525:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     525 | {
         | ^
>> fs/ocfs2/slot_map.c:546: error: expected '{' at end of input
>> fs/ocfs2/slot_map.c:545:1: warning: no return statement in function returning non-void [-Wreturn-type]
     545 | }
         | ^
   fs/ocfs2/slot_map.c: At top level:
>> fs/ocfs2/slot_map.c:44:12: warning: '__ocfs2_node_num_to_slot' declared 'static' but never defined [-Wunused-function]
      44 | static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~
>> fs/ocfs2/slot_map.c:47:12: warning: 'ocfs2_validate_slot_map_block' defined but not used [-Wunused-function]
      47 | static int ocfs2_validate_slot_map_block(struct super_block *sb,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +52 fs/ocfs2/slot_map.c

d85b20e4b300ed Joel Becker       2008-02-01  42  
d85b20e4b300ed Joel Becker       2008-02-01  43  
fc881fa0d59596 Joel Becker       2008-02-01 @44  static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
fc881fa0d59596 Joel Becker       2008-02-01  45  				    unsigned int node_num);
fc881fa0d59596 Joel Becker       2008-02-01  46  
39ad33650c4c83 Prithvi Tambewagh 2025-12-15 @47  static int ocfs2_validate_slot_map_block(struct super_block *sb,
39ad33650c4c83 Prithvi Tambewagh 2025-12-15  48  					  struct buffer_head *bh)
39ad33650c4c83 Prithvi Tambewagh 2025-12-15  49  
fc881fa0d59596 Joel Becker       2008-02-01  50  static void ocfs2_invalidate_slot(struct ocfs2_slot_info *si,
fc881fa0d59596 Joel Becker       2008-02-01  51  				  int slot_num)
fc881fa0d59596 Joel Becker       2008-02-01 @52  {
fc881fa0d59596 Joel Becker       2008-02-01  53  	BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots));
fc881fa0d59596 Joel Becker       2008-02-01  54  	si->si_slots[slot_num].sl_valid = 0;
fc881fa0d59596 Joel Becker       2008-02-01  55  }
fc881fa0d59596 Joel Becker       2008-02-01  56  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
Posted by kernel test robot 11 hours ago
Hi Prithvi,

kernel test robot noticed the following build errors:

[auto build test ERROR on 24172e0d79900908cf5ebf366600616d29c9b417]

url:    https://github.com/intel-lab-lkp/linux/commits/Prithvi-Tambewagh/Syzbot-test-for-v3-ocfs2-fix-kernel-BUG-in-ocfs2_write_block/20251215-032310
base:   24172e0d79900908cf5ebf366600616d29c9b417
patch link:    https://lore.kernel.org/r/20251214192047.34811-1-activprithvi%40gmail.com
patch subject: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20251215/202512151240.MwIXYwyy-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151240.MwIXYwyy-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/202512151240.MwIXYwyy-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/ocfs2/slot_map.c:48:31: error: expected ';' after top level declarator
      48 |                                           struct buffer_head *bh)
         |                                                                  ^
         |                                                                  ;
   1 error generated.


vim +48 fs/ocfs2/slot_map.c

    42	
    43	
    44	static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
    45					    unsigned int node_num);
    46	
    47	static int ocfs2_validate_slot_map_block(struct super_block *sb,
  > 48						  struct buffer_head *bh)
    49	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
Posted by kernel test robot 17 hours ago
Hi Prithvi,

kernel test robot noticed the following build errors:

[auto build test ERROR on 24172e0d79900908cf5ebf366600616d29c9b417]

url:    https://github.com/intel-lab-lkp/linux/commits/Prithvi-Tambewagh/Syzbot-test-for-v3-ocfs2-fix-kernel-BUG-in-ocfs2_write_block/20251215-032310
base:   24172e0d79900908cf5ebf366600616d29c9b417
patch link:    https://lore.kernel.org/r/20251214192047.34811-1-activprithvi%40gmail.com
patch subject: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
config: arc-randconfig-002-20251215 (https://download.01.org/0day-ci/archive/20251215/202512151210.z9u1Ypu5-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 12.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151210.z9u1Ypu5-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/202512151210.z9u1Ypu5-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   fs/ocfs2/slot_map.c: In function 'ocfs2_validate_slot_map_block':
>> fs/ocfs2/slot_map.c:52:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      52 | {
         | ^
   fs/ocfs2/slot_map.c:59:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      59 | {
         | ^
   fs/ocfs2/slot_map.c:68:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      68 | {
         | ^
   fs/ocfs2/slot_map.c:93:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
      93 | {
         | ^
   fs/ocfs2/slot_map.c:108:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     108 | {
         | ^
   fs/ocfs2/slot_map.c:120:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     120 | {
         | ^
   fs/ocfs2/slot_map.c:154:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     154 | {
         | ^
   fs/ocfs2/slot_map.c:172:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     172 | {
         | ^
   fs/ocfs2/slot_map.c:190:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     190 | {
         | ^
   fs/ocfs2/slot_map.c:215:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     215 | {
         | ^
   fs/ocfs2/slot_map.c:239:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     239 | {
         | ^
   fs/ocfs2/slot_map.c:255:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     255 | {
         | ^
   fs/ocfs2/slot_map.c:276:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     276 | {
         | ^
   fs/ocfs2/slot_map.c:289:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     289 | {
         | ^
   fs/ocfs2/slot_map.c:305:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     305 | {
         | ^
   fs/ocfs2/slot_map.c:326:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     326 | {
         | ^
   fs/ocfs2/slot_map.c:341:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     341 | {
         | ^
   fs/ocfs2/slot_map.c:361:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     361 | {
         | ^
   fs/ocfs2/slot_map.c:425:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     425 | {
         | ^
   fs/ocfs2/slot_map.c:464:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     464 | {
         | ^
   fs/ocfs2/slot_map.c:472:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     472 | {
         | ^
   fs/ocfs2/slot_map.c:525:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
     525 | {
         | ^
>> fs/ocfs2/slot_map.c:546: error: expected '{' at end of input
>> fs/ocfs2/slot_map.c:545:1: warning: no return statement in function returning non-void [-Wreturn-type]
     545 | }
         | ^
   fs/ocfs2/slot_map.c: At top level:
>> fs/ocfs2/slot_map.c:44:12: warning: '__ocfs2_node_num_to_slot' declared 'static' but never defined [-Wunused-function]
      44 | static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~
>> fs/ocfs2/slot_map.c:47:12: warning: 'ocfs2_validate_slot_map_block' defined but not used [-Wunused-function]
      47 | static int ocfs2_validate_slot_map_block(struct super_block *sb,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +52 fs/ocfs2/slot_map.c

d85b20e4b300ed Joel Becker       2008-02-01  42  
d85b20e4b300ed Joel Becker       2008-02-01  43  
fc881fa0d59596 Joel Becker       2008-02-01 @44  static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
fc881fa0d59596 Joel Becker       2008-02-01  45  				    unsigned int node_num);
fc881fa0d59596 Joel Becker       2008-02-01  46  
39ad33650c4c83 Prithvi Tambewagh 2025-12-15 @47  static int ocfs2_validate_slot_map_block(struct super_block *sb,
39ad33650c4c83 Prithvi Tambewagh 2025-12-15  48  					  struct buffer_head *bh)
39ad33650c4c83 Prithvi Tambewagh 2025-12-15  49  
fc881fa0d59596 Joel Becker       2008-02-01  50  static void ocfs2_invalidate_slot(struct ocfs2_slot_info *si,
fc881fa0d59596 Joel Becker       2008-02-01  51  				  int slot_num)
fc881fa0d59596 Joel Becker       2008-02-01 @52  {
fc881fa0d59596 Joel Becker       2008-02-01  53  	BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots));
fc881fa0d59596 Joel Becker       2008-02-01  54  	si->si_slots[slot_num].sl_valid = 0;
fc881fa0d59596 Joel Becker       2008-02-01  55  }
fc881fa0d59596 Joel Becker       2008-02-01  56  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
Posted by kernel test robot 17 hours ago
Hi Prithvi,

kernel test robot noticed the following build errors:

[auto build test ERROR on 24172e0d79900908cf5ebf366600616d29c9b417]

url:    https://github.com/intel-lab-lkp/linux/commits/Prithvi-Tambewagh/Syzbot-test-for-v3-ocfs2-fix-kernel-BUG-in-ocfs2_write_block/20251215-032310
base:   24172e0d79900908cf5ebf366600616d29c9b417
patch link:    https://lore.kernel.org/r/20251214192047.34811-1-activprithvi%40gmail.com
patch subject: Syzbot test for v3: ocfs2: fix kernel BUG in ocfs2_write_block
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20251215/202512151201.4cweqZmR-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151201.4cweqZmR-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/202512151201.4cweqZmR-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/ocfs2/slot_map.c:48:31: error: expected ';' after top level declarator
      48 |                                           struct buffer_head *bh)
         |                                                                  ^
         |                                                                  ;
   1 error generated.


vim +48 fs/ocfs2/slot_map.c

    42	
    43	
    44	static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
    45					    unsigned int node_num);
    46	
    47	static int ocfs2_validate_slot_map_block(struct super_block *sb,
  > 48						  struct buffer_head *bh)
    49	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [syzbot] [ocfs2?] kernel BUG in ocfs2_write_block
Posted by syzbot 1 day, 2 hours ago
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

fs/ocfs2/slot_map.c:48:31: error: expected ';' after top level declarator


Tested on:

commit:         24172e0d Merge tag 'arm64-fixes' of git://git.kernel.o..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel config:  https://syzkaller.appspot.com/x/.config?x=41ad820f608cb833
dashboard link: https://syzkaller.appspot.com/bug?extid=c818e5c4559444f88aa0
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=10f4811a580000