All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: fs/afs/dir_search.c:155 afs_dir_search_bucket() warn: potential spectre issue 'block->dirents' [r] (local cap)
Date: Sat, 13 Dec 2025 21:01:12 +0800	[thread overview]
Message-ID: <202512132017.RftO5LB3-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: David Howells <dhowells@redhat.com>
CC: Christian Brauner <brauner@kernel.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   9d9c1cfec01cdbf24bd9322ed555713a20422115
commit: a5b5beebcf96d5e8a2fc79856c2ac1e93f82478e afs: Use the contained hashtable to search a directory
date:   12 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 12 months ago
config: arm64-randconfig-r071-20251211 (https://download.01.org/0day-ci/archive/20251213/202512132017.RftO5LB3-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 6ec8c4351cfc1d0627d1633b02ea787bd29c77d8)

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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202512132017.RftO5LB3-lkp@intel.com/

smatch warnings:
fs/afs/dir_search.c:155 afs_dir_search_bucket() warn: potential spectre issue 'block->dirents' [r] (local cap)

vim +155 fs/afs/dir_search.c

a5b5beebcf96d5 David Howells 2024-12-16  119  
a5b5beebcf96d5 David Howells 2024-12-16  120  /*
a5b5beebcf96d5 David Howells 2024-12-16  121   * Search through a directory bucket.
a5b5beebcf96d5 David Howells 2024-12-16  122   */
a5b5beebcf96d5 David Howells 2024-12-16  123  int afs_dir_search_bucket(struct afs_dir_iter *iter, const struct qstr *name,
a5b5beebcf96d5 David Howells 2024-12-16  124  			  struct afs_fid *_fid)
a5b5beebcf96d5 David Howells 2024-12-16  125  {
a5b5beebcf96d5 David Howells 2024-12-16  126  	const union afs_xdr_dir_block *meta;
a5b5beebcf96d5 David Howells 2024-12-16  127  	unsigned int entry;
a5b5beebcf96d5 David Howells 2024-12-16  128  	int ret = -ESTALE;
a5b5beebcf96d5 David Howells 2024-12-16  129  
a5b5beebcf96d5 David Howells 2024-12-16  130  	meta = afs_dir_find_block(iter, 0);
a5b5beebcf96d5 David Howells 2024-12-16  131  	if (!meta)
a5b5beebcf96d5 David Howells 2024-12-16  132  		return -ESTALE;
a5b5beebcf96d5 David Howells 2024-12-16  133  
a5b5beebcf96d5 David Howells 2024-12-16  134  	entry = ntohs(meta->meta.hashtable[iter->bucket & (AFS_DIR_HASHTBL_SIZE - 1)]);
a5b5beebcf96d5 David Howells 2024-12-16  135  	_enter("%x,%x", iter->bucket, entry);
a5b5beebcf96d5 David Howells 2024-12-16  136  
a5b5beebcf96d5 David Howells 2024-12-16  137  	while (entry) {
a5b5beebcf96d5 David Howells 2024-12-16  138  		const union afs_xdr_dir_block *block;
a5b5beebcf96d5 David Howells 2024-12-16  139  		const union afs_xdr_dirent *dire;
a5b5beebcf96d5 David Howells 2024-12-16  140  		unsigned int blnum = entry / AFS_DIR_SLOTS_PER_BLOCK;
a5b5beebcf96d5 David Howells 2024-12-16  141  		unsigned int slot = entry % AFS_DIR_SLOTS_PER_BLOCK;
a5b5beebcf96d5 David Howells 2024-12-16  142  		unsigned int resv = (blnum == 0 ? AFS_DIR_RESV_BLOCKS0 : AFS_DIR_RESV_BLOCKS);
a5b5beebcf96d5 David Howells 2024-12-16  143  
a5b5beebcf96d5 David Howells 2024-12-16  144  		_debug("search %x", entry);
a5b5beebcf96d5 David Howells 2024-12-16  145  
a5b5beebcf96d5 David Howells 2024-12-16  146  		if (slot < resv) {
a5b5beebcf96d5 David Howells 2024-12-16  147  			kdebug("slot out of range h=%x rs=%2x sl=%2x-%2x",
a5b5beebcf96d5 David Howells 2024-12-16  148  			       iter->bucket, resv, slot, slot + iter->nr_slots - 1);
a5b5beebcf96d5 David Howells 2024-12-16  149  			goto bad;
a5b5beebcf96d5 David Howells 2024-12-16  150  		}
a5b5beebcf96d5 David Howells 2024-12-16  151  
a5b5beebcf96d5 David Howells 2024-12-16  152  		block = afs_dir_find_block(iter, blnum);
a5b5beebcf96d5 David Howells 2024-12-16  153  		if (!block)
a5b5beebcf96d5 David Howells 2024-12-16  154  			goto bad;
a5b5beebcf96d5 David Howells 2024-12-16 @155  		dire = &block->dirents[slot];
a5b5beebcf96d5 David Howells 2024-12-16  156  
a5b5beebcf96d5 David Howells 2024-12-16  157  		if (slot + iter->nr_slots <= AFS_DIR_SLOTS_PER_BLOCK &&
a5b5beebcf96d5 David Howells 2024-12-16  158  		    memcmp(dire->u.name, name->name, name->len) == 0 &&
a5b5beebcf96d5 David Howells 2024-12-16  159  		    dire->u.name[name->len] == '\0') {
a5b5beebcf96d5 David Howells 2024-12-16  160  			_fid->vnode  = ntohl(dire->u.vnode);
a5b5beebcf96d5 David Howells 2024-12-16  161  			_fid->unique = ntohl(dire->u.unique);
a5b5beebcf96d5 David Howells 2024-12-16  162  			ret = entry;
a5b5beebcf96d5 David Howells 2024-12-16  163  			goto found;
a5b5beebcf96d5 David Howells 2024-12-16  164  		}
a5b5beebcf96d5 David Howells 2024-12-16  165  
a5b5beebcf96d5 David Howells 2024-12-16  166  		iter->prev_entry = entry;
a5b5beebcf96d5 David Howells 2024-12-16  167  		entry = ntohs(dire->u.hash_next);
a5b5beebcf96d5 David Howells 2024-12-16  168  		if (!--iter->loop_check) {
a5b5beebcf96d5 David Howells 2024-12-16  169  			kdebug("dir chain loop h=%x", iter->bucket);
a5b5beebcf96d5 David Howells 2024-12-16  170  			goto bad;
a5b5beebcf96d5 David Howells 2024-12-16  171  		}
a5b5beebcf96d5 David Howells 2024-12-16  172  	}
a5b5beebcf96d5 David Howells 2024-12-16  173  
a5b5beebcf96d5 David Howells 2024-12-16  174  	ret = -ENOENT;
a5b5beebcf96d5 David Howells 2024-12-16  175  found:
a5b5beebcf96d5 David Howells 2024-12-16  176  	if (iter->block) {
a5b5beebcf96d5 David Howells 2024-12-16  177  		kunmap_local(iter->block);
a5b5beebcf96d5 David Howells 2024-12-16  178  		iter->block = NULL;
a5b5beebcf96d5 David Howells 2024-12-16  179  	}
a5b5beebcf96d5 David Howells 2024-12-16  180  
a5b5beebcf96d5 David Howells 2024-12-16  181  bad:
a5b5beebcf96d5 David Howells 2024-12-16  182  	if (ret == -ESTALE)
a5b5beebcf96d5 David Howells 2024-12-16  183  		afs_invalidate_dir(iter->dvnode, afs_dir_invalid_iter_stale);
a5b5beebcf96d5 David Howells 2024-12-16  184  	_leave(" = %d", ret);
a5b5beebcf96d5 David Howells 2024-12-16  185  	return ret;
a5b5beebcf96d5 David Howells 2024-12-16  186  }
a5b5beebcf96d5 David Howells 2024-12-16  187  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

             reply	other threads:[~2025-12-13 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-13 13:01 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-12-11 22:57 fs/afs/dir_search.c:155 afs_dir_search_bucket() warn: potential spectre issue 'block->dirents' [r] (local cap) kernel test robot

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=202512132017.RftO5LB3-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.