Re: [PATCH v3 8/8] initramfs_test: add filename padding test case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi David,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brauner-vfs/vfs.all]
[also build test WARNING on linus/master v6.17-rc2 next-20250819]
[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/David-Disseldorp/gen_init_cpio-write-to-fd-instead-of-stdout-stream/20250819-115406
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:    https://lore.kernel.org/r/20250819032607.28727-9-ddiss%40suse.de
patch subject: [PATCH v3 8/8] initramfs_test: add filename padding test case
config: sparc64-randconfig-r121-20250819 (https://download.01.org/0day-ci/archive/20250820/202508200304.wF1u78il-lkp@xxxxxxxxx/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f)
reproduce: (https://download.01.org/0day-ci/archive/20250820/202508200304.wF1u78il-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/202508200304.wF1u78il-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> init/initramfs_test.c:415:18: sparse: sparse: Initializer entry defined twice
   init/initramfs_test.c:425:18: sparse:   also defined here

vim +415 init/initramfs_test.c

   388	
   389	/*
   390	 * An initramfs filename is namesize in length, including the zero-terminator.
   391	 * A filename can be zero-terminated prior to namesize, with the remainder used
   392	 * as padding. This can be useful for e.g. alignment of file data segments with
   393	 * a 4KB filesystem block, allowing for extent sharing (reflinks) between cpio
   394	 * source and destination. This hack works with both GNU cpio and initramfs, as
   395	 * long as PATH_MAX isn't exceeded.
   396	 */
   397	static void __init initramfs_test_fname_pad(struct kunit *test)
   398	{
   399		char *err;
   400		size_t len;
   401		struct file *file;
   402		char fdata[] = "this file data is aligned at 4K in the archive";
   403		struct test_fname_pad {
   404			char padded_fname[4096 - CPIO_HDRLEN];
   405			char cpio_srcbuf[CPIO_HDRLEN + PATH_MAX + 3 + sizeof(fdata)];
   406		} *tbufs = kzalloc(sizeof(struct test_fname_pad), GFP_KERNEL);
   407		struct initramfs_test_cpio c[] = { {
   408			.magic = "070701",
   409			.ino = 1,
   410			.mode = S_IFREG | 0777,
   411			.uid = 0,
   412			.gid = 0,
   413			.nlink = 1,
   414			.mtime = 1,
 > 415			.filesize = 0,
   416			.devmajor = 0,
   417			.devminor = 1,
   418			.rdevmajor = 0,
   419			.rdevminor = 0,
   420			/* align file data at 4K archive offset via padded fname */
   421			.namesize = 4096 - CPIO_HDRLEN,
   422			.csum = 0,
   423			.fname = tbufs->padded_fname,
   424			.data = fdata,
   425			.filesize = sizeof(fdata),
   426		} };
   427	
   428		memcpy(tbufs->padded_fname, "padded_fname", sizeof("padded_fname"));
   429		len = fill_cpio(c, ARRAY_SIZE(c), tbufs->cpio_srcbuf);
   430	
   431		err = unpack_to_rootfs(tbufs->cpio_srcbuf, len);
   432		KUNIT_EXPECT_NULL(test, err);
   433	
   434		file = filp_open(c[0].fname, O_RDONLY, 0);
   435		if (IS_ERR(file)) {
   436			KUNIT_FAIL(test, "open failed");
   437			goto out;
   438		}
   439	
   440		/* read back file contents into @cpio_srcbuf and confirm match */
   441		len = kernel_read(file, tbufs->cpio_srcbuf, c[0].filesize, NULL);
   442		KUNIT_EXPECT_EQ(test, len, c[0].filesize);
   443		KUNIT_EXPECT_MEMEQ(test, tbufs->cpio_srcbuf, c[0].data, len);
   444	
   445		fput(file);
   446		KUNIT_EXPECT_EQ(test, init_unlink(c[0].fname), 0);
   447	out:
   448		kfree(tbufs);
   449	}
   450	

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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux