From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: Re: [PATCH] jfs: add dmapctl integrity check to prevent invalid operations
Date: Fri, 21 Nov 2025 18:03:54 +0800 [thread overview]
Message-ID: <202511211750.bjcw3Ucd-lkp@intel.com> (raw)
::::::
:::::: Manual check reason: "low confidence static check warning: fs/jfs/jfs_dmap.c:150:13: sparse: sparse: unsigned value that used to be signed checked against zero?"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251120154413.1043174-1-yun.zhou@windriver.com>
References: <20251120154413.1043174-1-yun.zhou@windriver.com>
TO: Yun Zhou <yun.zhou@windriver.com>
TO: shaggy@kernel.org
CC: rand.sec96@gmail.com
CC: contact@arnaud-lcm.com
CC: kovalev@altlinux.org
CC: zheng.yu@northwestern.edu
CC: eadavis@qq.com
CC: yun.zhou@windriver.com
CC: jfs-discussion@lists.sourceforge.net
CC: linux-kernel@vger.kernel.org
Hi Yun,
kernel test robot noticed the following build warnings:
[auto build test WARNING on kleikamp-shaggy/jfs-next]
[also build test WARNING on linus/master v6.18-rc6 next-20251121]
[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/Yun-Zhou/jfs-add-dmapctl-integrity-check-to-prevent-invalid-operations/20251121-001021
base: https://github.com/kleikamp/linux-shaggy jfs-next
patch link: https://lore.kernel.org/r/20251120154413.1043174-1-yun.zhou%40windriver.com
patch subject: [PATCH] jfs: add dmapctl integrity check to prevent invalid operations
:::::: branch date: 18 hours ago
:::::: commit date: 18 hours ago
config: nios2-randconfig-r123-20251121 (https://download.01.org/0day-ci/archive/20251121/202511211750.bjcw3Ucd-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251121/202511211750.bjcw3Ucd-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/r/202511211750.bjcw3Ucd-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> fs/jfs/jfs_dmap.c:150:13: sparse: sparse: unsigned value that used to be signed checked against zero?
fs/jfs/jfs_dmap.c:148:18: sparse: signed value source
fs/jfs/jfs_dmap.c:157:13: sparse: sparse: unsigned value that used to be signed checked against zero?
fs/jfs/jfs_dmap.c:156:20: sparse: signed value source
fs/jfs/jfs_dmap.c:180:13: sparse: sparse: unsigned value that used to be signed checked against zero?
fs/jfs/jfs_dmap.c:178:18: sparse: signed value source
vim +150 fs/jfs/jfs_dmap.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 135
a522d42d8bdabf Yun Zhou 2025-11-20 136 /*
a522d42d8bdabf Yun Zhou 2025-11-20 137 * check_dmapctl - Validate integrity of a dmapctl structure
a522d42d8bdabf Yun Zhou 2025-11-20 138 * @dcp: Pointer to the dmapctl structure to check
a522d42d8bdabf Yun Zhou 2025-11-20 139 *
a522d42d8bdabf Yun Zhou 2025-11-20 140 * Return: true if valid, false if corrupted
a522d42d8bdabf Yun Zhou 2025-11-20 141 */
a522d42d8bdabf Yun Zhou 2025-11-20 142 static bool check_dmapctl(struct dmapctl *dcp)
a522d42d8bdabf Yun Zhou 2025-11-20 143 {
a522d42d8bdabf Yun Zhou 2025-11-20 144 s8 budmin = dcp->budmin;
a522d42d8bdabf Yun Zhou 2025-11-20 145 u32 nleafs, l2nleafs, leafidx, height;
a522d42d8bdabf Yun Zhou 2025-11-20 146 int i;
a522d42d8bdabf Yun Zhou 2025-11-20 147
a522d42d8bdabf Yun Zhou 2025-11-20 148 nleafs = le32_to_cpu(dcp->nleafs);
a522d42d8bdabf Yun Zhou 2025-11-20 149 /* Check basic field ranges */
a522d42d8bdabf Yun Zhou 2025-11-20 @150 if (unlikely(nleafs > LPERCTL || nleafs < 0)) {
a522d42d8bdabf Yun Zhou 2025-11-20 151 jfs_err("dmapctl: invalid nleafs %u (max %u)",
a522d42d8bdabf Yun Zhou 2025-11-20 152 nleafs, LPERCTL);
a522d42d8bdabf Yun Zhou 2025-11-20 153 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 154 }
a522d42d8bdabf Yun Zhou 2025-11-20 155
a522d42d8bdabf Yun Zhou 2025-11-20 156 l2nleafs = le32_to_cpu(dcp->l2nleafs);
a522d42d8bdabf Yun Zhou 2025-11-20 157 if (unlikely(l2nleafs > L2LPERCTL || l2nleafs < 0)) {
a522d42d8bdabf Yun Zhou 2025-11-20 158 jfs_err("dmapctl: invalid l2nleafs %u (max %u)",
a522d42d8bdabf Yun Zhou 2025-11-20 159 l2nleafs, L2LPERCTL);
a522d42d8bdabf Yun Zhou 2025-11-20 160 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 161 }
a522d42d8bdabf Yun Zhou 2025-11-20 162
a522d42d8bdabf Yun Zhou 2025-11-20 163 /* Verify nleafs matches l2nleafs (must be power of two) */
a522d42d8bdabf Yun Zhou 2025-11-20 164 if (unlikely((1U << l2nleafs) != nleafs)) {
a522d42d8bdabf Yun Zhou 2025-11-20 165 jfs_err("dmapctl: nleafs %u != 2^%u",
a522d42d8bdabf Yun Zhou 2025-11-20 166 nleafs, l2nleafs);
a522d42d8bdabf Yun Zhou 2025-11-20 167 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 168 }
a522d42d8bdabf Yun Zhou 2025-11-20 169
a522d42d8bdabf Yun Zhou 2025-11-20 170 leafidx = le32_to_cpu(dcp->leafidx);
a522d42d8bdabf Yun Zhou 2025-11-20 171 /* Check leaf index matches expected position */
a522d42d8bdabf Yun Zhou 2025-11-20 172 if (unlikely(leafidx != CTLLEAFIND)) {
a522d42d8bdabf Yun Zhou 2025-11-20 173 jfs_err("dmapctl: invalid leafidx %u (expected %u)",
a522d42d8bdabf Yun Zhou 2025-11-20 174 leafidx, CTLLEAFIND);
a522d42d8bdabf Yun Zhou 2025-11-20 175 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 176 }
a522d42d8bdabf Yun Zhou 2025-11-20 177
a522d42d8bdabf Yun Zhou 2025-11-20 178 height = le32_to_cpu(dcp->height);
a522d42d8bdabf Yun Zhou 2025-11-20 179 /* Check tree height is within valid range */
a522d42d8bdabf Yun Zhou 2025-11-20 180 if (unlikely(height < 0 || height > (L2LPERCTL >> 1))) {
a522d42d8bdabf Yun Zhou 2025-11-20 181 jfs_err("dmapctl: invalid height %u (max %u)",
a522d42d8bdabf Yun Zhou 2025-11-20 182 height, L2LPERCTL >> 1);
a522d42d8bdabf Yun Zhou 2025-11-20 183 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 184 }
a522d42d8bdabf Yun Zhou 2025-11-20 185
a522d42d8bdabf Yun Zhou 2025-11-20 186 /* Check budmin is valid (cannot be NOFREE for non-empty tree) */
a522d42d8bdabf Yun Zhou 2025-11-20 187 if (budmin == NOFREE) {
a522d42d8bdabf Yun Zhou 2025-11-20 188 if (unlikely(nleafs > 0)) {
a522d42d8bdabf Yun Zhou 2025-11-20 189 jfs_err("dmapctl: budmin is NOFREE but nleafs %u",
a522d42d8bdabf Yun Zhou 2025-11-20 190 nleafs);
a522d42d8bdabf Yun Zhou 2025-11-20 191 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 192 }
a522d42d8bdabf Yun Zhou 2025-11-20 193 } else if (unlikely(budmin < BUDMIN)) {
a522d42d8bdabf Yun Zhou 2025-11-20 194 jfs_err("dmapctl: invalid budmin %d (min %d)",
a522d42d8bdabf Yun Zhou 2025-11-20 195 budmin, BUDMIN);
a522d42d8bdabf Yun Zhou 2025-11-20 196 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 197 }
a522d42d8bdabf Yun Zhou 2025-11-20 198
a522d42d8bdabf Yun Zhou 2025-11-20 199 /* Check leaf nodes fit within stree array */
a522d42d8bdabf Yun Zhou 2025-11-20 200 if (unlikely(leafidx + nleafs > CTLTREESIZE)) {
a522d42d8bdabf Yun Zhou 2025-11-20 201 jfs_err("dmapctl: leaf range exceeds stree size (end %u > %u)",
a522d42d8bdabf Yun Zhou 2025-11-20 202 leafidx + nleafs, CTLTREESIZE);
a522d42d8bdabf Yun Zhou 2025-11-20 203 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 204 }
a522d42d8bdabf Yun Zhou 2025-11-20 205
a522d42d8bdabf Yun Zhou 2025-11-20 206 /* Check leaf nodes have valid values */
a522d42d8bdabf Yun Zhou 2025-11-20 207 for (i = leafidx; i < leafidx + nleafs; i++) {
a522d42d8bdabf Yun Zhou 2025-11-20 208 s8 val = dcp->stree[i];
a522d42d8bdabf Yun Zhou 2025-11-20 209 if (unlikely(val < NOFREE)) {
a522d42d8bdabf Yun Zhou 2025-11-20 210 jfs_err("dmapctl: invalid leaf value %d at index %d",
a522d42d8bdabf Yun Zhou 2025-11-20 211 val, i);
a522d42d8bdabf Yun Zhou 2025-11-20 212 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 213 } else if (unlikely(val > 31)) {
a522d42d8bdabf Yun Zhou 2025-11-20 214 jfs_err("dmapctl: leaf value %d too large at index %d", val, i);
a522d42d8bdabf Yun Zhou 2025-11-20 215 return false;
a522d42d8bdabf Yun Zhou 2025-11-20 216 }
a522d42d8bdabf Yun Zhou 2025-11-20 217 }
a522d42d8bdabf Yun Zhou 2025-11-20 218
a522d42d8bdabf Yun Zhou 2025-11-20 219 return true;
a522d42d8bdabf Yun Zhou 2025-11-20 220 }
a522d42d8bdabf Yun Zhou 2025-11-20 221
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2025-11-21 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 10:03 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-20 15:44 [PATCH] jfs: add dmapctl integrity check to prevent invalid operations Yun Zhou
2025-11-24 11:42 ` Li Lingfeng
2025-11-28 0:31 ` Zhou, Yun
2025-11-28 1:17 ` Li Lingfeng
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=202511211750.bjcw3Ucd-lkp@intel.com \
--to=lkp@intel.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.