lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 22 Dec 2018 17:30:41 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Cc:     kbuild-all@...org, linux-f2fs-devel@...ts.sourceforge.net,
        yuchao0@...wei.com, jaegeuk@...nel.org,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Subject: Re: [PATCH 1/1] f2fs: fix validation of the block count in
 sanity_check_raw_super

Hi Martin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on f2fs/dev-test]
[also build test WARNING on v4.20-rc7 next-20181221]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Martin-Blumenstingl/f2fs-fix-sanity_check_raw_super-on-big-endian-machines/20181222-142616
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: i386-randconfig-a3-12211242 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   fs/f2fs/super.c: In function 'sanity_check_raw_super':
>> fs/f2fs/super.c:2499:4: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type '__le64' [-Wformat=]
       segment_count, le64_to_cpu(raw_super->block_count));
       ^

vim +2499 fs/f2fs/super.c

  2382	
  2383	static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
  2384					struct buffer_head *bh)
  2385	{
  2386		block_t segment_count, segs_per_sec, secs_per_zone;
  2387		block_t total_sections, blocks_per_seg;
  2388		struct f2fs_super_block *raw_super = (struct f2fs_super_block *)
  2389						(bh->b_data + F2FS_SUPER_OFFSET);
  2390		struct super_block *sb = sbi->sb;
  2391		unsigned int blocksize;
  2392		size_t crc_offset = 0;
  2393		__u32 crc = 0;
  2394	
  2395		/* Check checksum_offset and crc in superblock */
  2396		if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) {
  2397			crc_offset = le32_to_cpu(raw_super->checksum_offset);
  2398			if (crc_offset !=
  2399				offsetof(struct f2fs_super_block, crc)) {
  2400				f2fs_msg(sb, KERN_INFO,
  2401					"Invalid SB checksum offset: %zu",
  2402					crc_offset);
  2403				return 1;
  2404			}
  2405			crc = le32_to_cpu(raw_super->crc);
  2406			if (!f2fs_crc_valid(sbi, crc, raw_super, crc_offset)) {
  2407				f2fs_msg(sb, KERN_INFO,
  2408					"Invalid SB checksum value: %u", crc);
  2409				return 1;
  2410			}
  2411		}
  2412	
  2413		if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {
  2414			f2fs_msg(sb, KERN_INFO,
  2415				"Magic Mismatch, valid(0x%x) - read(0x%x)",
  2416				F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
  2417			return 1;
  2418		}
  2419	
  2420		/* Currently, support only 4KB page cache size */
  2421		if (F2FS_BLKSIZE != PAGE_SIZE) {
  2422			f2fs_msg(sb, KERN_INFO,
  2423				"Invalid page_cache_size (%lu), supports only 4KB\n",
  2424				PAGE_SIZE);
  2425			return 1;
  2426		}
  2427	
  2428		/* Currently, support only 4KB block size */
  2429		blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
  2430		if (blocksize != F2FS_BLKSIZE) {
  2431			f2fs_msg(sb, KERN_INFO,
  2432				"Invalid blocksize (%u), supports only 4KB\n",
  2433				blocksize);
  2434			return 1;
  2435		}
  2436	
  2437		/* check log blocks per segment */
  2438		if (le32_to_cpu(raw_super->log_blocks_per_seg) != 9) {
  2439			f2fs_msg(sb, KERN_INFO,
  2440				"Invalid log blocks per segment (%u)\n",
  2441				le32_to_cpu(raw_super->log_blocks_per_seg));
  2442			return 1;
  2443		}
  2444	
  2445		/* Currently, support 512/1024/2048/4096 bytes sector size */
  2446		if (le32_to_cpu(raw_super->log_sectorsize) >
  2447					F2FS_MAX_LOG_SECTOR_SIZE ||
  2448			le32_to_cpu(raw_super->log_sectorsize) <
  2449					F2FS_MIN_LOG_SECTOR_SIZE) {
  2450			f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize (%u)",
  2451				le32_to_cpu(raw_super->log_sectorsize));
  2452			return 1;
  2453		}
  2454		if (le32_to_cpu(raw_super->log_sectors_per_block) +
  2455			le32_to_cpu(raw_super->log_sectorsize) !=
  2456				F2FS_MAX_LOG_SECTOR_SIZE) {
  2457			f2fs_msg(sb, KERN_INFO,
  2458				"Invalid log sectors per block(%u) log sectorsize(%u)",
  2459				le32_to_cpu(raw_super->log_sectors_per_block),
  2460				le32_to_cpu(raw_super->log_sectorsize));
  2461			return 1;
  2462		}
  2463	
  2464		segment_count = le32_to_cpu(raw_super->segment_count);
  2465		segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
  2466		secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
  2467		total_sections = le32_to_cpu(raw_super->section_count);
  2468	
  2469		/* blocks_per_seg should be 512, given the above check */
  2470		blocks_per_seg = 1 << le32_to_cpu(raw_super->log_blocks_per_seg);
  2471	
  2472		if (segment_count > F2FS_MAX_SEGMENT ||
  2473					segment_count < F2FS_MIN_SEGMENTS) {
  2474			f2fs_msg(sb, KERN_INFO,
  2475				"Invalid segment count (%u)",
  2476				segment_count);
  2477			return 1;
  2478		}
  2479	
  2480		if (total_sections > segment_count ||
  2481				total_sections < F2FS_MIN_SEGMENTS ||
  2482				segs_per_sec > segment_count || !segs_per_sec) {
  2483			f2fs_msg(sb, KERN_INFO,
  2484				"Invalid segment/section count (%u, %u x %u)",
  2485				segment_count, total_sections, segs_per_sec);
  2486			return 1;
  2487		}
  2488	
  2489		if ((segment_count / segs_per_sec) < total_sections) {
  2490			f2fs_msg(sb, KERN_INFO,
  2491				"Small segment_count (%u < %u * %u)",
  2492				segment_count, segs_per_sec, total_sections);
  2493			return 1;
  2494		}
  2495	
  2496		if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) {
  2497			f2fs_msg(sb, KERN_INFO,
  2498				"Wrong segment_count / block_count (%u > %u)",
> 2499				segment_count, le64_to_cpu(raw_super->block_count));
  2500			return 1;
  2501		}
  2502	
  2503		if (secs_per_zone > total_sections || !secs_per_zone) {
  2504			f2fs_msg(sb, KERN_INFO,
  2505				"Wrong secs_per_zone / total_sections (%u, %u)",
  2506				secs_per_zone, total_sections);
  2507			return 1;
  2508		}
  2509		if (le32_to_cpu(raw_super->extension_count) > F2FS_MAX_EXTENSION ||
  2510				raw_super->hot_ext_count > F2FS_MAX_EXTENSION ||
  2511				(le32_to_cpu(raw_super->extension_count) +
  2512				raw_super->hot_ext_count) > F2FS_MAX_EXTENSION) {
  2513			f2fs_msg(sb, KERN_INFO,
  2514				"Corrupted extension count (%u + %u > %u)",
  2515				le32_to_cpu(raw_super->extension_count),
  2516				raw_super->hot_ext_count,
  2517				F2FS_MAX_EXTENSION);
  2518			return 1;
  2519		}
  2520	
  2521		if (le32_to_cpu(raw_super->cp_payload) >
  2522					(blocks_per_seg - F2FS_CP_PACKS)) {
  2523			f2fs_msg(sb, KERN_INFO,
  2524				"Insane cp_payload (%u > %u)",
  2525				le32_to_cpu(raw_super->cp_payload),
  2526				blocks_per_seg - F2FS_CP_PACKS);
  2527			return 1;
  2528		}
  2529	
  2530		/* check reserved ino info */
  2531		if (le32_to_cpu(raw_super->node_ino) != 1 ||
  2532			le32_to_cpu(raw_super->meta_ino) != 2 ||
  2533			le32_to_cpu(raw_super->root_ino) != 3) {
  2534			f2fs_msg(sb, KERN_INFO,
  2535				"Invalid Fs Meta Ino: node(%u) meta(%u) root(%u)",
  2536				le32_to_cpu(raw_super->node_ino),
  2537				le32_to_cpu(raw_super->meta_ino),
  2538				le32_to_cpu(raw_super->root_ino));
  2539			return 1;
  2540		}
  2541	
  2542		/* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */
  2543		if (sanity_check_area_boundary(sbi, bh))
  2544			return 1;
  2545	
  2546		return 0;
  2547	}
  2548	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (30537 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ