Re: [PATCH 10/18] Squashfs: sanity check directory metadata block location
From: kernel test robot
Date: Sat Nov 07 2026 - 20:37:13 EST
Hi Phillip,
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.4-rc1]
[cannot apply to akpm-mm/mm-everything next-20261105]
[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/Phillip-Lougher/Squashfs-convert-SQUASHFS_COMPRESSED_-to-inline-functions/20261107-052826
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20261107052843.725239-11-phillip%40squashfs.org.uk
patch subject: [PATCH 10/18] Squashfs: sanity check directory metadata block location
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20261108/202611080942.VKgPZf4A-lkp@xxxxxxxxx/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project fc9576e3b179738d99c5babe5cd9d6c1f883e0db)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261108/202611080942.VKgPZf4A-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611080942.VKgPZf4A-lkp@xxxxxxxxx/
All warnings (new ones prefixed by >>):
>> fs/squashfs/namei.c:141:6: warning: variable 'dire' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
141 | if (block < 0)
| ^~~~~~~~~
fs/squashfs/namei.c:231:8: note: uninitialized use occurs here
231 | kfree(dire);
| ^~~~
fs/squashfs/namei.c:141:2: note: remove the 'if' if its condition is always false
141 | if (block < 0)
| ^~~~~~~~~~~~~~
142 | goto data_error;
| ~~~~~~~~~~~~~~~
fs/squashfs/namei.c:133:33: note: initialize the variable 'dire' to silence this warning
133 | struct squashfs_dir_entry *dire;
| ^
| = NULL
1 warning generated.
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;
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