Wind River Support Network

HomeDefectsLIN1023-8437
Fixed

LIN1023-8437 : A compile error in drivers/net/ethernet/freescale/sdk_fman/etc/sprint.c

Created: Oct 2, 2024    Updated: Dec 15, 2024
Resolved Date: Oct 11, 2024
Found In Version: 10.23.30.12
Fix Version: 10.23.30.14
Severity: Severe
Applicable for: Wind River Linux LTS 23
Component/s: Kernel

Description

There is a compile error in sprint.c:

CC      drivers/net/ethernet/freescale/sdk_fman/etc/sprint.o
In file included from include/linux/string.h:293,
                 from drivers/net/ethernet/freescale/sdk_fman/inc/string_ext.h:40,
                 from drivers/net/ethernet/freescale/sdk_fman/etc/sprint.c:40:
include/linux/fortify-string.h:186:9: error: expected identifier or '(' before '__builtin_choose_expr'
  186 |         __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),      \
      |         ^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/freescale/sdk_fman/inc/stdlib_ext.h:93:8: note: in expansion of macro 'strlen'
   93 | size_t strlen(const char * s);
      |        ^~~~~~

Both string_ext.h and stdlib_ext.h are included in sprint.c.
strlen is redefined as macro indirectly in string_ext.h:
  -> #include <linux/string.h>
     -> #include <linux/fortify-string.h>
          #define strlen(p)                                                       \
                  __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),      \
                                   __builtin_strlen(p), __fortify_strlen(p))

In stdlib_ext.h there is a function declaration of strlen:
size_t strlen(const char * s);
But here compiler will expand macro 'strlen', this is wrong.

Solution: Don't include stdlib_ext.h in sprint.c

Steps to Reproduce

$ ./wrlinux-x/setup.sh (https://setup.sh/) --machines qemuarm64,nxp-lx2xxx,xilinx-zynqmp --buildtools-type extended --distros wrlinux,poky --template feature/kernel-hardening feature/initramfs feature/busybox feature/selinux feature/syslog-ng feature/chrony feature/snmp feature/stig feature/bpf feature/podman feature/buildah feature/signed-container feature/preserve-buildtime feature/task-scheduler

Set up environment

$ source environment-setup-x86_64-wrlinuxsdk-linux

Create build directory:

$ source oe-init-build-env build-2160

Edit conf/local.conf. Uncomment the line "MACHINE ?= "nxp-lx2xxx"

Edit bblayers.conf. Add the path to meta-security/meta-security-compliance under meta-security. (This is for openscap, which is part of feature/stig.)

Run bitbake wrlinux-image-core or bitbake wrlinux-image-small or bitbake wrlinux-image-std

It will eventually fail compiling linux-yocto.
 
If I edit conf/local.conf, and remove just "feature/kernel-hardening" from WRTEMPLATE, then the kernel compiles.

*Note:* Also test using only the feature/kernel-hardening and using PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-rt"
Live chat
Online