* [akpm-mm:mm-nonmm-unstable 130/151] fs/squashfs/namei.c:141:21: sparse: sparse: unsigned value that used to be signed checked against zero?
@ 2026-11-13 15:20 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-11-13 15:20 UTC (permalink / raw)
To: Phillip Lougher
Cc: oe-kbuild-all, David Hildenbrand, Andrew Morton,
Linux Memory Management List, mm-commits
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
head: 152f0559e66c079f717de375f133ff127afb1f58
commit: 4dddf794b08bef04e5634dd4b52775a160d2cb6c [130/151] Squashfs: sanity check directory metadata block location
config: sh-randconfig-r2307-20261113 (https://download.01.org/0day-ci/archive/20261113/202611131605.L4Uvbf8p-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 16.2.0
sparse: v0.6.5-rc1-21-g84ec0658
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261113/202611131605.L4Uvbf8p-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/202611131605.L4Uvbf8p-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> fs/squashfs/namei.c:141:21: sparse: sparse: unsigned value that used to be signed checked against zero?
fs/squashfs/namei.c: note: in included file:
fs/squashfs/squashfs_helpers.h:79:24: sparse: signed value source
vim +141 fs/squashfs/namei.c
123
124
125 static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
126 unsigned int flags)
127 {
128 const unsigned char *name = dentry->d_name.name;
129 int len = dentry->d_name.len;
130 struct inode *inode = NULL;
131 struct squashfs_sb_info *msblk = dir->i_sb->s_fs_info;
132 struct squashfs_dir_header dirh;
133 struct squashfs_dir_entry *dire = NULL;
134 u64 block = squashfs_dir_start(squashfs_i(dir)->start, msblk);
135 int offset = squashfs_i(dir)->offset;
136 int err, length;
137 unsigned int dir_count, size;
138
139 TRACE("Entered squashfs_lookup [%llx:%x]\n", squashfs_i(dir)->start, offset);
140
> 141 if (block < 0)
142 goto data_error;
143
144 dire = kmalloc(sizeof(*dire) + SQUASHFS_NAME_LEN + 1, GFP_KERNEL);
145 if (dire == NULL) {
146 ERROR("Failed to allocate squashfs_dir_entry\n");
147 return ERR_PTR(-ENOMEM);
148 }
149
150 if (len > SQUASHFS_NAME_LEN) {
151 err = -ENAMETOOLONG;
152 goto failed;
153 }
154
155 length = get_dir_index_using_name(dir->i_sb, &block, &offset,
156 squashfs_i(dir)->dir_idx_start,
157 squashfs_i(dir)->dir_idx_offset,
158 squashfs_i(dir)->dir_idx_cnt, name);
159
160 while (length < i_size_read(dir)) {
161 /*
162 * Read directory header.
163 */
164 err = squashfs_read_metadata(dir->i_sb, &dirh, &block,
165 &offset, sizeof(dirh));
166 if (err < 0)
167 goto read_failure;
168
169 length += sizeof(dirh);
170
171 dir_count = le32_to_cpu(dirh.count) + 1;
172
173 if (dir_count > SQUASHFS_DIR_COUNT)
174 goto data_error;
175
176 while (dir_count--) {
177 /*
178 * Read directory entry.
179 */
180 err = squashfs_read_metadata(dir->i_sb, dire, &block,
181 &offset, sizeof(*dire));
182 if (err < 0)
183 goto read_failure;
184
185 size = le16_to_cpu(dire->size) + 1;
186
187 /* size should never be larger than SQUASHFS_NAME_LEN */
188 if (size > SQUASHFS_NAME_LEN)
189 goto data_error;
190
191 err = squashfs_read_metadata(dir->i_sb, dire->name,
192 &block, &offset, size);
193 if (err < 0)
194 goto read_failure;
195
196 length += sizeof(*dire) + size;
197
198 if (name[0] < dire->name[0])
199 goto exit_lookup;
200
201 if (len == size && !strncmp(name, dire->name, len)) {
202 unsigned int blk, off, ino_num;
203 long long ino;
204 blk = le32_to_cpu(dirh.start_block);
205 off = le16_to_cpu(dire->offset);
206 ino_num = le32_to_cpu(dirh.inode_number) +
207 (short) le16_to_cpu(dire->inode_number);
208 ino = squashfs_mkinode(blk, off);
209
210 TRACE("calling squashfs_iget for directory "
211 "entry %s, inode %x:%x, %d\n", name,
212 blk, off, ino_num);
213
214 inode = squashfs_iget(dir->i_sb, ino, ino_num);
215 goto exit_lookup;
216 }
217 }
218 }
219
220 exit_lookup:
221 kfree(dire);
222 return d_splice_alias(inode, dentry);
223
224 data_error:
225 err = -EIO;
226
227 read_failure:
228 ERROR("Unable to read directory block [%llx:%x]\n",
229 squashfs_i(dir)->start, squashfs_i(dir)->offset);
230 failed:
231 kfree(dire);
232 return ERR_PTR(err);
233 }
234
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-13 15:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 15:20 [akpm-mm:mm-nonmm-unstable 130/151] fs/squashfs/namei.c:141:21: sparse: sparse: unsigned value that used to be signed checked against zero? kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox