Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'kbuild-6.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux

Pull Kbuild updates from Nathan Chancellor:

- Extend modules.builtin.modinfo to include module aliases from
MODULE_DEVICE_TABLE for builtin modules so that userspace tools (such
as kmod) can verify that a particular module alias will be handled by
a builtin module

- Bump the minimum version of LLVM for building the kernel to 15.0.0

- Upgrade several userspace API checks in headers_check.pl to errors

- Unify and consolidate CONFIG_WERROR / W=e handling

- Turn assembler and linker warnings into errors with CONFIG_WERROR /
W=e

- Respect CONFIG_WERROR / W=e when building userspace programs
(userprogs)

- Enable -Werror unconditionally when building host programs
(hostprogs)

- Support copy_file_range() and data segment alignment in gen_init_cpio
to improve performance on filesystems that support reflinks such as
btrfs and XFS

- Miscellaneous small changes to scripts and configuration files

* tag 'kbuild-6.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux: (47 commits)
modpost: Initialize builtin_modname to stop SIGSEGVs
Documentation: kbuild: note CONFIG_DEBUG_EFI in reproducible builds
kbuild: vmlinux.unstripped should always depend on .vmlinux.export.o
modpost: Create modalias for builtin modules
modpost: Add modname to mod_device_table alias
scsi: Always define blogic_pci_tbl structure
kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
kbuild: keep .modinfo section in vmlinux.unstripped
kbuild: always create intermediate vmlinux.unstripped
s390: vmlinux.lds.S: Reorder sections
KMSAN: Remove tautological checks
objtool: Drop noinstr hack for KCSAN_WEAK_MEMORY
lib/Kconfig.debug: Drop CLANG_VERSION check from DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
riscv: Remove ld.lld version checks from many TOOLCHAIN_HAS configs
riscv: Unconditionally use linker relaxation
riscv: Remove version check for LTO_CLANG selects
powerpc: Drop unnecessary initializations in __copy_inst_from_kernel_nofault()
mips: Unconditionally select ARCH_HAS_CURRENT_STACK_POINTER
arm64: Remove tautological LLVM Kconfig conditions
ARM: Clean up definition of ARM_HAS_GROUP_RELOCS
...

+433 -260
+1 -1
.gitignore
··· 176 176 *.kdev4 177 177 178 178 # Clang's compilation database file 179 - /compile_commands.json 179 + compile_commands.json 180 180 181 181 # Documentation toolchain 182 182 sphinx_*/
+5
Documentation/driver-api/early-userspace/buffer-format.rst
··· 86 86 The c_filesize should be zero for any file which is not a regular file 87 87 or symlink. 88 88 89 + c_namesize may account for more than one trailing '\0', as long as the 90 + value doesn't exceed PATH_MAX. This can be useful for ensuring that a 91 + subsequent file data segment is aligned, e.g. to a filesystem block 92 + boundary. 93 + 89 94 The c_chksum field contains a simple 32-bit unsigned sum of all the 90 95 bytes in the data field. cpio(1) refers to this as "crc", which is 91 96 clearly incorrect (a cyclic redundancy check is a different and
+3
Documentation/kbuild/reproducible-builds.rst
··· 61 61 The Reproducible Builds web site has more information about these 62 62 `prefix-map options`_. 63 63 64 + Some CONFIG options such as `CONFIG_DEBUG_EFI` embed absolute paths in 65 + object files. Such options should be disabled. 66 + 64 67 Generated files in source packages 65 68 ---------------------------------- 66 69
+1 -1
Documentation/process/changes.rst
··· 30 30 Program Minimal version Command to check the version 31 31 ====================== =============== ======================================== 32 32 GNU C 8.1 gcc --version 33 - Clang/LLVM (optional) 13.0.1 clang --version 33 + Clang/LLVM (optional) 15.0.0 clang --version 34 34 Rust (optional) 1.78.0 rustc --version 35 35 bindgen (optional) 0.65.1 bindgen --version 36 36 GNU make 4.0 make --version
+3 -5
Makefile
··· 901 901 902 902 KBUILD_CFLAGS += $(stackp-flags-y) 903 903 904 - KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings 905 - KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) 906 - 907 904 ifdef CONFIG_FRAME_POINTER 908 905 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 909 906 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y ··· 1135 1138 endif 1136 1139 1137 1140 # Align the bit size of userspace programs with the kernel 1138 - KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) 1139 - KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) 1141 + USERFLAGS_FROM_KERNEL := -m32 -m64 --target=% 1142 + KBUILD_USERCFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) 1143 + KBUILD_USERLDFLAGS += $(filter $(USERFLAGS_FROM_KERNEL), $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) 1140 1144 1141 1145 # userspace programs are linked via the compiler, use the correct linker 1142 1146 ifdef CONFIG_CC_IS_CLANG
-1
arch/Kconfig
··· 1523 1523 bool "Support for randomizing kernel stack offset on syscall entry" if EXPERT 1524 1524 default y 1525 1525 depends on HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET 1526 - depends on INIT_STACK_NONE || !CC_IS_CLANG || CLANG_VERSION >= 140000 1527 1526 help 1528 1527 The kernel stack offset can be randomized (after pt_regs) by 1529 1528 roughly 5 bits of entropy, frustrating memory corruption
+4 -7
arch/arm/Kconfig
··· 166 166 <http://www.arm.linux.org.uk/>. 167 167 168 168 config ARM_HAS_GROUP_RELOCS 169 - def_bool y 170 - depends on !LD_IS_LLD || LLD_VERSION >= 140000 171 - depends on !COMPILE_TEST 169 + def_bool !COMPILE_TEST 172 170 help 173 171 Whether or not to use R_ARM_ALU_PC_Gn or R_ARM_LDR_PC_Gn group 174 - relocations, which have been around for a long time, but were not 175 - supported in LLD until version 14. The combined range is -/+ 256 MiB, 176 - which is usually sufficient, but not for allyesconfig, so we disable 177 - this feature when doing compile testing. 172 + relocations. The combined range is -/+ 256 MiB, which is usually 173 + sufficient, but not for allyesconfig, so we disable this feature 174 + when doing compile testing. 178 175 179 176 config ARM_DMA_USE_IOMMU 180 177 bool
+2 -4
arch/arm64/Kconfig
··· 1495 1495 1496 1496 config CPU_BIG_ENDIAN 1497 1497 bool "Build big-endian kernel" 1498 - # https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c 1499 - depends on (AS_IS_GNU || AS_VERSION >= 150000) && BROKEN 1498 + depends on BROKEN 1500 1499 help 1501 1500 Say Y if you plan on running a kernel with a big-endian userspace. 1502 1501 ··· 2326 2327 2327 2328 config UNWIND_PATCH_PAC_INTO_SCS 2328 2329 bool "Enable shadow call stack dynamically using code patching" 2329 - # needs Clang with https://github.com/llvm/llvm-project/commit/de07cde67b5d205d58690be012106022aea6d2b3 incorporated 2330 - depends on CC_IS_CLANG && CLANG_VERSION >= 150000 2330 + depends on CC_IS_CLANG 2331 2331 depends on ARM64_PTR_AUTH_KERNEL && CC_HAS_BRANCH_PROT_PAC_RET 2332 2332 depends on SHADOW_CALL_STACK 2333 2333 select UNWIND_TABLES
+1 -1
arch/mips/Kconfig
··· 6 6 select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT 7 7 select ARCH_HAS_CPU_CACHE_ALIASING 8 8 select ARCH_HAS_CPU_FINALIZE_INIT 9 - select ARCH_HAS_CURRENT_STACK_POINTER if !CC_IS_CLANG || CLANG_VERSION >= 140000 9 + select ARCH_HAS_CURRENT_STACK_POINTER 10 10 select ARCH_HAS_DEBUG_VIRTUAL if !64BIT 11 11 select ARCH_HAS_DMA_OPS if MACH_JAZZ 12 12 select ARCH_HAS_FORTIFY_SOURCE
-4
arch/powerpc/include/asm/inst.h
··· 143 143 { 144 144 unsigned int val, suffix; 145 145 146 - /* See https://github.com/ClangBuiltLinux/linux/issues/1521 */ 147 - #if defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 140000 148 - val = suffix = 0; 149 - #endif 150 146 __get_kernel_nofault(&val, src, u32, Efault); 151 147 if (IS_ENABLED(CONFIG_PPC64) && get_op(val) == OP_PREFIX) { 152 148 __get_kernel_nofault(&suffix, src + 1, u32, Efault);
+7 -14
arch/riscv/Kconfig
··· 66 66 select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU 67 67 select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE 68 68 select ARCH_SUPPORTS_HUGETLBFS if MMU 69 - # LLD >= 14: https://github.com/llvm/llvm-project/issues/50505 70 - select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000 && CMODEL_MEDANY 71 - select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000 69 + select ARCH_SUPPORTS_LTO_CLANG if CMODEL_MEDANY 70 + select ARCH_SUPPORTS_LTO_CLANG_THIN 72 71 select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU 73 72 select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU 74 73 select ARCH_SUPPORTS_PER_VMA_LOCK if MMU ··· 248 249 # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769 249 250 depends on $(ld-option,--no-relax-gp) 250 251 251 - config RISCV_USE_LINKER_RELAXATION 252 - def_bool y 253 - # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985 254 - depends on !LD_IS_LLD || LLD_VERSION >= 150000 255 - 256 252 # https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 257 253 config ARCH_HAS_BROKEN_DWARF5 258 254 def_bool y 259 - depends on RISCV_USE_LINKER_RELAXATION 260 255 # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a 261 256 depends on AS_IS_LLVM && AS_VERSION < 180000 262 257 # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 ··· 614 621 default y 615 622 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64imv) 616 623 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32imv) 617 - depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 624 + depends on LD_IS_LLD || LD_VERSION >= 23800 618 625 depends on AS_HAS_OPTION_ARCH 619 626 620 627 config RISCV_ISA_V ··· 714 721 default y 715 722 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb) 716 723 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb) 717 - depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 724 + depends on LD_IS_LLD || LD_VERSION >= 23900 718 725 depends on AS_HAS_OPTION_ARCH 719 726 720 727 # This symbol indicates that the toolchain supports all v1.0 vector crypto ··· 729 736 default y 730 737 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba) 731 738 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba) 732 - depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 739 + depends on LD_IS_LLD || LD_VERSION >= 23900 733 740 depends on AS_HAS_OPTION_ARCH 734 741 735 742 config RISCV_ISA_ZBA ··· 764 771 default y 765 772 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbc) 766 773 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbc) 767 - depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 774 + depends on LD_IS_LLD || LD_VERSION >= 23900 768 775 depends on AS_HAS_OPTION_ARCH 769 776 770 777 config RISCV_ISA_ZBC ··· 787 794 default y 788 795 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbkb) 789 796 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbkb) 790 - depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 797 + depends on LD_IS_LLD || LD_VERSION >= 23900 791 798 depends on AS_HAS_OPTION_ARCH 792 799 793 800 config RISCV_ISA_ZBKB
+1 -8
arch/riscv/Makefile
··· 46 46 KBUILD_LDFLAGS += -melf32lriscv 47 47 endif 48 48 49 - ifndef CONFIG_RISCV_USE_LINKER_RELAXATION 50 - KBUILD_CFLAGS += -mno-relax 51 - KBUILD_AFLAGS += -mno-relax 52 - ifndef CONFIG_AS_IS_LLVM 53 - KBUILD_CFLAGS += -Wa,-mno-relax 54 - KBUILD_AFLAGS += -Wa,-mno-relax 55 - endif 56 49 # LLVM has an issue with target-features and LTO: https://github.com/llvm/llvm-project/issues/59350 57 50 # Ensure it is aware of linker relaxation with LTO, otherwise relocations may 58 51 # be incorrect: https://github.com/llvm/llvm-project/issues/65090 59 - else ifeq ($(CONFIG_LTO_CLANG),y) 52 + ifeq ($(CONFIG_LTO_CLANG),y) 60 53 KBUILD_LDFLAGS += -mllvm -mattr=+c -mllvm -mattr=+relax 61 54 endif 62 55
+5 -5
arch/s390/kernel/vmlinux.lds.S
··· 209 209 . = ALIGN(PAGE_SIZE); 210 210 _end = . ; 211 211 212 + /* Debugging sections. */ 213 + STABS_DEBUG 214 + DWARF_DEBUG 215 + ELF_DETAILS 216 + 212 217 /* 213 218 * uncompressed image info used by the decompressor 214 219 * it should match struct vmlinux_info ··· 243 238 QUAD(kasan_early_shadow_p4d) 244 239 #endif 245 240 } :NONE 246 - 247 - /* Debugging sections. */ 248 - STABS_DEBUG 249 - DWARF_DEBUG 250 - ELF_DETAILS 251 241 252 242 /* 253 243 * Make sure that the .got.plt is either completely empty or it
+1 -3
drivers/scsi/BusLogic.c
··· 3715 3715 3716 3716 __setup("BusLogic=", blogic_setup); 3717 3717 3718 - #ifdef MODULE 3719 3718 /*static const struct pci_device_id blogic_pci_tbl[] = { 3720 3719 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, 3721 3720 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, ··· 3724 3725 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 3725 3726 { } 3726 3727 };*/ 3727 - static const struct pci_device_id blogic_pci_tbl[] = { 3728 + static const struct pci_device_id blogic_pci_tbl[] __maybe_unused = { 3728 3729 {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER)}, 3729 3730 {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC)}, 3730 3731 {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)}, 3731 3732 {0, }, 3732 3733 }; 3733 - #endif 3734 3734 MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); 3735 3735 3736 3736 module_init(blogic_init);
+1 -1
include/asm-generic/vmlinux.lds.h
··· 832 832 833 833 /* Required sections not related to debugging. */ 834 834 #define ELF_DETAILS \ 835 + .modinfo : { *(.modinfo) } \ 835 836 .comment 0 : { *(.comment) } \ 836 837 .symtab 0 : { *(.symtab) } \ 837 838 .strtab 0 : { *(.strtab) } \ ··· 1046 1045 *(.discard.*) \ 1047 1046 *(.export_symbol) \ 1048 1047 *(.no_trim_symbol) \ 1049 - *(.modinfo) \ 1050 1048 /* ld.bfd warns about .gnu.version* even when not emitted */ \ 1051 1049 *(.gnu.version*) \ 1052 1050
+13 -5
include/linux/module.h
··· 244 244 /* What your module does. */ 245 245 #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) 246 246 247 - #ifdef MODULE 247 + /* 248 + * Format: __mod_device_table__kmod_<modname>__<type>__<name> 249 + * Parts of the string `__kmod_` and `__` are used as delimiters when parsing 250 + * a symbol in file2alias.c 251 + */ 252 + #define __mod_device_table(type, name) \ 253 + __PASTE(__mod_device_table__, \ 254 + __PASTE(__KBUILD_MODNAME, \ 255 + __PASTE(__, \ 256 + __PASTE(type, \ 257 + __PASTE(__, name))))) 258 + 248 259 /* Creates an alias so file2alias.c can find device table. */ 249 260 #define MODULE_DEVICE_TABLE(type, name) \ 250 - static typeof(name) __mod_device_table__##type##__##name \ 261 + static typeof(name) __mod_device_table(type, name) \ 251 262 __attribute__ ((used, alias(__stringify(name)))) 252 - #else /* !MODULE */ 253 - #define MODULE_DEVICE_TABLE(type, name) 254 - #endif 255 263 256 264 /* Version of form [<epoch>:]<version>[-<extra-version>]. 257 265 * Or for CVS/RCS ID version, everything but the number is stripped.
+66 -1
init/initramfs_test.c
··· 45 45 c->mtime, c->filesize, c->devmajor, c->devminor, 46 46 c->rdevmajor, c->rdevminor, c->namesize, c->csum, 47 47 c->fname) + 1; 48 + 48 49 pr_debug("packing (%zu): %.*s\n", thislen, (int)thislen, pos); 49 - off += thislen; 50 + if (thislen != CPIO_HDRLEN + c->namesize) 51 + pr_debug("padded to: %u\n", CPIO_HDRLEN + c->namesize); 52 + off += CPIO_HDRLEN + c->namesize; 50 53 while (off & 3) 51 54 out[off++] = '\0'; 52 55 ··· 387 384 } 388 385 389 386 /* 387 + * An initramfs filename is namesize in length, including the zero-terminator. 388 + * A filename can be zero-terminated prior to namesize, with the remainder used 389 + * as padding. This can be useful for e.g. alignment of file data segments with 390 + * a 4KB filesystem block, allowing for extent sharing (reflinks) between cpio 391 + * source and destination. This hack works with both GNU cpio and initramfs, as 392 + * long as PATH_MAX isn't exceeded. 393 + */ 394 + static void __init initramfs_test_fname_pad(struct kunit *test) 395 + { 396 + char *err; 397 + size_t len; 398 + struct file *file; 399 + char fdata[] = "this file data is aligned at 4K in the archive"; 400 + struct test_fname_pad { 401 + char padded_fname[4096 - CPIO_HDRLEN]; 402 + char cpio_srcbuf[CPIO_HDRLEN + PATH_MAX + 3 + sizeof(fdata)]; 403 + } *tbufs = kzalloc(sizeof(struct test_fname_pad), GFP_KERNEL); 404 + struct initramfs_test_cpio c[] = { { 405 + .magic = "070701", 406 + .ino = 1, 407 + .mode = S_IFREG | 0777, 408 + .uid = 0, 409 + .gid = 0, 410 + .nlink = 1, 411 + .mtime = 1, 412 + .filesize = sizeof(fdata), 413 + .devmajor = 0, 414 + .devminor = 1, 415 + .rdevmajor = 0, 416 + .rdevminor = 0, 417 + /* align file data at 4K archive offset via padded fname */ 418 + .namesize = 4096 - CPIO_HDRLEN, 419 + .csum = 0, 420 + .fname = tbufs->padded_fname, 421 + .data = fdata, 422 + } }; 423 + 424 + memcpy(tbufs->padded_fname, "padded_fname", sizeof("padded_fname")); 425 + len = fill_cpio(c, ARRAY_SIZE(c), tbufs->cpio_srcbuf); 426 + 427 + err = unpack_to_rootfs(tbufs->cpio_srcbuf, len); 428 + KUNIT_EXPECT_NULL(test, err); 429 + 430 + file = filp_open(c[0].fname, O_RDONLY, 0); 431 + if (IS_ERR(file)) { 432 + KUNIT_FAIL(test, "open failed"); 433 + goto out; 434 + } 435 + 436 + /* read back file contents into @cpio_srcbuf and confirm match */ 437 + len = kernel_read(file, tbufs->cpio_srcbuf, c[0].filesize, NULL); 438 + KUNIT_EXPECT_EQ(test, len, c[0].filesize); 439 + KUNIT_EXPECT_MEMEQ(test, tbufs->cpio_srcbuf, c[0].data, len); 440 + 441 + fput(file); 442 + KUNIT_EXPECT_EQ(test, init_unlink(c[0].fname), 0); 443 + out: 444 + kfree(tbufs); 445 + } 446 + 447 + /* 390 448 * The kunit_case/_suite struct cannot be marked as __initdata as this will be 391 449 * used in debugfs to retrieve results after test has run. 392 450 */ ··· 458 394 KUNIT_CASE(initramfs_test_csum), 459 395 KUNIT_CASE(initramfs_test_hardlink), 460 396 KUNIT_CASE(initramfs_test_many), 397 + KUNIT_CASE(initramfs_test_fname_pad), 461 398 {}, 462 399 }; 463 400
+1 -1
lib/Kconfig.debug
··· 259 259 config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT 260 260 bool "Rely on the toolchain's implicit default DWARF version" 261 261 select DEBUG_INFO 262 - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128) 262 + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128) 263 263 help 264 264 The implicit default version of DWARF debug info produced by a 265 265 toolchain changes over time.
-6
lib/Kconfig.kcsan
··· 185 185 bool "Enable weak memory modeling to detect missing memory barriers" 186 186 default y 187 187 depends on KCSAN_STRICT 188 - # We can either let objtool nop __tsan_func_{entry,exit}() and builtin 189 - # atomics instrumentation in .noinstr.text, or use a compiler that can 190 - # implement __no_kcsan to really remove all instrumentation. 191 - depends on !ARCH_WANTS_NO_INSTR || HAVE_NOINSTR_HACK || \ 192 - CC_IS_GCC || CLANG_VERSION >= 140000 193 - select OBJTOOL if HAVE_NOINSTR_HACK 194 188 help 195 189 Enable support for modeling a subset of weak memory, which allows 196 190 detecting a subset of data races due to missing memory barriers.
+1 -10
lib/Kconfig.kmsan
··· 3 3 bool 4 4 5 5 config HAVE_KMSAN_COMPILER 6 - # Clang versions <14.0.0 also support -fsanitize=kernel-memory, but not 7 - # all the features necessary to build the kernel with KMSAN. 8 - depends on CC_IS_CLANG && CLANG_VERSION >= 140000 9 - def_bool $(cc-option,-fsanitize=kernel-memory -mllvm -msan-disable-checks=1) 6 + def_bool CC_IS_CLANG 10 7 11 8 config KMSAN 12 9 bool "KMSAN: detector of uninitialized values use" ··· 25 28 26 29 if KMSAN 27 30 28 - config HAVE_KMSAN_PARAM_RETVAL 29 - # -fsanitize-memory-param-retval is supported only by Clang >= 14. 30 - depends on HAVE_KMSAN_COMPILER 31 - def_bool $(cc-option,-fsanitize=kernel-memory -fsanitize-memory-param-retval) 32 - 33 31 config KMSAN_CHECK_PARAM_RETVAL 34 32 bool "Check for uninitialized values passed to and returned from functions" 35 33 default y 36 - depends on HAVE_KMSAN_PARAM_RETVAL 37 34 help 38 35 If the compiler supports -fsanitize-memory-param-retval, KMSAN will 39 36 eagerly check every function parameter passed by value and every
+4 -4
rust/kernel/device_id.rs
··· 195 195 ($table_type: literal, $module_table_name:ident, $table_name:ident) => { 196 196 #[rustfmt::skip] 197 197 #[export_name = 198 - concat!("__mod_device_table__", $table_type, 199 - "__", module_path!(), 200 - "_", line!(), 201 - "_", stringify!($table_name)) 198 + concat!("__mod_device_table__", line!(), 199 + "__kmod_", module_path!(), 200 + "__", $table_type, 201 + "__", stringify!($table_name)) 202 202 ] 203 203 static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] = 204 204 unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };
+13 -5
scripts/Makefile.extrawarn
··· 25 25 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) 26 26 endif 27 27 28 - KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror 29 - KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) 30 28 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds 31 29 32 30 ifdef CONFIG_CC_IS_CLANG ··· 212 214 endif 213 215 214 216 # 215 - # W=e - error out on warnings 217 + # W=e and CONFIG_WERROR - error out on warnings 216 218 # 217 - ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),) 219 + ifneq ($(findstring e, $(KBUILD_EXTRA_WARN))$(CONFIG_WERROR),) 218 220 219 - KBUILD_CFLAGS += -Werror 221 + KBUILD_CPPFLAGS += -Werror 222 + KBUILD_AFLAGS += -Wa,--fatal-warnings 223 + KBUILD_LDFLAGS += --fatal-warnings 224 + KBUILD_USERCFLAGS += -Werror 225 + KBUILD_USERLDFLAGS += -Wl,--fatal-warnings 226 + KBUILD_RUSTFLAGS += -Dwarnings 220 227 221 228 endif 229 + 230 + # Hostprog flags are used during build bootstrapping and can not rely on CONFIG_ symbols. 231 + KBUILD_HOSTCFLAGS += -Werror 232 + KBUILD_HOSTLDFLAGS += -Wl,--fatal-warnings 233 + KBUILD_HOSTRUSTFLAGS += -Dwarnings
+52 -27
scripts/Makefile.vmlinux
··· 9 9 10 10 targets := 11 11 12 - ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS 13 - vmlinux-final := vmlinux.unstripped 14 - 15 - quiet_cmd_strip_relocs = RSTRIP $@ 16 - cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' --remove-section=!'.rel*.dyn' $< $@ 17 - 18 - vmlinux: $(vmlinux-final) FORCE 19 - $(call if_changed,strip_relocs) 20 - 21 - targets += vmlinux 22 - else 23 - vmlinux-final := vmlinux 24 - endif 25 - 26 12 %.o: %.c FORCE 27 13 $(call if_changed_rule,cc_o_c) 28 14 ··· 47 61 48 62 ifdef CONFIG_GENERIC_BUILTIN_DTB 49 63 targets += .builtin-dtbs.S .builtin-dtbs.o 50 - $(vmlinux-final): .builtin-dtbs.o 64 + vmlinux.unstripped: .builtin-dtbs.o 51 65 endif 52 66 53 - # vmlinux 67 + # vmlinux.unstripped 54 68 # --------------------------------------------------------------------------- 55 69 56 - ifdef CONFIG_MODULES 57 - targets += .vmlinux.export.o 58 - $(vmlinux-final): .vmlinux.export.o 59 - endif 60 - 61 70 ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX 62 - $(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o 71 + vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o 63 72 64 73 arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE 65 74 $(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@ ··· 67 86 $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ 68 87 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 69 88 70 - targets += $(vmlinux-final) 71 - $(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE 89 + targets += vmlinux.unstripped .vmlinux.export.o 90 + vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o .vmlinux.export.o $(KBUILD_LDS) FORCE 72 91 +$(call if_changed_dep,link_vmlinux) 73 92 ifdef CONFIG_DEBUG_INFO_BTF 74 - $(vmlinux-final): $(RESOLVE_BTFIDS) 93 + vmlinux.unstripped: $(RESOLVE_BTFIDS) 75 94 endif 76 95 77 96 ifdef CONFIG_BUILDTIME_TABLE_SORT 78 - $(vmlinux-final): scripts/sorttable 97 + vmlinux.unstripped: scripts/sorttable 79 98 endif 99 + 100 + # vmlinux 101 + # --------------------------------------------------------------------------- 102 + 103 + remove-section-y := .modinfo 104 + remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*' 105 + 106 + remove-symbols := -w --strip-symbol='__mod_device_table__*' 107 + 108 + # To avoid warnings: "empty loadable segment detected at ..." from GNU objcopy, 109 + # it is necessary to remove the PT_LOAD flag from the segment. 110 + quiet_cmd_strip_relocs = OBJCOPY $@ 111 + cmd_strip_relocs = $(OBJCOPY) $(patsubst %,--set-section-flags %=noload,$(remove-section-y)) $< $@; \ 112 + $(OBJCOPY) $(addprefix --remove-section=,$(remove-section-y)) $(remove-symbols) $@ 113 + 114 + targets += vmlinux 115 + vmlinux: vmlinux.unstripped FORCE 116 + $(call if_changed,strip_relocs) 117 + 118 + # modules.builtin.modinfo 119 + # --------------------------------------------------------------------------- 120 + 121 + OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary 122 + 123 + targets += modules.builtin.modinfo 124 + modules.builtin.modinfo: vmlinux.unstripped FORCE 125 + $(call if_changed,objcopy) 126 + 127 + # modules.builtin 128 + # --------------------------------------------------------------------------- 129 + 130 + __default: modules.builtin 131 + 132 + # The second line aids cases where multiple modules share the same object. 133 + 134 + quiet_cmd_modules_builtin = GEN $@ 135 + cmd_modules_builtin = \ 136 + tr '\0' '\n' < $< | \ 137 + sed -n 's/^[[:alnum:]:_]*\.file=//p' | \ 138 + tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ 139 + 140 + targets += modules.builtin 141 + modules.builtin: modules.builtin.modinfo FORCE 142 + $(call if_changed,modules_builtin) 80 143 81 144 # modules.builtin.ranges 82 145 # --------------------------------------------------------------------------- ··· 135 110 modules.builtin vmlinux.map vmlinux.o.map FORCE 136 111 $(call if_changed,modules_builtin_ranges) 137 112 138 - vmlinux.map: $(vmlinux-final) 113 + vmlinux.map: vmlinux.unstripped 139 114 @: 140 115 141 116 endif
+1 -25
scripts/Makefile.vmlinux_o
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 3 PHONY := __default 4 - __default: vmlinux.o modules.builtin.modinfo modules.builtin 4 + __default: vmlinux.o 5 5 6 6 include include/config/auto.conf 7 7 include $(srctree)/scripts/Kbuild.include ··· 72 72 $(call if_changed_rule,ld_vmlinux.o) 73 73 74 74 targets += vmlinux.o 75 - 76 - # modules.builtin.modinfo 77 - # --------------------------------------------------------------------------- 78 - 79 - OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary 80 - 81 - targets += modules.builtin.modinfo 82 - modules.builtin.modinfo: vmlinux.o FORCE 83 - $(call if_changed,objcopy) 84 - 85 - # modules.builtin 86 - # --------------------------------------------------------------------------- 87 - 88 - # The second line aids cases where multiple modules share the same object. 89 - 90 - quiet_cmd_modules_builtin = GEN $@ 91 - cmd_modules_builtin = \ 92 - tr '\0' '\n' < $< | \ 93 - sed -n 's/^[[:alnum:]:_]*\.file=//p' | \ 94 - tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ 95 - 96 - targets += modules.builtin 97 - modules.builtin: modules.builtin.modinfo FORCE 98 - $(call if_changed,modules_builtin) 99 75 100 76 # Add FORCE to the prerequisites of a target to force it to be always rebuilt. 101 77 # ---------------------------------------------------------------------------
+5 -3
scripts/extract-vmlinux
··· 10 10 # 11 11 # ---------------------------------------------------------------------- 12 12 13 + me=${0##*/} 14 + 13 15 check_vmlinux() 14 16 { 15 17 if file "$1" | grep -q 'Linux kernel.*boot executable' || 16 18 readelf -h "$1" > /dev/null 2>&1 17 19 then 18 20 cat "$1" 21 + echo "$me: Extracted vmlinux using '$2' from offset $3" >&2 19 22 exit 0 20 23 fi 21 24 } ··· 33 30 do 34 31 pos=${pos%%:*} 35 32 tail -c+$pos "$img" | $3 > $tmp 2> /dev/null 36 - check_vmlinux $tmp 33 + check_vmlinux $tmp "$3" $pos 37 34 done 38 35 } 39 36 40 37 # Check invocation: 41 - me=${0##*/} 42 38 img=$1 43 39 if [ $# -ne 1 -o ! -s "$img" ] 44 40 then ··· 59 57 try_decompress '(\265/\375' xxx unzstd 60 58 61 59 # Finally check for uncompressed images or objects: 62 - check_vmlinux $img 60 + check_vmlinux "$img" cat 0 63 61 64 62 # Bail out: 65 63 echo "$me: Cannot find vmlinux." >&2
+3 -5
scripts/kconfig/nconf.gui.c
··· 173 173 /* do not go over end of line */ 174 174 total_lines = min(total_lines, y); 175 175 for (i = 0; i < total_lines; i++) { 176 - char tmp[x+10]; 177 176 const char *line = get_line(text, i); 178 - int len = get_line_length(line); 179 - strncpy(tmp, line, min(len, x)); 180 - tmp[len] = '\0'; 181 - mvwprintw(win, i, 0, "%s", tmp); 177 + int len = min(get_line_length(line), x); 178 + 179 + mvwprintw(win, i, 0, "%.*s", len, line); 182 180 } 183 181 } 184 182
+13
scripts/kconfig/qconf.cc
··· 1377 1377 ConfigList::showPromptAction = new QAction("Show Prompt Options", optGroup); 1378 1378 ConfigList::showPromptAction->setCheckable(true); 1379 1379 1380 + switch (configList->optMode) { 1381 + case allOpt: 1382 + ConfigList::showAllAction->setChecked(true); 1383 + break; 1384 + case promptOpt: 1385 + ConfigList::showPromptAction->setChecked(true); 1386 + break; 1387 + case normalOpt: 1388 + default: 1389 + ConfigList::showNormalAction->setChecked(true); 1390 + break; 1391 + } 1392 + 1380 1393 QAction *showDebugAction = new QAction("Show Debug Info", this); 1381 1394 showDebugAction->setCheckable(true); 1382 1395 connect(showDebugAction, &QAction::toggled,
+2 -4
scripts/min-tool-version.sh
··· 24 24 fi 25 25 ;; 26 26 llvm) 27 - if [ "$SRCARCH" = s390 -o "$SRCARCH" = x86 ]; then 28 - echo 15.0.0 29 - elif [ "$SRCARCH" = loongarch ]; then 27 + if [ "$SRCARCH" = loongarch ]; then 30 28 echo 18.0.0 31 29 else 32 - echo 13.0.1 30 + echo 15.0.0 33 31 fi 34 32 ;; 35 33 rustc)
+2 -2
scripts/misc-check
··· 45 45 # does not automatically fix it. 46 46 check_missing_include_linux_export_h () { 47 47 48 - git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_GPL_FOR_MODULES)\(.*\)' \ 48 + git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \ 49 49 -- '*.[ch]' :^tools/ :^include/linux/export.h | 50 50 xargs -r git -C "${srctree:-.}" grep --files-without-match '#include[[:space:]]*<linux/export\.h>' | 51 51 xargs -r printf "%s: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing\n" >&2 ··· 58 58 59 59 git -C "${srctree:-.}" grep --files-with-matches '#include[[:space:]]*<linux/export\.h>' \ 60 60 -- '*.[c]' :^tools/ | 61 - xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_GPL_FOR_MODULES)\(.*\)' | 61 + xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' | 62 62 xargs -r printf "%s: warning: EXPORT_SYMBOL() is not used, but #include <linux/export.h> is present\n" >&2 63 63 } 64 64
+6
scripts/mksysmap
··· 59 59 # EXPORT_SYMBOL (namespace) 60 60 / __kstrtabns_/d 61 61 62 + # MODULE_DEVICE_TABLE (symbol name) 63 + / __mod_device_table__/d 64 + 62 65 # --------------------------------------------------------------------------- 63 66 # Ignored suffixes 64 67 # (do not forget '$' after each pattern) ··· 81 78 # ppc 82 79 / _SDA_BASE_$/d 83 80 / _SDA2_BASE_$/d 81 + 82 + # MODULE_INFO() 83 + / __UNIQUE_ID_modinfo[0-9]*$/d 84 84 85 85 # --------------------------------------------------------------------------- 86 86 # Ignored patterns
+31 -4
scripts/mod/file2alias.c
··· 94 94 } 95 95 } 96 96 97 + new->builtin_modname = NULL; 97 98 list_add_tail(&new->node, &mod->aliases); 98 99 } 99 100 ··· 1477 1476 { 1478 1477 void *symval; 1479 1478 char *zeros = NULL; 1480 - const char *type, *name; 1481 - size_t typelen; 1479 + const char *type, *name, *modname; 1480 + size_t typelen, modnamelen; 1482 1481 static const char *prefix = "__mod_device_table__"; 1483 1482 1484 1483 /* We're looking for a section relative symbol */ ··· 1489 1488 if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) 1490 1489 return; 1491 1490 1492 - /* All our symbols are of form __mod_device_table__<type>__<name>. */ 1491 + /* All our symbols are of form __mod_device_table__kmod_<modname>__<type>__<name>. */ 1493 1492 if (!strstarts(symname, prefix)) 1494 1493 return; 1495 - type = symname + strlen(prefix); 1494 + 1495 + modname = strstr(symname, "__kmod_"); 1496 + if (!modname) 1497 + return; 1498 + modname += strlen("__kmod_"); 1499 + 1500 + type = strstr(modname, "__"); 1501 + if (!type) 1502 + return; 1503 + modnamelen = type - modname; 1504 + type += strlen("__"); 1496 1505 1497 1506 name = strstr(type, "__"); 1498 1507 if (!name) ··· 1525 1514 do_table(name, symval, sym->st_size, p->id_size, 1526 1515 p->device_id, p->do_entry, mod); 1527 1516 break; 1517 + } 1518 + } 1519 + 1520 + if (mod->is_vmlinux) { 1521 + struct module_alias *alias; 1522 + 1523 + /* 1524 + * If this is vmlinux, record the name of the builtin module. 1525 + * Traverse the linked list in the reverse order, and set the 1526 + * builtin_modname unless it has already been set in the 1527 + * previous call. 1528 + */ 1529 + list_for_each_entry_reverse(alias, &mod->aliases, node) { 1530 + if (alias->builtin_modname) 1531 + break; 1532 + alias->builtin_modname = xstrndup(modname, modnamelen); 1528 1533 } 1529 1534 } 1530 1535
+15
scripts/mod/modpost.c
··· 2067 2067 static void write_vmlinux_export_c_file(struct module *mod) 2068 2068 { 2069 2069 struct buffer buf = { }; 2070 + struct module_alias *alias, *next; 2070 2071 2071 2072 buf_printf(&buf, 2072 2073 "#include <linux/export-internal.h>\n"); 2073 2074 2074 2075 add_exported_symbols(&buf, mod); 2076 + 2077 + buf_printf(&buf, 2078 + "#include <linux/module.h>\n" 2079 + "#undef __MODULE_INFO_PREFIX\n" 2080 + "#define __MODULE_INFO_PREFIX\n"); 2081 + 2082 + list_for_each_entry_safe(alias, next, &mod->aliases, node) { 2083 + buf_printf(&buf, "MODULE_INFO(%s.alias, \"%s\");\n", 2084 + alias->builtin_modname, alias->str); 2085 + list_del(&alias->node); 2086 + free(alias->builtin_modname); 2087 + free(alias); 2088 + } 2089 + 2075 2090 write_if_changed(&buf, ".vmlinux.export.c"); 2076 2091 free(buf.p); 2077 2092 }
+2
scripts/mod/modpost.h
··· 99 99 * struct module_alias - auto-generated MODULE_ALIAS() 100 100 * 101 101 * @node: linked to module::aliases 102 + * @modname: name of the builtin module (only for vmlinux) 102 103 * @str: a string for MODULE_ALIAS() 103 104 */ 104 105 struct module_alias { 105 106 struct list_head node; 107 + char *builtin_modname; 106 108 char str[]; 107 109 }; 108 110
-10
tools/objtool/check.c
··· 2453 2453 if (!strncmp(name, "__sanitizer_cov_", 16)) 2454 2454 return true; 2455 2455 2456 - /* 2457 - * Some compilers currently do not remove __tsan_func_entry/exit nor 2458 - * __tsan_atomic_signal_fence (used for barrier instrumentation) with 2459 - * the __no_sanitize_thread attribute, remove them. Once the kernel's 2460 - * minimum Clang version is 14.0, this can be removed. 2461 - */ 2462 - if (!strncmp(name, "__tsan_func_", 12) || 2463 - !strcmp(name, "__tsan_atomic_signal_fence")) 2464 - return true; 2465 - 2466 2456 return false; 2467 2457 } 2468 2458
-3
tools/power/cpupower/.gitignore
··· 27 27 debug/i386/powernow-k8-decode 28 28 debug/x86_64/centrino-decode 29 29 debug/x86_64/powernow-k8-decode 30 - 31 - # Clang's compilation database file 32 - compile_commands.json
+157 -76
usr/gen_init_cpio.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 + #define _GNU_SOURCE 2 3 #include <stdio.h> 3 4 #include <stdlib.h> 4 5 #include <stdint.h> ··· 24 23 #define xstr(s) #s 25 24 #define str(s) xstr(s) 26 25 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 26 + #define CPIO_HDR_LEN 110 27 + #define CPIO_TRAILER "TRAILER!!!" 28 + #define padlen(_off, _align) (((_align) - ((_off) & ((_align) - 1))) % (_align)) 27 29 30 + /* zero-padding the filename field for data alignment is limited by PATH_MAX */ 31 + static char padding[PATH_MAX]; 28 32 static unsigned int offset; 29 33 static unsigned int ino = 721; 30 34 static time_t default_mtime; 31 35 static bool do_file_mtime; 32 36 static bool do_csum = false; 37 + static int outfd = STDOUT_FILENO; 38 + static unsigned int dalign; 33 39 34 40 struct file_handler { 35 41 const char *type; 36 42 int (*handler)(const char *line); 37 43 }; 38 44 39 - static void push_string(const char *name) 45 + static int push_buf(const char *name, size_t name_len) 40 46 { 41 - unsigned int name_len = strlen(name) + 1; 47 + ssize_t len; 42 48 43 - fputs(name, stdout); 44 - putchar(0); 49 + len = write(outfd, name, name_len); 50 + if (len != name_len) 51 + return -1; 52 + 45 53 offset += name_len; 54 + return 0; 46 55 } 47 56 48 - static void push_pad (void) 57 + static int push_pad(size_t padlen) 49 58 { 50 - while (offset & 3) { 51 - putchar(0); 52 - offset++; 53 - } 59 + ssize_t len = 0; 60 + 61 + if (!padlen) 62 + return 0; 63 + 64 + if (padlen < sizeof(padding)) 65 + len = write(outfd, padding, padlen); 66 + if (len != padlen) 67 + return -1; 68 + 69 + offset += padlen; 70 + return 0; 54 71 } 55 72 56 - static void push_rest(const char *name) 73 + static int push_rest(const char *name, size_t name_len) 57 74 { 58 - unsigned int name_len = strlen(name) + 1; 59 - unsigned int tmp_ofs; 75 + ssize_t len; 60 76 61 - fputs(name, stdout); 62 - putchar(0); 77 + len = write(outfd, name, name_len); 78 + if (len != name_len) 79 + return -1; 80 + 63 81 offset += name_len; 64 82 65 - tmp_ofs = name_len + 110; 66 - while (tmp_ofs & 3) { 67 - putchar(0); 68 - offset++; 69 - tmp_ofs++; 70 - } 83 + return push_pad(padlen(name_len + CPIO_HDR_LEN, 4)); 71 84 } 72 85 73 - static void push_hdr(const char *s) 86 + static int cpio_trailer(void) 74 87 { 75 - fputs(s, stdout); 76 - offset += 110; 77 - } 88 + int len; 89 + unsigned int namesize = sizeof(CPIO_TRAILER); 78 90 79 - static void cpio_trailer(void) 80 - { 81 - char s[256]; 82 - const char name[] = "TRAILER!!!"; 83 - 84 - sprintf(s, "%s%08X%08X%08lX%08lX%08X%08lX" 91 + len = dprintf(outfd, "%s%08X%08X%08lX%08lX%08X%08lX" 85 92 "%08X%08X%08X%08X%08X%08X%08X", 86 93 do_csum ? "070702" : "070701", /* magic */ 87 94 0, /* ino */ ··· 103 94 0, /* minor */ 104 95 0, /* rmajor */ 105 96 0, /* rminor */ 106 - (unsigned)strlen(name)+1, /* namesize */ 97 + namesize, /* namesize */ 107 98 0); /* chksum */ 108 - push_hdr(s); 109 - push_rest(name); 99 + offset += len; 110 100 111 - while (offset % 512) { 112 - putchar(0); 113 - offset++; 114 - } 101 + if (len != CPIO_HDR_LEN || 102 + push_rest(CPIO_TRAILER, namesize) < 0 || 103 + push_pad(padlen(offset, 512)) < 0) 104 + return -1; 105 + 106 + return fsync(outfd); 115 107 } 116 108 117 109 static int cpio_mkslink(const char *name, const char *target, 118 110 unsigned int mode, uid_t uid, gid_t gid) 119 111 { 120 - char s[256]; 112 + int len; 113 + unsigned int namesize, targetsize = strlen(target) + 1; 121 114 122 115 if (name[0] == '/') 123 116 name++; 124 - sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" 117 + namesize = strlen(name) + 1; 118 + 119 + len = dprintf(outfd, "%s%08X%08X%08lX%08lX%08X%08lX" 125 120 "%08X%08X%08X%08X%08X%08X%08X", 126 121 do_csum ? "070702" : "070701", /* magic */ 127 122 ino++, /* ino */ ··· 134 121 (long) gid, /* gid */ 135 122 1, /* nlink */ 136 123 (long) default_mtime, /* mtime */ 137 - (unsigned)strlen(target)+1, /* filesize */ 124 + targetsize, /* filesize */ 138 125 3, /* major */ 139 126 1, /* minor */ 140 127 0, /* rmajor */ 141 128 0, /* rminor */ 142 - (unsigned)strlen(name) + 1,/* namesize */ 129 + namesize, /* namesize */ 143 130 0); /* chksum */ 144 - push_hdr(s); 145 - push_string(name); 146 - push_pad(); 147 - push_string(target); 148 - push_pad(); 131 + offset += len; 132 + 133 + if (len != CPIO_HDR_LEN || 134 + push_buf(name, namesize) < 0 || 135 + push_pad(padlen(offset, 4)) < 0 || 136 + push_buf(target, targetsize) < 0 || 137 + push_pad(padlen(offset, 4)) < 0) 138 + return -1; 139 + 149 140 return 0; 141 + 150 142 } 151 143 152 144 static int cpio_mkslink_line(const char *line) ··· 175 157 static int cpio_mkgeneric(const char *name, unsigned int mode, 176 158 uid_t uid, gid_t gid) 177 159 { 178 - char s[256]; 160 + int len; 161 + unsigned int namesize; 179 162 180 163 if (name[0] == '/') 181 164 name++; 182 - sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" 165 + namesize = strlen(name) + 1; 166 + 167 + len = dprintf(outfd, "%s%08X%08X%08lX%08lX%08X%08lX" 183 168 "%08X%08X%08X%08X%08X%08X%08X", 184 169 do_csum ? "070702" : "070701", /* magic */ 185 170 ino++, /* ino */ ··· 196 175 1, /* minor */ 197 176 0, /* rmajor */ 198 177 0, /* rminor */ 199 - (unsigned)strlen(name) + 1,/* namesize */ 178 + namesize, /* namesize */ 200 179 0); /* chksum */ 201 - push_hdr(s); 202 - push_rest(name); 180 + offset += len; 181 + 182 + if (len != CPIO_HDR_LEN || 183 + push_rest(name, namesize) < 0) 184 + return -1; 185 + 203 186 return 0; 204 187 } 205 188 ··· 271 246 uid_t uid, gid_t gid, char dev_type, 272 247 unsigned int maj, unsigned int min) 273 248 { 274 - char s[256]; 249 + int len; 250 + unsigned int namesize; 275 251 276 252 if (dev_type == 'b') 277 253 mode |= S_IFBLK; ··· 281 255 282 256 if (name[0] == '/') 283 257 name++; 284 - sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" 258 + namesize = strlen(name) + 1; 259 + 260 + len = dprintf(outfd, "%s%08X%08X%08lX%08lX%08X%08lX" 285 261 "%08X%08X%08X%08X%08X%08X%08X", 286 262 do_csum ? "070702" : "070701", /* magic */ 287 263 ino++, /* ino */ ··· 297 269 1, /* minor */ 298 270 maj, /* rmajor */ 299 271 min, /* rminor */ 300 - (unsigned)strlen(name) + 1,/* namesize */ 272 + namesize, /* namesize */ 301 273 0); /* chksum */ 302 - push_hdr(s); 303 - push_rest(name); 274 + offset += len; 275 + 276 + if (len != CPIO_HDR_LEN || 277 + push_rest(name, namesize) < 0) 278 + return -1; 279 + 304 280 return 0; 305 281 } 306 282 ··· 356 324 unsigned int mode, uid_t uid, gid_t gid, 357 325 unsigned int nlinks) 358 326 { 359 - char s[256]; 360 327 struct stat buf; 361 328 unsigned long size; 362 - int file; 363 - int retval; 329 + int file, retval, len; 364 330 int rc = -1; 365 331 time_t mtime; 366 - int namesize; 332 + int namesize, namepadlen; 367 333 unsigned int i; 368 334 uint32_t csum = 0; 335 + ssize_t this_read; 369 336 370 337 mode |= S_IFREG; 371 338 ··· 409 378 } 410 379 411 380 size = 0; 381 + namepadlen = 0; 412 382 for (i = 1; i <= nlinks; i++) { 413 - /* data goes on last link */ 414 - if (i == nlinks) 415 - size = buf.st_size; 416 - 417 383 if (name[0] == '/') 418 384 name++; 419 385 namesize = strlen(name) + 1; 420 - sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" 386 + 387 + /* data goes on last link, after any alignment padding */ 388 + if (i == nlinks) 389 + size = buf.st_size; 390 + 391 + if (dalign && size > dalign) { 392 + namepadlen = padlen(offset + CPIO_HDR_LEN + namesize, 393 + dalign); 394 + if (namesize + namepadlen > PATH_MAX) { 395 + fprintf(stderr, 396 + "%s: best-effort alignment %u missed\n", 397 + name, dalign); 398 + namepadlen = 0; 399 + } 400 + } 401 + 402 + len = dprintf(outfd, "%s%08X%08X%08lX%08lX%08X%08lX" 421 403 "%08lX%08X%08X%08X%08X%08X%08X", 422 404 do_csum ? "070702" : "070701", /* magic */ 423 405 ino, /* ino */ ··· 444 400 1, /* minor */ 445 401 0, /* rmajor */ 446 402 0, /* rminor */ 447 - namesize, /* namesize */ 403 + namesize + namepadlen, /* namesize */ 448 404 size ? csum : 0); /* chksum */ 449 - push_hdr(s); 450 - push_string(name); 451 - push_pad(); 405 + offset += len; 406 + 407 + if (len != CPIO_HDR_LEN || 408 + push_buf(name, namesize) < 0 || 409 + push_pad(namepadlen ? namepadlen : padlen(offset, 4)) < 0) 410 + goto error; 411 + 412 + if (size) { 413 + this_read = copy_file_range(file, NULL, outfd, NULL, size, 0); 414 + if (this_read > 0) { 415 + if (this_read > size) 416 + goto error; 417 + offset += this_read; 418 + size -= this_read; 419 + } 420 + /* short or failed copy falls back to read/write... */ 421 + } 452 422 453 423 while (size) { 454 424 unsigned char filebuf[65536]; 455 - ssize_t this_read; 456 425 size_t this_size = MIN(size, sizeof(filebuf)); 457 426 458 427 this_read = read(file, filebuf, this_size); ··· 474 417 goto error; 475 418 } 476 419 477 - if (fwrite(filebuf, this_read, 1, stdout) != 1) { 420 + if (write(outfd, filebuf, this_read) != this_read) { 478 421 fprintf(stderr, "writing filebuf failed\n"); 479 422 goto error; 480 423 } 481 424 offset += this_read; 482 425 size -= this_read; 483 426 } 484 - push_pad(); 427 + if (push_pad(padlen(offset, 4)) < 0) 428 + goto error; 485 429 486 430 name += namesize; 487 431 } ··· 567 509 static void usage(const char *prog) 568 510 { 569 511 fprintf(stderr, "Usage:\n" 570 - "\t%s [-t <timestamp>] [-c] <cpio_list>\n" 512 + "\t%s [-t <timestamp>] [-c] [-o <output_file>] [-a <data_align>] <cpio_list>\n" 571 513 "\n" 572 514 "<cpio_list> is a file containing newline separated entries that\n" 573 515 "describe the files to be included in the initramfs archive:\n" ··· 604 546 "as mtime for symlinks, directories, regular and special files.\n" 605 547 "The default is to use the current time for all files, but\n" 606 548 "preserve modification time for regular files.\n" 607 - "-c: calculate and store 32-bit checksums for file data.\n", 549 + "-c: calculate and store 32-bit checksums for file data.\n" 550 + "<output_file>: write cpio to this file instead of stdout\n" 551 + "<data_align>: attempt to align file data by zero-padding the\n" 552 + "filename field up to data_align. Must be a multiple of 4.\n" 553 + "Alignment is best-effort; PATH_MAX limits filename padding.\n", 608 554 prog); 609 555 } 610 556 ··· 650 588 651 589 default_mtime = time(NULL); 652 590 while (1) { 653 - int opt = getopt(argc, argv, "t:ch"); 591 + int opt = getopt(argc, argv, "t:cho:a:"); 654 592 char *invalid; 655 593 656 594 if (opt == -1) ··· 668 606 break; 669 607 case 'c': 670 608 do_csum = true; 609 + break; 610 + case 'o': 611 + outfd = open(optarg, 612 + O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC, 613 + 0600); 614 + if (outfd < 0) { 615 + fprintf(stderr, "failed to open %s\n", optarg); 616 + usage(argv[0]); 617 + exit(1); 618 + } 619 + break; 620 + case 'a': 621 + dalign = strtoul(optarg, &invalid, 10); 622 + if (!*optarg || *invalid || (dalign & 3)) { 623 + fprintf(stderr, "Invalid data_align: %s\n", 624 + optarg); 625 + usage(argv[0]); 626 + exit(1); 627 + } 671 628 break; 672 629 case 'h': 673 630 case '?': ··· 772 691 } 773 692 } 774 693 if (ec == 0) 775 - cpio_trailer(); 694 + ec = cpio_trailer(); 776 695 777 696 exit(ec); 778 697 }
+4 -3
usr/gen_initramfs.sh
··· 193 193 dep_list= 194 194 timestamp= 195 195 cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) 196 - output="/dev/stdout" 196 + # gen_init_cpio writes to stdout by default 197 + output="" 197 198 198 199 trap "rm -f $cpio_list" EXIT 199 200 ··· 208 207 shift 209 208 ;; 210 209 "-o") # generate cpio image named $1 211 - output="$1" 210 + output="-o $1" 212 211 shift 213 212 ;; 214 213 "-u") # map $1 to uid=0 (root) ··· 247 246 248 247 # If output_file is set we will generate cpio archive 249 248 # we are careful to delete tmp files 250 - usr/gen_init_cpio $timestamp $cpio_list > $output 249 + usr/gen_init_cpio $output $timestamp $cpio_list
+2 -2
usr/include/Makefile
··· 80 80 # Include the header twice to detect missing include guard. 81 81 quiet_cmd_hdrtest = HDRTEST $< 82 82 cmd_hdrtest = \ 83 - $(CC) $(c_flags) -fsyntax-only -x c /dev/null \ 83 + $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ 84 84 $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ 85 85 $(PERL) $(src)/headers_check.pl $(obj) $<; \ 86 86 touch $@ 87 87 88 - $(obj)/%.hdrtest: $(obj)/%.h FORCE 88 + $(obj)/%.hdrtest: $(obj)/%.h $(src)/headers_check.pl FORCE 89 89 $(call if_changed_dep,hdrtest) 90 90 91 91 # Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
+4 -5
usr/include/headers_check.pl
··· 74 74 printf STDERR "$filename:$lineno: " . 75 75 "userspace cannot reference function or " . 76 76 "variable defined in the kernel\n"; 77 + $ret = 1; 77 78 } 78 79 } 79 80 ··· 99 98 if ($line =~ m/^\s*#\s*include\s+<asm\/types.h>/) { 100 99 $linux_asm_types = 1; 101 100 printf STDERR "$filename:$lineno: " . 102 - "include of <linux/types.h> is preferred over <asm/types.h>\n" 103 - # Warn until headers are all fixed 104 - #$ret = 1; 101 + "include of <linux/types.h> is preferred over <asm/types.h>\n"; 102 + $ret = 1; 105 103 } 106 104 } 107 105 ··· 160 160 "found __[us]{8,16,32,64} type " . 161 161 "without #include <linux/types.h>\n"; 162 162 $linux_types = 2; 163 - # Warn until headers are all fixed 164 - #$ret = 1; 163 + $ret = 1; 165 164 } 166 165 }