Allow additional arguments be passed to userprogs compilation.
Reproducible clang builds need to provide a sysroot and gcc path to
ensure the same toolchain is used across hosts. KCFLAGS is not currently
used for any user programs compilation, so add new USERCFLAGS and
USERLDFLAGS which serves similar purpose as HOSTCFLAGS/HOSTLDFLAGS.
Clang 13+ might detect GCC installation on hosts which have it installed
to a default location in /. With addition of these environment
variables, you can specify flags such as:
$ make USERCFLAGS=--sysroot=/path/to/sysroot
This can also be used to specify different sysroots such as musl or
bionic which may be installed on the host in paths that the compiler
may not search by default.
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Bug: 214127735
Link: https://lore.kernel.org/linux-kbuild/20220201213542.2808035-1-quic_eberman@quicinc.com/
Change-Id: I035309a569130774a1212f294973eee2830a6588
(cherry picked from commit df704104322c6bd1b3d40cb7ad109cba7453f3be)
https://source.android.com/docs/security/bulletin/2025-09-01
CVE-2025-21755
CVE-2025-38352
CVE-2025-021701
* tag 'ASB-2025-09-05_11-5.4' of https://android.googlesource.com/kernel/common:
UPSTREAM: perf/core: Fix potential NULL deref
UPSTREAM: net/packet: fix a race in packet_set_ring() and packet_notifier()
ANDROID: 16K: Allocate pad vma on the stack
ANDROID: 16K: Don't copy data vma for maps/smaps output
ANDROID: GKI: update Trimble symbol list
UPSTREAM: net/sched: Always pass notifications when child class becomes empty
Revert "drm/exynos: exynos7_drm_decon: add vblank check in IRQ handling"
Linux 5.4.296
net: ipv6: Discard next-hop MTU less than minimum link MTU
x86/mm: Disable hugetlb page table sharing on 32-bit
Input: atkbd - do not skip atkbd_deactivate() when skipping ATKBD_CMD_GETID
HID: quirks: Add quirk for 2 Chicony Electronics HP 5MP Cameras
HID: Add IGNORE quirk for SMARTLINKTECHNOLOGY
vt: add missing notification when switching back to text mode
net: usb: qmi_wwan: add SIMCom 8230C composition
atm: idt77252: Add missing `dma_map_error()`
bnxt_en: Set DMA unmap len correctly for XDP_REDIRECT
bnxt_en: Fix DCB ETS validation
can: m_can: m_can_handle_lost_msg(): downgrade msg lost in rx message to debug level
net: phy: microchip: limit 100M workaround to link-down events on LAN88xx
net: appletalk: Fix device refcount leak in atrtr_create()
md/raid1: Fix stack memory use after return in raid1_reshape
wifi: zd1211rw: Fix potential NULL pointer dereference in zd_mac_tx_to_dev()
dma-buf: fix timeout handling in dma_resv_wait_timeout v2
Input: xpad - support Acer NGR 200 Controller
Input: xpad - add VID for Turtle Beach controllers
Input: xpad - add support for Amazon Game Controller
NFSv4/flexfiles: Fix handling of NFS level errors in I/O
flexfiles/pNFS: update stats on NFS4ERR_DELAY for v4.1 DSes
RDMA/mlx5: Fix vport loopback for MPV device
netlink: Fix rmem check in netlink_broadcast_deliver().
netlink: make sure we allow at least one dump skb
pwm: mediatek: Ensure to disable clocks in error path
Revert "ACPI: battery: negate current when discharging"
usb: gadget: u_serial: Fix race condition in TTY wakeup
drm/sched: Increment job count before swapping tail spsc queue
pinctrl: qcom: msm: mark certain pins as invalid for interrupts
x86/mce: Make sure CMCI banks are cleared during shutdown on Intel
x86/mce: Don't remove sysfs if thresholding sysfs init fails
x86/mce/amd: Fix threshold limit reset
rxrpc: Fix oops due to non-existence of prealloc backlog struct
net/sched: Abort __tc_modify_qdisc if parent class does not exist
atm: clip: Fix NULL pointer dereference in vcc_sendmsg()
atm: clip: Fix infinite recursive call of clip_push().
atm: clip: Fix memory leak of struct clip_vcc.
atm: clip: Fix potential null-ptr-deref in to_atmarpd().
tipc: Fix use-after-free in tipc_conn_close().
netlink: Fix wraparounds of sk->sk_rmem_alloc.
fix proc_sys_compare() handling of in-lookup dentries
proc: Clear the pieces of proc_inode that proc_evict_inode cares about
drm/exynos: exynos7_drm_decon: add vblank check in IRQ handling
staging: rtl8723bs: Avoid memset() in aes_cipher() and aes_decipher()
media: uvcvideo: Rollback non processed entities on error
media: uvcvideo: Send control events for partial succeeds
media: uvcvideo: Return the number of processed controls
ACPI: PAD: fix crash in exit_round_robin()
usb: typec: displayport: Fix potential deadlock
Logitech C-270 even more broken
rose: fix dangling neighbour pointers in rose_rt_device_down()
net: rose: Fix fall-through warnings for Clang
drm/i915/gt: Fix timeline left held on VMA alloc error
drm/i915/selftests: Change mock_request() to return error pointers
spi: spi-fsl-dspi: Clear completion counter before initiating transfer
spi: spi-fsl-dspi: Fix interrupt-less DMA mode taking an XSPI code path
spi: spi-fsl-dspi: Rename fifo_{read,write} and {tx,cmd}_fifo_write
dpaa2-eth: fix xdp_rxq_info leak
ethernet: atl1: Add missing DMA mapping error checks and count errors
btrfs: use btrfs_record_snapshot_destroy() during rmdir
btrfs: propagate last_unlink_trans earlier when doing a rmdir
RDMA/mlx5: Fix CC counters query for MPV
RDMA/core: Create and destroy counters in the ib_core
scsi: ufs: core: Fix spelling of a sysfs attribute name
drm/v3d: Disable interrupts before resetting the GPU
mtk-sd: reset host->mrq on prepare_data() error
mtk-sd: Prevent memory corruption from DMA map failure
mmc: mediatek: use data instead of mrq parameter from msdc_{un}prepare_data()
regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods
regulator: gpio: Add input_supply support in gpio_regulator_config
ACPICA: Refuse to evaluate a method if arguments are missing
wifi: ath6kl: remove WARN on bad firmware input
wifi: mac80211: drop invalid source address OCB frames
powerpc: Fix struct termio related ioctl macros
ata: pata_cs5536: fix build on 32-bit UML
ALSA: sb: Force to disable DMAs once when DMA mode is changed
net/sched: Always pass notifications when child class becomes empty
nui: Fix dma_mapping_error() check
enic: fix incorrect MTU comparison in enic_change_mtu()
amd-xgbe: align CL37 AN sequence as per databook
lib: test_objagg: Set error message in check_expect_hints_stats()
drm/exynos: fimd: Guard display clock control with runtime PM calls
btrfs: fix missing error handling when searching for inode refs during log replay
scsi: qla4xxx: Fix missing DMA mapping error in qla4xxx_alloc_pdu()
nfs: Clean up /proc/net/rpc/nfs when nfs_fs_proc_net_init() fails.
RDMA/mlx5: Initialize obj_event->obj_sub_list before xa_insert
platform/mellanox: mlxbf-tmfifo: fix vring_desc.len assignment
mtk-sd: Fix a pagefault in dma_unmap_sg() for not prepared data
usb: typec: altmodes/displayport: do not index invalid pin_assignments
Revert "mmc: sdhci: Disable SD card clock before changing parameters"
mmc: sdhci: Add a helper function for dump register in dynamic debug mode
vsock/vmci: Clear the vmci transport packet properly when initializing it
btrfs: don't abort filesystem when attempting to snapshot deleted subvolume
arm64: Restrict pagetable teardown to avoid false warning
s390: Add '-std=gnu11' to decompressor and purgatory CFLAGS
drm/bridge: cdns-dsi: Check return value when getting default PHY config
drm/bridge: cdns-dsi: Fix connecting to next bridge
drm/bridge: cdns-dsi: Fix the clock variable for mode_valid()
drm/tegra: Assign plane type before registration
HID: wacom: fix kobject reference count leak
HID: wacom: fix memory leak on sysfs attribute creation failure
HID: wacom: fix memory leak on kobject creation failure
dm-raid: fix variable in journal device check
Bluetooth: L2CAP: Fix L2CAP MTU negotiation
atm: Release atm_dev_mutex after removing procfs in atm_dev_deregister().
net: enetc: Correct endianness handling in _enetc_rd_reg64
um: ubd: Add missing error check in start_io_thread()
vsock/uapi: fix linux/vm_sockets.h userspace compilation errors
wifi: mac80211: fix beacon interval calculation overflow
attach_recursive_mnt(): do not lock the covering tree when sliding something under it
ALSA: usb-audio: Fix out-of-bounds read in snd_usb_get_audioformat_uac3()
i2c: robotfuzz-osif: disable zero-length read messages
i2c: tiny-usb: disable zero-length read messages
RDMA/iwcm: Fix use-after-free of work objects after cm_id destruction
RDMA/core: Use refcount_t instead of atomic_t on refcount of iwcm_id_private
media: vivid: Change the siize of the composing
media: omap3isp: use sgtable-based scatterlist wrappers
media: cxusb: no longer judge rbuf when the write fails
media: cxusb: use dev_dbg() rather than hand-rolled debug
jfs: validate AG parameters in dbMount() to prevent crashes
fs/jfs: consolidate sanity checking in dbMount
ASoC: meson: meson-card-utils: use of_property_present() for DT parsing
of: Add of_property_present() helper
of: property: define of_property_read_u{8,16,32,64}_array() unconditionally
kbuild: hdrcheck: fix cross build with clang
kbuild: add --target to correctly cross-compile UAPI headers with Clang
bpfilter: match bit size of bpfilter_umh to that of the kernel
kbuild: use -MMD instead of -MD to exclude system headers from dependency
VMCI: fix race between vmci_host_setup_notify and vmci_ctx_unset_notify
VMCI: check context->notify_page after call to get_user_pages_fast() to avoid GPF
ovl: Check for NULL d_inode() in ovl_dentry_upper()
ceph: fix possible integer overflow in ceph_zero_objects()
ALSA: hda: Ignore unsol events for cards being shut down
usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
usb: cdc-wdm: avoid setting WDM_READ for ZLP-s
usb: Add checks for snprintf() calls in usb_alloc_dev()
tty: serial: uartlite: register uart driver in init
usb: potential integer overflow in usbg_make_tpg()
iio: pressure: zpa2326: Use aligned_s64 for the timestamp
md/md-bitmap: fix dm-raid max_write_behind setting
dmaengine: xilinx_dma: Set dma_device directions
mfd: max14577: Fix wakeup source leaks on device unbind
mailbox: Not protect module_put with spin_lock_irqsave
cifs: Fix cifs_query_path_info() for Windows NT servers
Conflicts:
drivers/hid/hid-ids.h
drivers/pinctrl/qcom/pinctrl-msm.c
Change-Id: Ifd5acd2c013f9985e02b866e3f9383383077e3f0
[ Upstream commit 02e9a22ceef0227175e391902d8760425fa072c6 ]
The headercheck tries to call clang with a mix of compiler arguments
that don't include the target architecture. When building e.g. x86
headers on arm64, this produces a warning like
clang: warning: unknown platform, assuming -mfloat-abi=soft
Add in the KBUILD_CPPFLAGS, which contain the target, in order to make it
build properly.
See also 1b71c2fb04e7 ("kbuild: userprogs: fix bitsize and target
detection on clang").
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Fixes: feb843a469fb ("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit 9fbed27a7a1101c926718dfa9b49aff1d04477b5 ]
When you compile-test UAPI headers (CONFIG_UAPI_HEADER_TEST=y) with
Clang, they are currently compiled for the host target (likely x86_64)
regardless of the given ARCH=.
In fact, some exported headers include libc headers. For example,
include/uapi/linux/agpgart.h includes <stdlib.h> after being exported.
The header search paths should match to the target we are compiling
them for.
Pick up the --target triple from KBUILD_CFLAGS in the same ways as
commit 7f58b487e9ff ("kbuild: make Clang build userprogs for target
architecture").
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Stable-dep-of: 02e9a22ceef0 ("kbuild: hdrcheck: fix cross build with clang")
Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit 9371f86ecb60f6f1f120e3d93fe892bbb70d04c0 ]
bpfilter_umh is built for the default machine bit of the compiler,
which may not match to the bit size of the kernel.
This happens in the scenario below:
You can use biarch GCC that defaults to 64-bit for building the 32-bit
kernel. In this case, Kbuild passes -m32 to teach the compiler to
produce 32-bit kernel space objects. However, it is missing when
building bpfilter_umh. It is built as a 64-bit ELF, and then embedded
into the 32-bit kernel.
The 32-bit kernel and 64-bit umh is a bad combination.
In theory, we can have 32-bit umh running on 64-bit kernel, but we do
not have a good reason to support such a usecase.
The best is to match the bit size between them.
Pass -m32 or -m64 to the umh build command if it is found in
$(KBUILD_CFLAGS). Evaluate CC_CAN_LINK against the kernel bit-size.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Stable-dep-of: 02e9a22ceef0 ("kbuild: hdrcheck: fix cross build with clang")
Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit 30a7729771731971839cc969d2a321e6ea7a144b ]
This omits system headers from the generated header dependency.
System headers are not updated unless you upgrade the compiler. Nor do
they contain CONFIG options, so fixdep does not need to parse them.
Having said that, the effect of this optimization will be quite small
because the kernel code generally does not include system headers
except <stdarg.h>. Host programs include a lot of system headers,
but there are not so many in the kernel tree.
At first, keeping system headers in .*.cmd files might be useful to
detect the compiler update, but there is no guarantee that <stdarg.h>
is included from every file. So, I implemented a more reliable way in
the previous commit.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Stable-dep-of: 02e9a22ceef0 ("kbuild: hdrcheck: fix cross build with clang")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Currently, header test puts videodev2.h into exclude list,
which avoid its inclusion while performing header test.
There are few camera headers which includes videodev2.h
and fails to compile during header test on some
host machine. Ideally, the headers files which includes
videodev2.h should get excluded from header test as they
eventually becomes incompatible due to videodev2.h .
This patch add camera headers to exclude list.
Change-Id: Ia8b7dc8ec635d568a026b948854448c77aae7770
Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
Excluding the camera headers which includes videodev2.h
to avoid compilation error on some platforms.
Change-Id: I9fe2c6b75914bd77ceff39f7714f542f711b4af6
Signed-off-by: Prasad Mullamuri <prasadmu@codeaurora.org>
commit 7ecaf069da52e472d393f03e79d721aabd724166 upstream.
Currently, some sanity checks for uapi headers are done by
scripts/headers_check.pl, which is wired up to the 'headers_check'
target in the top Makefile.
It is true compiling headers has better test coverage, but there
are still several headers excluded from the compile test. I like
to keep headers_check.pl for a while, but we can delete a lot of
code by moving the build rule to usr/include/Makefile.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit fcbb8461fd2376ba3782b5b8bd440c929b8e4980 upstream.
There are both positive and negative options about this feature.
At first, I thought it was a good idea, but actually Linus stated a
negative opinion (https://lkml.org/lkml/2019/9/29/227). I admit it
is ugly and annoying.
The baseline I'd like to keep is the compile-test of uapi headers.
(Otherwise, kernel developers have no way to ensure the correctness
of the exported headers.)
I will maintain a small build rule in usr/include/Makefile.
Remove the other header test functionality.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[ added to 5.4.y due to start of build warnings from backported patches
because of this feature - gregkh]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Commit 6dc280ebee ("coda: remove uapi/linux/coda_psdev.h") removed
a header in question. Some more build errors were fixed. Add more
headers into the test coverage.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Pull networking fixes from David Miller:
1) Sanity check URB networking device parameters to avoid divide by
zero, from Oliver Neukum.
2) Disable global multicast filter in NCSI, otherwise LLDP and IPV6
don't work properly. Longer term this needs a better fix tho. From
Vijay Khemka.
3) Small fixes to selftests (use ping when ping6 is not present, etc.)
from David Ahern.
4) Bring back rt_uses_gateway member of struct rtable, it's semantics
were not well understood and trying to remove it broke things. From
David Ahern.
5) Move usbnet snaity checking, ignore endpoints with invalid
wMaxPacketSize. From Bjørn Mork.
6) Missing Kconfig deps for sja1105 driver, from Mao Wenan.
7) Various small fixes to the mlx5 DR steering code, from Alaa Hleihel,
Alex Vesker, and Yevgeny Kliteynik
8) Missing CAP_NET_RAW checks in various places, from Ori Nimron.
9) Fix crash when removing sch_cbs entry while offloading is enabled,
from Vinicius Costa Gomes.
10) Signedness bug fixes, generally in looking at the result given by
of_get_phy_mode() and friends. From Dan Crapenter.
11) Disable preemption around BPF_PROG_RUN() calls, from Eric Dumazet.
12) Don't create VRF ipv6 rules if ipv6 is disabled, from David Ahern.
13) Fix quantization code in tcp_bbr, from Kevin Yang.
* git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (127 commits)
net: tap: clean up an indentation issue
nfp: abm: fix memory leak in nfp_abm_u32_knode_replace
tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state
sk_buff: drop all skb extensions on free and skb scrubbing
tcp_bbr: fix quantization code to not raise cwnd if not probing bandwidth
mlxsw: spectrum_flower: Fail in case user specifies multiple mirror actions
Documentation: Clarify trap's description
mlxsw: spectrum: Clear VLAN filters during port initialization
net: ena: clean up indentation issue
NFC: st95hf: clean up indentation issue
net: phy: micrel: add Asym Pause workaround for KSZ9021
net: socionext: ave: Avoid using netdev_err() before calling register_netdev()
ptp: correctly disable flags on old ioctls
lib: dimlib: fix help text typos
net: dsa: microchip: Always set regmap stride to 1
nfp: flower: fix memory leak in nfp_flower_spawn_vnic_reprs
nfp: flower: prevent memory leak in nfp_flower_spawn_phy_reprs
net/sched: Set default of CONFIG_NET_TC_SKB_EXT to N
vrf: Do not attempt to create IPv6 mcast rule if IPv6 is disabled
net: sched: sch_sfb: don't call qdisc_put() while holding tree lock
...
When CONFIG_UAPI_HEADER_TEST=y, exported headers are compile-tested to
make sure they can be included from user-space.
Currently, linux/netfilter_bridge/ebtables.h is excluded from the test
coverage. To make it join the compile-test, we need to fix the build
errors attached below.
For a case like this, we decided to use __u{8,16,32,64} variable types
in this discussion:
https://lkml.org/lkml/2019/6/5/18
Build log:
CC usr/include/linux/netfilter_bridge/ebtables.h.s
In file included from <command-line>:32:0:
./usr/include/linux/netfilter_bridge/ebtables.h:126:4: error: unknown type name ‘uint8_t’
uint8_t revision;
^~~~~~~
./usr/include/linux/netfilter_bridge/ebtables.h:139:4: error: unknown type name ‘uint8_t’
uint8_t revision;
^~~~~~~
./usr/include/linux/netfilter_bridge/ebtables.h:152:4: error: unknown type name ‘uint8_t’
uint8_t revision;
^~~~~~~
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
The only the difference between clean-files and clean-dirs is the -r
option passed to the 'rm' command.
You can always pass -r, and then remove the clean-dirs syntax.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada changed the zcrypt.h header file to use __u{16,32,64}
instead of uint{16,32,64}_t with ("s390: use __u{16,32,64} instead of
uint{16,32,64}_t in uapi header").
This makes all s390 header files pass - remove zcrypt.h from the blacklist.
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
- Some headers graduated from the blacklist
- hyperv_timer.h joined the header-test when CONFIG_X86=y
- nf_tables*.h joined the header-test when CONFIG_NF_TABLES is
enabled.
- The entry for nf_tables_offload.h was added to fix build error for
the combination of CONFIG_NF_TABLES=n and CONFIG_KERNEL_HEADER_TEST=y.
- The entry for iomap.h was added because this header is supposed to
be included only when CONFIG_BLOCK=y
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Multiple people have suggested compile-testing UAPI headers to ensure
they can be really included from user-space. "make headers_check" is
obviously not enough to catch bugs, and we often leak unresolved
references to user-space.
Use the new header-test-y syntax to implement it. Please note exported
headers are compile-tested with a completely different set of compiler
flags. The header search path is set to $(objtree)/usr/include since
exported headers should not include unexported ones.
We use -std=gnu89 for the kernel space since the kernel code highly
depends on GNU extensions. On the other hand, UAPI headers should be
written in more standardized C, so they are compiled with -std=c90.
This will emit errors if C++ style comments, the keyword 'inline', etc.
are used. Please use C style comments (/* ... */), '__inline__', etc.
in UAPI headers.
There is additional compiler requirement to enable this test because
many of UAPI headers include <stdlib.h>, <sys/ioctl.h>, <sys/time.h>,
etc. directly or indirectly. You cannot use kernel.org pre-built
toolchains [1] since they lack <stdlib.h>.
I reused CONFIG_CC_CAN_LINK to check the system header availability.
The intention is slightly different, but a compiler that can link
userspace programs provide system headers.
For now, a lot of headers need to be excluded because they cannot
be compiled standalone, but this is a good start point.
[1] https://mirrors.edge.kernel.org/pub/tools/crosstool/index.html
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>