fs/nfsd/state.h:788 nfsd4_try_run_cb() warn: test_and_set_bit() takes a bit number
PATCH 35/53 fs/nfsd/state.h:788 nfsd4_try_run_cb() warn: test_and_set_bit() takes a bit number
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux nfsd-testing head: 312e8dc9f5f591a4927b4786a25840ef381c97d9 commit: f94ac2bc823ffbabc5c88c38e63a1e6635f8a6cd [35/53] nfsd: prevent callback tasks running concurrently config: x86_64-randconfig-161-20250306 (https://download.01.org/0day-ci/archive/20250307/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
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/nfsd/state.h:788 nfsd4_try_run_cb() warn: test_and_set_bit() takes a bit number fs/nfsd/nfs4state.c:3235 nfs4_cb_getattr() warn: test_and_set_bit() takes a bit number fs/nfsd/nfs4state.c:5428 nfsd_break_one_deleg() warn: test_and_set_bit() takes a bit number fs/nfsd/state.h:788 nfsd4_try_run_cb() warn: test_and_set_bit() takes a bit number fs/nfsd/nfs4callback.c:1315 nfsd41_destroy_cb() warn: clear_bit() takes a bit number fs/nfsd/nfs4layouts.c:347 nfsd4_recall_file_layout() warn: test_and_set_bit() takes a bit number
vim +788 fs/nfsd/state.h
f94ac2bc823ffb Jeff Layton 2025-02-20 786 static inline void nfsd4_try_run_cb(struct nfsd4_callback *cb)
f94ac2bc823ffb Jeff Layton 2025-02-20 787 {
f94ac2bc823ffb Jeff Layton 2025-02-20 @788 if (!test_and_set_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags))NFSD4_CALLBACK_RUNNING is BIT(0) so this actually tests BIT(1). It's a double shift bug. Which works out fine so long as it's done consistently and the BITs never go above 5.
f94ac2bc823ffb Jeff Layton 2025-02-20 789 WARN_ON_ONCE(!nfsd4_run_cb(cb)); f94ac2bc823ffb Jeff Layton 2025-02-20 790 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 27 lines · Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux nfsd-testing head: 312e8dc9f5f591a4927b4786a25840ef381c97d9 commit: f94ac2bc823ffbabc5c88c38e63a1e6635f8a6cd [35/53] nfsd: prevent callback tasks running concurrently config: x86_64-randconfig-161-20250306 (https://download.01.org/0day-ci/archive/20250307/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0If 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/nfsd/state.h:788nfsd4_try_run_cb()warn:test_and_set_bit()takes a bit numberfs/nfsd/nfs4state.c:3235nfs4_cb_getattr()warn:test_and_set_bit()takes a bit numberfs/nfsd/nfs4state.c:5428nfsd_break_one_deleg()warn:test_and_set_bit()takes a bit numberfs/nfsd/state.h:788nfsd4_try_run_cb()warn:test_and_set_bit()takes a bit numberfs/nfsd/nfs4callback.c:1315nfsd41_destroy_cb()warn:clear_bit()takes a bit numberfs/nfsd/nfs4layouts.c:347nfsd4_recall_file_layout()warn:test_and_set_bit()takes a bit numbervim +788
fs/nfsd/state.hf94ac2bc823ffb Jeff Layton 2025-02-20 786 static inline void nfsd4_try_run_cb(struct nfsd4_callback *cb) f94ac2bc823ffb Jeff Layton 2025-02-20 787 { f94ac2bc823ffb Jeff Layton 2025-02-20 @788 if (!test_and_set_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags))
Quoted 7 lines
NFSD4_CALLBACK_RUNNINGis BIT(0) so this actually tests BIT(1). It's a double shift bug. Which works out fine so long as it's done consistently and the BITs never go above 5.f94ac2bc823ffb Jeff Layton 2025-02-20 789 WARN_ON_ONCE(!nfsd4_run_cb(cb)); f94ac2bc823ffb Jeff Layton 2025-02-20 790 }
Thank you, Dan. Fixed in this patch and the two following, and pushed to nfsd-next / nfsd-testing.
Signature · 1 line
Chuck Lever