Skip to contentSkip to conversation

hfsplus: refactor b-tree map page access and add node-type validation

PATCH kernel test robot 1 participant 1 message Feb 26

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Shardul Bankar <[email protected]>
TO: [email protected]
TO: [email protected]
TO: [email protected]
TO: [email protected]
TO: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: Shardul Bankar <[email protected]>

Hi Shardul,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brauner-vfs/vfs.all]
[also build test WARNING on linus/master v7.0-rc1 next-20260226] [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/Shardul-Bankar/hfsplus-refactor-b-tree-map-page-access-and-add-node-type-validation/20260226-171914
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:    https://lore.kernel.org/r/20260226091235.927749-2-shardul.b%40mpiricsoftware.com
patch subject: [PATCH v4 1/2] hfsplus: refactor b-tree map page access and add node-type validation

:::::: branch date: 10 hours ago
:::::: commit date: 10 hours ago
config: hexagon-randconfig-r072-20260226 (https://download.01.org/0day-ci/archive/20260227/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) smatch version: v0.5.0-8994-gd50c5a4c

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
fs/hfsplus/btree.c:167 hfs_bmap_get_map_page() warn: right shifting more than type allows 16 vs 18 fs/hfsplus/btree.c:460 hfsplus_bmap_alloc() warn: impossible condition '(++off >= ((1) << 18)) => (0-u16max >= 262144)'

Old smatch warnings:
fs/hfsplus/btree.c:533 hfsplus_bmap_free() warn: right shifting more than type allows 16 vs 18

vim +167 fs/hfsplus/btree.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  131  
af50648ad1415c Shardul Bankar 2026-02-26  132  /*
af50648ad1415c Shardul Bankar 2026-02-26  133   * Maps the page containing the b-tree map record and calculates offsets.
af50648ad1415c Shardul Bankar 2026-02-26  134   * Automatically handles the difference between header and map nodes.
af50648ad1415c Shardul Bankar 2026-02-26  135   * Returns the mapped data pointer, or an ERR_PTR on failure.
af50648ad1415c Shardul Bankar 2026-02-26  136   * Note: The caller is responsible for calling kunmap_local(data).
af50648ad1415c Shardul Bankar 2026-02-26  137   */
af50648ad1415c Shardul Bankar 2026-02-26  138  static u8 *hfs_bmap_get_map_page(struct hfs_bnode *node, u16 *off, u16 *len,
af50648ad1415c Shardul Bankar 2026-02-26  139  				unsigned int *page_idx)
af50648ad1415c Shardul Bankar 2026-02-26  140  {
af50648ad1415c Shardul Bankar 2026-02-26  141  	u16 rec_idx, off16;
af50648ad1415c Shardul Bankar 2026-02-26  142  
af50648ad1415c Shardul Bankar 2026-02-26  143  	if (node->this == HFSPLUS_TREE_HEAD) {
af50648ad1415c Shardul Bankar 2026-02-26  144  		if (node->type != HFS_NODE_HEADER) {
af50648ad1415c Shardul Bankar 2026-02-26  145  			pr_err("hfsplus: invalid btree header node\n");
af50648ad1415c Shardul Bankar 2026-02-26  146  			return ERR_PTR(-EIO);
af50648ad1415c Shardul Bankar 2026-02-26  147  		}
af50648ad1415c Shardul Bankar 2026-02-26  148  		rec_idx = HFSPLUS_BTREE_HDR_MAP_REC_INDEX;
af50648ad1415c Shardul Bankar 2026-02-26  149  	} else {
af50648ad1415c Shardul Bankar 2026-02-26  150  		if (node->type != HFS_NODE_MAP) {
af50648ad1415c Shardul Bankar 2026-02-26  151  			pr_err("hfsplus: invalid btree map node\n");
af50648ad1415c Shardul Bankar 2026-02-26  152  			return ERR_PTR(-EIO);
af50648ad1415c Shardul Bankar 2026-02-26  153  		}
af50648ad1415c Shardul Bankar 2026-02-26  154  		rec_idx = HFSPLUS_BTREE_MAP_NODE_REC_INDEX;
af50648ad1415c Shardul Bankar 2026-02-26  155  	}
af50648ad1415c Shardul Bankar 2026-02-26  156  
af50648ad1415c Shardul Bankar 2026-02-26  157  	*len = hfs_brec_lenoff(node, rec_idx, &off16);
af50648ad1415c Shardul Bankar 2026-02-26  158  	if (!*len)
af50648ad1415c Shardul Bankar 2026-02-26  159  		return ERR_PTR(-ENOENT);
af50648ad1415c Shardul Bankar 2026-02-26  160  
af50648ad1415c Shardul Bankar 2026-02-26  161  	if (!is_bnode_offset_valid(node, off16))
af50648ad1415c Shardul Bankar 2026-02-26  162  		return ERR_PTR(-EIO);
af50648ad1415c Shardul Bankar 2026-02-26  163  
af50648ad1415c Shardul Bankar 2026-02-26  164  	*len = check_and_correct_requested_length(node, off16, *len);
af50648ad1415c Shardul Bankar 2026-02-26  165  
af50648ad1415c Shardul Bankar 2026-02-26  166  	off16 += node->page_offset;
af50648ad1415c Shardul Bankar 2026-02-26 @167  	*page_idx = off16 >> PAGE_SHIFT;
af50648ad1415c Shardul Bankar 2026-02-26  168  	*off = off16 & ~PAGE_MASK;
af50648ad1415c Shardul Bankar 2026-02-26  169  
af50648ad1415c Shardul Bankar 2026-02-26  170  	return kmap_local_page(node->page[*page_idx]);
af50648ad1415c Shardul Bankar 2026-02-26  171  }
af50648ad1415c Shardul Bankar 2026-02-26  172  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki