The arm64 hardening.config builds failed on the Linux mainline master for the arm64 architectures.
First seen on Linux mainline master 7eef7e306d3c40a0c5b9ff6adc9b273cc894dbd5. Good: 9f16d5e6f220661f73b36a4be1b21575651d8833 Bad: 7eef7e306d3c40a0c5b9ff6adc9b273cc894dbd5
arm64: build: * gcc-8-lkftconfig-hardening * gcc-13-lkftconfig-hardening
Reported-by: Linux Kernel Functional Testing lkft@linaro.org
Build error: --------- In function 'sized_strscpy', inlined from '__audit_ptrace' at kernel/auditsc.c:2732:2: include/linux/fortify-string.h:293:17: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object (1st parameter) 293 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ In function 'sized_strscpy', inlined from 'audit_signal_info_syscall' at kernel/auditsc.c:2759:3: include/linux/fortify-string.h:293:17: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object (1st parameter) 293 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ make[4]: *** [scripts/Makefile.build:229: kernel/auditsc.o] Error 1
Build image: ----------- - https://storage.tuxsuite.com/public/linaro/lkft/builds/2pNLRwWNgNgfh4C67CGIS... - https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v6.12-9567-g7... - https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v6.12-9567-g7... - https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v6.12-9567-g7...
Steps to reproduce: ------------ - # tuxmake --runtime podman --target-arch arm64 --toolchain gcc-13 \ --kconfig defconfig \ --kconfig-add https://gitlab.com/Linaro/lkft/kernel-fragments/-/raw/main/netdev.config \ --kconfig-add hardening.config
metadata: ---- git describe: v6.12-9567-g7eef7e306d3c git repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git sha: 7eef7e306d3c40a0c5b9ff6adc9b273cc894dbd5 kernel config: https://storage.tuxsuite.com/public/linaro/lkft/builds/2pNLRwWNgNgfh4C67CGIS... build url: https://storage.tuxsuite.com/public/linaro/lkft/builds/2pNLRwWNgNgfh4C67CGIS... toolchain: gcc-13 and gcc-8 config: hardening.config arch: arm64
-- Linaro LKFT https://lkft.linaro.org
On Tue, Nov 26, 2024, at 15:58, Naresh Kamboju wrote:
Build error:
In function 'sized_strscpy', inlined from '__audit_ptrace' at kernel/auditsc.c:2732:2: include/linux/fortify-string.h:293:17: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object (1st parameter) 293 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ In function 'sized_strscpy', inlined from 'audit_signal_info_syscall' at kernel/auditsc.c:2759:3: include/linux/fortify-string.h:293:17: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object (1st parameter) 293 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ make[4]: *** [scripts/Makefile.build:229: kernel/auditsc.o] Error 1
I have run into this specific one before but failed to come up with a working fix.
I think the specific warning started with
https://lore.kernel.org/all/20240828030321.20688-3-laoar.shao@gmail.com/
but reverting that just replaces it with a slightly different warning. In my randconfig tree I have a patch that comments out the two security_task_getlsmprop_obj(), and I don't think I get warnings at the moment, but I no longer see why I would have done that.
Arnd
On Tue, Nov 26, 2024, at 16:12, Arnd Bergmann wrote:
On Tue, Nov 26, 2024, at 15:58, Naresh Kamboju wrote:
Build error:
In function 'sized_strscpy', inlined from '__audit_ptrace' at kernel/auditsc.c:2732:2: include/linux/fortify-string.h:293:17: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object (1st parameter) 293 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ In function 'sized_strscpy', inlined from 'audit_signal_info_syscall' at kernel/auditsc.c:2759:3: include/linux/fortify-string.h:293:17: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object (1st parameter) 293 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ make[4]: *** [scripts/Makefile.build:229: kernel/auditsc.o] Error 1
I have run into this specific one before but failed to come up with a working fix.
I think the specific warning started with
https://lore.kernel.org/all/20240828030321.20688-3-laoar.shao@gmail.com/
but reverting that just replaces it with a slightly different warning. In my randconfig tree I have a patch that comments out the two security_task_getlsmprop_obj(), and I don't think I get warnings at the moment, but I no longer see why I would have done that.
Update: this seems to reliably avoid the warning, but I'm still a bit lost about what exactly gcc warns about. I assume this is a false-positive warning somewhere.
Added Kees and Gustavo to Cc in case they know what's going on.
Arnd
diff --git a/kernel/audit.h b/kernel/audit.h index 0211cb307d30..31cc41b167ae 100644 --- a/kernel/audit.h +++ b/kernel/audit.h @@ -145,7 +145,9 @@ struct audit_context { kuid_t target_uid; unsigned int target_sessionid; struct lsm_prop target_ref; - char target_comm[TASK_COMM_LEN]; + struct_group(_target_comm, + char target_comm[TASK_COMM_LEN]; + );
struct audit_tree_refs *trees, *first_trees; struct list_head killed_trees;