From: Christophe Leroy <christophe.le...@csgroup.eu> Sent: Thursday, February 27, 2025 2:43 AM > > Le 27/02/2025 à 02:38, Stephen Rothwell a écrit : > > Hi Venkat, > > > > CC Kees Cook for advice. This is a result of the tests added in commit > > > > bbeb38b8487a ("string.h: Validate memtostr*()/strtomem*() arguments more > > carefully") > > > > from the kspp tree. > > > > I note that the comment about memtostr() says "Copy a possibly > > non-NUL-term string". > > Can you tell more about your config and your environment ? > > I just tested with ppc64_defconfig and ppc64le_defconfig, with gcc 12.4, > gcc 13.2 and gcc 14.2 and didn't get that build error. > > Christophe
FWIW, I see the same build failures related to __must_be_noncstr() when building natively on x86 and on arm64. In both cases, it's an Ubuntu 20.04 installation with gcc 9.4.0 and binutils 2.34. Michael > > > > > On Thu, 27 Feb 2025 06:30:12 +0530 Venkat Rao Bagalkote > <venka...@linux.vnet.ibm.com> wrote: > >> > >> I am seeing build failures with kernel next-20250226, on IBM Power8 > >> systems. > >> > >> Failures: > >> > >> In file included from ./include/asm-generic/div64.h:27, > >> from ./arch/powerpc/include/generated/asm/div64.h:1, > >> from ./include/linux/math.h:6, > >> from ./include/linux/math64.h:6, > >> from ./include/linux/time.h:6, > >> from fs/ext4/file.c:22: > >> fs/ext4/file.c: In function 'ext4_sample_last_mounted': > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:418:6: note: in expansion of macro > >> '__must_be_noncstr' > >> __must_be_noncstr(dest) + \ > >> ^~~~~~~~~~~~~~~~~ > >> fs/ext4/file.c:869:2: note: in expansion of macro 'strtomem_pad' > >> strtomem_pad(sbi->s_es->s_last_mounted, cp, 0); > >> ^~~~~~~~~~~~ > >> In file included from ./include/linux/build_bug.h:5, > >> from ./include/linux/container_of.h:5, > >> from ./include/linux/list.h:5, > >> from ./include/linux/module.h:12, > >> from drivers/message/fusion/mptsas.c:46: > >> drivers/message/fusion/mptsas.c: In function > >> 'mptsas_exp_repmanufacture_info': > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/message/fusion/mptsas.c:2968:3: note: in expansion of macro > >> 'memtostr' > >> memtostr(edev->vendor_id, manufacture_reply->vendor_id); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/message/fusion/mptsas.c:2969:3: note: in expansion of macro > >> 'memtostr' > >> memtostr(edev->product_id, manufacture_reply->product_id); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/message/fusion/mptsas.c:2970:3: note: in expansion of macro > >> 'memtostr' > >> memtostr(edev->product_rev, manufacture_reply->product_rev); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/message/fusion/mptsas.c:2973:4: note: in expansion of macro > >> 'memtostr' > >> memtostr(edev->component_vendor_id, > >> ^~~~~~~~ > >> make[4]: *** [scripts/Makefile.build:203: fs/ext4/file.o] Error 1 > >> make[3]: *** [scripts/Makefile.build:461: fs/ext4] Error 2 > >> make[3]: *** Waiting for unfinished jobs.... > >> In file included from ./include/linux/array_size.h:5, > >> from ./include/linux/kernel.h:16, > >> from drivers/scsi/mpt3sas/mpt3sas_base.c:46: > >> drivers/scsi/mpt3sas/mpt3sas_base.c: In function > >> '_base_display_ioc_capabilities': > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/mpt3sas/mpt3sas_base.c:4798:2: note: in expansion of macro > >> 'memtostr' > >> memtostr(desc, ioc->manu_pg0.ChipName); > >> ^~~~~~~~ > >> In file included from ./include/linux/build_bug.h:5, > >> from ./include/linux/container_of.h:5, > >> from ./include/linux/list.h:5, > >> from ./include/linux/module.h:12, > >> from drivers/scsi/mpt3sas/mpt3sas_transport.c:45: > >> drivers/scsi/mpt3sas/mpt3sas_transport.c: In function > '_transport_expander_report_manufacture': > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/mpt3sas/mpt3sas_transport.c:461:3: note: in expansion of macro > 'memtostr' > >> memtostr(edev->vendor_id, manufacture_reply->vendor_id); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/mpt3sas/mpt3sas_transport.c:462:3: note: in expansion of macro > 'memtostr' > >> memtostr(edev->product_id, manufacture_reply->product_id); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/mpt3sas/mpt3sas_transport.c:463:3: note: in expansion of macro > 'memtostr' > >> memtostr(edev->product_rev, manufacture_reply->product_rev); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/mpt3sas/mpt3sas_transport.c:466:4: note: in expansion of macro > 'memtostr' > >> memtostr(edev->component_vendor_id, > >> ^~~~~~~~ > >> make[5]: *** [scripts/Makefile.build:203: > >> drivers/scsi/mpt3sas/mpt3sas_transport.o] > Error 1 > >> make[5]: *** Waiting for unfinished jobs.... > >> make[5]: *** [scripts/Makefile.build:203: drivers/message/fusion/mptsas.o] > >> Error 1 > >> make[4]: *** [scripts/Makefile.build:461: drivers/message/fusion] Error 2 > >> make[3]: *** [scripts/Makefile.build:461: drivers/message] Error 2 > >> make[3]: *** Waiting for unfinished jobs.... > >> make[5]: *** [scripts/Makefile.build:203: > >> drivers/scsi/mpt3sas/mpt3sas_base.o] Error 1 > >> In file included from ./include/linux/array_size.h:5, > >> from ./include/linux/kernel.h:16, > >> from drivers/scsi/qla2xxx/qla_def.h:9, > >> from drivers/scsi/qla2xxx/qla_mr.c:6: > >> drivers/scsi/qla2xxx/qla_mr.c: In function 'qlafx00_fx_disc': > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/qla2xxx/qla_mr.c:1912:3: note: in expansion of macro > >> 'memtostr' > >> memtostr(vha->hw->model_number, pinfo->model_num); > >> ^~~~~~~~ > >> ./include/linux/compiler.h:197:62: error: static assertion failed: "must > >> be non-C-string > (not NUL-terminated)" > >> #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct > >> {_Static_assert(!(e), > msg);})) > >> ^~~~~~~~~~~~~~ > >> ./include/linux/compiler.h:226:2: note: in expansion of macro > '__BUILD_BUG_ON_ZERO_MSG' > >> __BUILD_BUG_ON_ZERO_MSG(!__is_noncstr(p), \ > >> ^~~~~~~~~~~~~~~~~~~~~~~ > >> ./include/linux/string.h:468:26: note: in expansion of macro > >> '__must_be_noncstr' > >> const size_t _src_len = __must_be_noncstr(src) + \ > >> ^~~~~~~~~~~~~~~~~ > >> drivers/scsi/qla2xxx/qla_mr.c:1913:3: note: in expansion of macro > >> 'memtostr' > >> memtostr(vha->hw->model_desc, pinfo->model_description); > >> ^~~~~~~~ > >> make[5]: *** [scripts/Makefile.build:203: drivers/scsi/qla2xxx/qla_mr.o] > >> Error 1 > >> make[5]: *** Waiting for unfinished jobs.... > >> make[2]: *** [scripts/Makefile.build:461: fs] Error 2 > >> make[2]: *** Waiting for unfinished jobs.... > >> make[4]: *** [scripts/Makefile.build:461: drivers/scsi/mpt3sas] Error 2 > >> make[4]: *** Waiting for unfinished jobs.... > >> make[4]: *** [scripts/Makefile.build:461: drivers/scsi/qla2xxx] Error 2 > >> make[3]: *** [scripts/Makefile.build:461: drivers/scsi] Error 2 > >> make[2]: *** [scripts/Makefile.build:461: drivers] Error 2 > >> make[1]: *** [/root/linux-next/Makefile:1989: .] Error 2 > >> make: *** [Makefile:251: __sub-make] Error 2 > > >