Commit graph

1,429,402 commits

Author SHA1 Message Date
Paolo Abeni
0858206732 Just one fix, for a parsing error in mac80211 that might
result in a one byte out-of-bounds read.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEpeA8sTs3M8SN2hR410qiO8sPaAAFAml7Pl0ACgkQ10qiO8sP
 aAAKXA/+P8I3WjVL2QuW0a84VJHxNN398JvOHE68vkWg+HulxDcV/9alCNJAFbYU
 9O9mzNTTH+eW28F4YxIhW86YNnGqkeMy+ZTTdPuSn17WE3OrHubWkdJdqnC3SWb/
 2lYR+BSXLHMTLSFP0olcbUX+WXYHptETxfOX1dpmFZq80wioqs32MPabneGT7vs/
 ENFRK6oT26aouKvGvNa9znqGwVO0rsr3Bmz0N1fgehYhU3YNrqgDH0Lj7Cs5kTOZ
 0QzhZjnIIOXW/3kJNp7Jk7aYW9+9QR6Wo6G5B+wTL/mxZsWhCMxZfqkOm796ktl8
 0OdHOrAD7Fy4w6hPXlUzUHy6kX0lAR1tdk1fE/lNgYyM4WCjvZb0ABP8sncuoEIH
 M2EaDh/drVd/aOU2KQJqvjnG2qlBSK/Gf9hYfBDFpw+GFsOKRowv2o84qnWDGbOw
 rPk8kCz8CFyzUCaF5l0DridPyWu6GEFyAxQ5CDJw8zUu7Mi3PCp9pWCVjAHQPNho
 r7Mao1n0dx4bsiPRZDNfGuymi/MHovRdmPBkdYtMJHYWNAtvDdwu3N50meCA21lM
 kQdY6WMq4dPrqULFW4yfFInTXmkAReHNKVgc49LfSYfrZTyj5ACxgNtELO5GRAgM
 NVGjXfzykOa/GtBTqf+Ob0gDa4mU9QQdRo4DV98cHlKIdZDV0zs=
 =qI59
 -----END PGP SIGNATURE-----

Merge tag 'wireless-2026-01-29' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless

Johannes Berg says:

====================
Just one fix, for a parsing error in mac80211 that might
result in a one byte out-of-bounds read.

* tag 'wireless-2026-01-29' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless:
  wifi: mac80211: correctly decode TTLM with default link map
====================

Link: https://patch.msgid.link/20260129110403.178036-3-johannes@sipsolutions.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-01-29 13:21:35 +01:00
Will Deacon
76e9f683a5 Merge branch 'for-next/selftests' into for-next/core
* for-next/selftests:
  kselftest/arm64: Raise default number of loops in fp-pidbench
  kselftest/arm64: Add a no-SVE loop after SVE in fp-pidbench
  kselftest/arm64: Add missing file in .gitignore
  kselftest/arm64: Add HWCAP test for FEAT_LS64
  kselftest/arm64: Use syscall() macro over nolibc my_syscall()
  kselftest/arm64: Support FORCE_TARGETS
2026-01-29 12:05:49 +00:00
Will Deacon
d4cfa05ac7 Merge branch 'for-next/perf' into for-next/core
* for-next/perf:
  perf/cxlpmu: Replace IRQF_ONESHOT with IRQF_NO_THREAD
  perf/arm_dsu: Allow standard cycles events
  perf/arm_dsu: Support DSU-120
  perf/arm_dsu: Support DSU-110
  drivers: perf: use bitmap_empty() where appropriate
  perf/arm-cmn: Support CMN-600AE
2026-01-29 12:05:45 +00:00
Will Deacon
c96f95bca1 Merge branch 'for-next/misc' into for-next/core
* for-next/misc:
  arm64: mm: warn once for ioremap attempts on RAM mappings
  arm64: Disable branch profiling for all arm64 code
  arm64: kernel: initialize missing kexec_buf->random field
  arm64: simplify arch_uprobe_xol_was_trapped return
2026-01-29 12:05:40 +00:00
Will Deacon
2f8aed5e97 Merge branch 'for-next/errata' into for-next/core
* for-next/errata:
  arm64: errata: Workaround for SI L1 downstream coherency issue
2026-01-29 12:05:33 +00:00
Will Deacon
3aa99d74c8 Merge branch 'for-next/entry' into for-next/core
* for-next/entry:
  arm64/ptrace: Return early for ptrace_report_syscall_entry() error
  arm64/ptrace: Split report_syscall()
  arm64: Remove unused _TIF_WORK_MASK
  arm64: Avoid memcpy() for syscall_get_arguments()
  syscall.h: Remove unused SYSCALL_MAX_ARGS
2026-01-29 12:05:30 +00:00
Will Deacon
c2581836cc Merge branch 'for-next/cpufreq' into for-next/core
* for-next/cpufreq:
  arm64: topology: Do not warn on missing AMU in cpuhp_topology_online()
  arm64: topology: Handle AMU FIE setup on CPU hotplug
  cpufreq: Add new helper function returning cpufreq policy
  arm64: topology: Skip already covered CPUs when setting freq source
2026-01-29 12:05:25 +00:00
Will Deacon
86941154bc Merge branch 'for-next/cpufeature' into for-next/core
* for-next/cpufeature:
  arm64: poe: fix stale POR_EL0 values for ptrace
  arm64: mte: Set TCMA1 whenever MTE is present in the kernel
  arm64: Add support for FEAT_{LS64, LS64_V}
  KVM: arm64: Enable FEAT_{LS64, LS64_V} in the supported guest
  arm64: Provide basic EL2 setup for FEAT_{LS64, LS64_V} usage at EL0/1
  KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory
  KVM: arm64: Add documentation for KVM_EXIT_ARM_LDST64B
  KVM: arm64: Add exit to userspace on {LD,ST}64B* outside of memslots
  arm64: Unconditionally enable PAN support
  arm64: Unconditionally enable LSE support
  arm64: Add support for TSV110 Spectre-BHB mitigation
2026-01-29 12:05:19 +00:00
Will Deacon
3e42a4f5e0 Merge branch 'for-next/acpi' into for-next/core
* for-next/acpi:
  ACPI: AGDI: Add interrupt signaling mode support
  MAINTAINERS: Update the maintainers for ARM64 ACPI
2026-01-29 12:05:12 +00:00
Andy Shevchenko
da0a672268
spi: dw: Remove not-going-to-be-supported code for Baikal SoC
As noticed in the discussion [1] the Baikal SoC and platforms
are not going to be finalized, hence remove stale code.

Link: https://lore.kernel.org/lkml/22b92ddf-6321-41b5-8073-f9c7064d3432@infradead.org/ [1]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260127210541.4068379-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-01-29 11:54:47 +00:00
Maciej Strozek
94e5baff3e
ASoC: sof_sdw: Add a quirk for Lenovo laptop using sidecar amps with cs42l43
Add a quirk for a Lenovo laptop (SSID: 0x17aa3821) to allow using sidecar
CS35L57 amps with CS42L43 codec.

Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260128092410.1540583-1-mstrozek@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-01-29 11:41:54 +00:00
Benjamin Berg
1eab33aa63 wifi: mac80211: correctly decode TTLM with default link map
TID-To-Link Mapping (TTLM) elements do not contain any link mapping
presence indicator if a default mapping is used and parsing needs to be
skipped.

Note that access points should not explicitly report an advertised TTLM
with a default mapping as that is the implied mapping if the element is
not included, this is even the case when switching back to the default
mapping. However, mac80211 would incorrectly parse the frame and would
also read one byte beyond the end of the element.

Reported-by: Ruikai Peng <ruikai@pwno.io>
Closes: https://lore.kernel.org/linux-wireless/CAFD3drMqc9YWvTCSHLyP89AOpBZsHdZ+pak6zVftYoZcUyF7gw@mail.gmail.com
Fixes: 702e80470a ("wifi: mac80211: support handling of advertised TID-to-link mapping")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20260129113349.d6b96f12c732.I69212a50f0f70db185edd3abefb6f04d3cb3e5ff@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-01-29 11:46:43 +01:00
Arnd Bergmann
1b65492f45 Two fixes for the default-settings code for the General-Register-Files,
which sets system defaults for some settings like disabling the automatic
 jtag/sdmmc switching.
 
 One is a corrected register-offset and the other makes the code actually
 look for all matched GRF instances, which it didn't do before.
 -----BEGIN PGP SIGNATURE-----
 
 iQFEBAABCAAuFiEE7v+35S2Q1vLNA3Lx86Z5yZzRHYEFAmlycPAQHGhlaWtvQHNu
 dGVjaC5kZQAKCRDzpnnJnNEdgVlmB/9jID6+y5wY6+8OyTPoh3CJJFcIolUs3ycD
 FPOvKUqgvP8XKGCAuXrAtd4vaEGucCdN/j5vsHi5I8GKyuG9ZJvbpExpzxPPdIIB
 OdU8mWVEiVG94FvFaomFtaLVoK0NiuAUk/WphKrvLDqQ+SVSU6KOev9pK/7NkmxZ
 7yT8NtCm0cul1T8JXpwiXZuTQnu7Bm3Po5NhA7/szBdaxBswT7OaAfA3HMz0+w8l
 KcgAUnlGex54lTW9coKSHTRz1HZUrhvj3YnMY3F9PRlZtsHJSBteuFBTe2yJqyjg
 xUTaxqcRwMiUapTgDpUvfp3ltry9L1/IkZ4R2049oJ7Z71iM1Rsr
 =lx0C
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAml7NZ8ACgkQmmx57+YA
 GNnQ+xAApxezQ4PhoOJ4LvVwcXxJbwXk/est1f7KL2TZ9Aw+C9FV5+k7cvK4QJ8z
 zCbd1g1i0LRZxjRLZctZeC0dHJpfCVYPha6/lFVoJVlC6SvkQQraOdnb9mGCSbOV
 RetWQD6iVYHWPbLHyGbDv5o+bKoSNBBH+jDBBiLwctCkmsDFchrJjYOwh7obAtLI
 mcS74v1c0qEC3HWfxtMcreHA/IY84a/Xmk9PvRq2OXiC5fi0UrfEp3housLyVUs4
 x4+52BxrIczO2gr7cNPQk0L2YaCHP/BkglKV9kqZKkYk8scNxV3vgCm7hy2GdxhY
 gryZADFxm2yqJ7OgN57keUdUk+8cL8WQ0z4ynHHHx4TMppVAmx1lwE/kjJF+7D81
 p4aA15fQgEfBaojHXr8qYrzmZEBsLcXteOgv3yL7Asig0zGu2WB3cyG6aQpMBvdu
 i6eCtxqORyyCipDu8l/6kzu/5ecPUGvYukHa6EWxqbw6gp+HXMSdi0J00Ggxi3Fk
 3zrQORJBLwVwrwuoSiBcKg8lCSUeYjuT/ZUI3zEDSsRBCyB9pfMwEfZzBj0r7HV3
 1IBu6b5chicJ4IrcYhqiiVbftkl0BdgCxtzuHWtEzNWqPurUi3NNKGXczsWmi/CB
 k0jlCwY5QQy1VX5X5gypImlaQo4ktVrC4nJgJu2o5LRHkWx00rs=
 =pe+r
 -----END PGP SIGNATURE-----

Merge tag 'v6.20-rockchip-drivers1' of https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into soc/drivers

Two fixes for the default-settings code for the General-Register-Files,
which sets system defaults for some settings like disabling the automatic
jtag/sdmmc switching.

One is a corrected register-offset and the other makes the code actually
look for all matched GRF instances, which it didn't do before.

* tag 'v6.20-rockchip-drivers1' of https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip:
  soc: rockchip: grf: Support multiple grf to be handled
  soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-29 11:25:29 +01:00
Arnd Bergmann
1918a0d574 mvebu arm for 6.20 (part 1)
Simplify Dove PMU OF child node iteration with scoped loops
 -----BEGIN PGP SIGNATURE-----
 
 iF0EABECAB0WIQQYqXDMF3cvSLY+g9cLBhiOFHI71QUCaXOp4wAKCRALBhiOFHI7
 1WGtAJ96an/I+sIvtz3FvPaWoaDoGHB1jACgjpvvq3VzNZt8UVlAxoVEUHaZFN4=
 =LLOa
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAml7NXQACgkQmmx57+YA
 GNnT8g/7B15yhpfbVBdkp/WmK7ezOelI4u5YhbxU39LtHvFcEQWc+i25ZGs5fiBP
 0bgExDBjH6gGKmXC+0S5vZz4mZbdyunbcJzUqz3b8hLZl2t4sE6TZAgxKBPxVjrh
 1qQMAAVyIy3AGWLdN/do5Sk/1z9unojMOdXHBYDnVBoAE/5hD2YnQOyIZV8k4OKI
 DOroEFk/XkaGWf9q2POMhbIT8JufVACPWtDVumdregPY3ZSflSAjFw38JxU8hyFJ
 T2zxjLG0gvkhLxZyFaelMfk2QZCxfeVNXqR5SYFJGCXhQ8hIrObyaAzkUVEVvRu7
 AQetV6/F22FDC95TjWS8VXQgXg6zUsgyHqS92Xkdl0gEl8wbuDYOC8tLKEKboU8p
 nTpv9BtIu267Ops46M0e2lFQMvbQI+8IoksKhIAA7NydQKQVpcLueldnl8T7om6f
 6iyg9Zm3Ti2+wOjunbL4N885Sxvor4f9qHT8Z2Ht+vjf8XtEwWWKDDHAOGHYDead
 wvrhCOzn7sKHtSmr9zsLOxD73GTKDVi+4pfKxDxLcjGPXfw1ZOZhTVTfWIOHMj+l
 2HpJmCQI1K3Okoh2LLg2TFPHCak6TKnmCcMo1lLMtyafqkc7321cPrw1t7KzjPfD
 2Zlu6mEQxgqcAbnmVLR51+NPsvVjNF49nqJnt21VbKWqn67csyk=
 =qFRc
 -----END PGP SIGNATURE-----

Merge tag 'mvebu-arm-6.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/gclement/mvebu into soc/drivers

mvebu arm for 6.20 (part 1)

Simplify Dove PMU OF child node iteration with scoped loops

* tag 'mvebu-arm-6.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/gclement/mvebu:
  soc: dove: pmu: Simplify with scoped for each OF child loop

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-29 11:23:07 +01:00
Arnd Bergmann
0a82d3d407 TI K3 device tree updates for v6.20
Generic Fixes/Cleanups:
 - Minor whitespace cleanup and lowercase hex formatting for consistency
 - Various DT schema warning fixes across multiple boards
 
 SoC Specific Features and Fixes:
 AM62P/J722S:
 - Add HSM M4F node for hardware security module support
 
 J784S4/J742S2/J721S2:
 - Add HSM M4F node for hardware security module support
 - Refactor watchdog instances for j784s4
 - Move c71_3 node to appropriate order in device tree
 
 Board Specific Fixes:
 AM62:
 - phycore-som: Add bootphase tags to cpsw_mac_syscon and phy_gmii_sel
 
 AM62A:
 - phycore-som: Add bootphase tags to cpsw_mac_syscon and phy_gmii_sel
 
 AM62P:
 - Verdin: Fix SD regulator startup delay
 
 AM67A:
 - Kontron SA67: Fix CMA node and SD card regulator configuration
 
 AM69:
 - Aquila: Change main_spi0/2 chip select to GPIO mode
 - Aquila-clover: Change main_spi2 CS0 to GPIO mode
 - Aquila-dev/clover: Fix USB-C Sink PDO configuration
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE+KKGk1TrgjIXoxo03bWEnRc2JJ0FAmlvjOMACgkQ3bWEnRc2
 JJ0BZg//RZjUiSLGtNuv964SKkrvzpEfz4w/FKdy59unL4DzLMv2RzGrmFZMNiVj
 fYzUsLsJV85m0IKvmfj6TSnToDpfCxyyxvbr2OaII6w41D6d6xSrbjAAYrtfzU0x
 J+dnhVAeof/x+1YxSsTYapHCA/mF30gvoNT9UuBQTZgjbD2YjeVa3H3qAX67NxbM
 POqq80vJV+0MKSiei01KJLxl5P5RGoECiOMgUiWQeT6xaOyAuit8xLpQNoWLe+xU
 wwyO2hh70GVl2BB+pKoo64IIqk749Rcz72mwN009bsp8gs2vXFkeN16V+FZOKBRX
 98SnTNzwmuEe6jKn4Bb31R+5gW+0VFNpT35KmINcvLdioDJAZHiJf/sfT7E8eIfR
 ahKcB/D4yhoGxYBvzJgwXAyHFn76ZlQWY+UyzXvNr0L2anFg8YRMcAs4ZBoHIn0R
 B+DGb81V3ckabghXCraYLvhT8WwpWndaXv7i2urhkdKURR9BTBlt1ihwk/wEfAP6
 nw3nFlE4oqQfl9kHeUxs7d/JNJaQm1/DyPgxO5/pOFpLPW987O5UwLoMSpMwAE9I
 ET7QfoJ3cL0m47HHkJNbCn2ulQl53db3GhE8oeNFmHrCBCVOyadhKrJuR2MNDiy3
 LgRjyD/faS6PDprk8n7+daDczO/+k+hYRON/jAfhtLdxoRyFu4I=
 =Xr4O
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAml7MugACgkQmmx57+YA
 GNmswg/7BlnGZQ249UuKVemWYwuiG9e6fBU7nox9MB6Lt46ZNp5/ln/H/in6IXVi
 IMum69rPraj8WfAUA2Xph0/ePzeFBvWwuhuMY74twDHkWgnLI/WxkCVizqhpOKxU
 sIC8LBm3GtGrbFuxAqn9wU0yYSK6iVlJcI3jmASvg8PHJmgFF4bKmllpI58iJwDE
 HSFHKdxzGOqDrPb70XyHodEiMND8K9VfihToGB1ekG+lhnlGNlTF8XchW0V2cAd5
 XiNBhR6kVb/t3+Ck6ASDtrZxqfEi4fwos0QpYdLeiRwjtnBaZ3ZPdDw5DYBlkRR8
 p9pJvkMiDviSl0siGm0khXb3pWLgIAGn7QarGAOPy3mZhAOpIgfTQjhcpuqE/te5
 M/ZK8QLaxRTKQyRlsmK9UGnGj9FArkcRFY2MvFxdmwVw+/0X3ip+bEwedYxnspRX
 MdAmh5bOFWLno5kOwfeqCaujyhbXjXUTdLj0izkjc6KnZNYJNz1q7qiE7ou3oNQ5
 cnuxh7jWDecVUm5UnW9Sd0zqZNlKfPzv5Uj0yyvW98UUwD6Kkgo2XD+0a2S918fJ
 lgv5OarO2WhCozSVbRio32pF19Oa9XFGkteYSwNQ3qfl4K6OXOwjMlNOFlM8XICu
 pEq1Ak4TmY6Beh20X7E+ZtndZw2ZVcXaCHQE6BNqwvt8UKVFiLI=
 =q468
 -----END PGP SIGNATURE-----

Merge tag 'ti-k3-dt-for-v6.20' of https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux into soc/dt

TI K3 device tree updates for v6.20

Generic Fixes/Cleanups:
- Minor whitespace cleanup and lowercase hex formatting for consistency
- Various DT schema warning fixes across multiple boards

SoC Specific Features and Fixes:
AM62P/J722S:
- Add HSM M4F node for hardware security module support

J784S4/J742S2/J721S2:
- Add HSM M4F node for hardware security module support
- Refactor watchdog instances for j784s4
- Move c71_3 node to appropriate order in device tree

Board Specific Fixes:
AM62:
- phycore-som: Add bootphase tags to cpsw_mac_syscon and phy_gmii_sel

AM62A:
- phycore-som: Add bootphase tags to cpsw_mac_syscon and phy_gmii_sel

AM62P:
- Verdin: Fix SD regulator startup delay

AM67A:
- Kontron SA67: Fix CMA node and SD card regulator configuration

AM69:
- Aquila: Change main_spi0/2 chip select to GPIO mode
- Aquila-clover: Change main_spi2 CS0 to GPIO mode
- Aquila-dev/clover: Fix USB-C Sink PDO configuration

* tag 'ti-k3-dt-for-v6.20' of https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux:
  arm64: dts: ti: k3-am67a-kontron-sa67-base: Fix SD card regulator
  arm64: dts: ti: k3-am67a-kontron-sa67-base: Fix CMA node
  arm64: dts: ti: k3-am62p-j722s-common-main: Add HSM M4F node
  arm64: dts: ti: k3-{j784s4-j742s2/j721s2}-mcu-wakeup: Add HSM M4F node
  arm64: dts: ti: k3-j784s4-j742s2-main-common.dtsi: Refactor watchdog instances for j784s4
  arm64: dts: ti: k3-j784s4-main.dtsi: Move c71_3 node to appropriate order
  arm64: dts: ti: k3-am69-aquila-clover: Change main_spi2 CS0 to GPIO mode
  arm64: dts: ti: k3-am69-aquila: Change main_spi0/2 CS to GPIO mode
  arm64: dts: ti: Use lowercase hex
  arm64: dts: ti: Minor whitespace cleanup
  arm64: dts: ti: am62p-verdin: Fix SD regulator startup delay
  arm64: dts: ti: k3-am69-aquila-clover: Fix USB-C Sink PDO
  arm64: dts: ti: k3-am69-aquila-dev: Fix USB-C Sink PDO
  arm64: dts: ti: k3-am62(a)-phycore-som: Add bootphase tag to phy_gmii_sel
  arm64: dts: ti: k3-am62a-phycore-som: Add bootphase tag to cpsw_mac_syscon
  arm64: dts: ti: k3-am62-phycore-som: Add bootphase tag to cpsw_mac_syscon
  arm64: dts: ti: k3-am62-lp-sk-nand: Rename pinctrls to fix schema warnings
  arm64: dts: ti: k3-am642-phyboard-electra-x27-gpio1-spi1-uart3: Fix schema warnings
  arm64: dts: ti: k3-am642-phyboard-electra-peb-c-010: Fix icssg-prueth schema warning

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-29 11:13:50 +01:00
Shin Seong-jun
0ead3b7246 xfs: fix spacing style issues in xfs_alloc.c
Fix checkpatch.pl errors regarding missing spaces around assignment
operators in xfs_alloc_compute_diff() and xfs_alloc_fixup_trees().

Adhere to the Linux kernel coding style by ensuring spaces are placed
around the assignment operator '='.

Signed-off-by: Shin Seong-jun <shinsj4653@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
2026-01-29 10:57:18 +01:00
Christoph Hellwig
7da4ebea83 xfs: remove xfs_zone_gc_space_available
xfs_zone_gc_space_available only has one caller left, so fold it into
that.  Reorder the checks so that the cheaper scratch_available check
is done first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
2026-01-29 10:57:18 +01:00
Christoph Hellwig
c17a1c0349 xfs: use a seprate member to track space availabe in the GC scatch buffer
When scratch_head wraps back to 0 and scratch_tail is also 0 because no
I/O has completed yet, the ring buffer could be mistaken for empty.

Fix this by introducing a separate scratch_available member in
struct xfs_zone_gc_data.  This actually ends up simplifying the code as
well.

Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
2026-01-29 10:57:18 +01:00
Ilya Mamay
8cdb04bd06 riscv: ptrace: return ENODATA for inactive vector extension
Currently, ptrace returns EINVAL when the vector extension is supported
but not yet activated for the traced process. This error code is not
always appropriate since the ptrace arguments may be valid.

Debug tools like gdbserver expect ENODATA when the requested register
set is not active, e.g. see [1]. This expectation seems to be more
appropriate, so modify the vector ptrace implementation to return:
- EINVAL when V extension is not supported
- ENODATA when V extension is supported but not active

[1] 637f25e886/gdbserver/linux-low.cc (L5020)

Signed-off-by: Ilya Mamay <mmamayka01@gmail.com>
Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
Reviewed-by: Andy Chiu <andybnac@gmail.com>
Tested-by: Andy Chiu <andybnac@gmail.com>
Link: https://patch.msgid.link/20251214163537.1054292-2-geomatsi@gmail.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
d30c1683aa kselftest/riscv: add kselftest for user mode CFI
Add a kselftest for RISC-V control flow integrity implementation for
user mode. There is not a lot going on in the kernel to enable landing
pad for user mode. CFI selftests are intended to be compiled with a
zicfilp and zicfiss enabled compiler. This kselftest simply checks if
landing pads and shadow stacks for the process are enabled or not and
executes ptrace selftests on CFI. The selftest then registers a
SIGSEGV signal handler.  Any control flow violations are reported as
SIGSEGV with si_code = SEGV_CPERR.  The test will fail on receiving
any SEGV_CPERR. The shadow stack part has more changes in the kernel,
and thus there are separate tests for that.

- Exercise 'map_shadow_stack' syscall
- 'fork' test to make sure COW works for shadow stack pages
- gup tests
  Kernel uses FOLL_FORCE when access happens to memory via
  /proc/<pid>/mem. Not breaking that for shadow stack.
- signal test. Make sure signal delivery results in token creation on
  shadow stack and consumes (and verifies) token on sigreturn
- shadow stack protection test. attempts to write using regular store
  instruction on shadow stack memory must result in access faults
- ptrace test: adds landing pad violation, clears ELP and continues

In case the toolchain doesn't support the CFI extension, the CFI
kselftest won't be built.

Test output
===========

"""
TAP version 13
1..5
  This is to ensure shadow stack is indeed enabled and working
  This is to ensure shadow stack is indeed enabled and working
ok 1 shstk fork test
ok 2 map shadow stack syscall
ok 3 shadow stack gup tests
ok 4 shadow stack signal tests
ok 5 memory protections of shadow stack memory
"""

Suggested-by: Charlie Jenkins <charlie@rivosinc.com>
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-28-b55691eacf4f@rivosinc.com
[pjw@kernel.org: updated to apply; cleaned up patch description, code comments]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
c8350aa2ed riscv: add documentation for shadow stack
Add documentation on shadow stack for user mode on riscv and the kernel
interfaces exposed for user tasks to enable it.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-27-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up the documentation, patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
f6eeb67b91 riscv: add documentation for landing pad / indirect branch tracking
Add documentation on landing pad aka indirect branch tracking on riscv
and the kernel interfaces exposed for user tasks to enable it.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-26-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up the documentation]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
22c1e263af riscv: create a Kconfig fragment for shadow stack and landing pad support
This patch creates a Kconfig fragment for shadow stack support and
landing pad instruction support. Shadow stack support and landing pad
instruction support can be enabled by selecting
'CONFIG_RISCV_USER_CFI'. Selecting 'CONFIG_RISCV_USER_CFI' wires up
the path to enumerate CPU support.  If support exists, the kernel will
support CPU-assisted user mode CFI.

If CONFIG_RISCV_USER_CFI is selected, select 'ARCH_USES_HIGH_VMA_FLAGS',
'ARCH_HAS_USER_SHADOW_STACK' and 'DYNAMIC_SIGFRAME' for riscv.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-25-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description, Kconfig text; added CONFIG_MMU exclusion]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
ccad8c1336 arch/riscv: add dual vdso creation logic and select vdso based on hw
Shadow stack instructions are taken from the Zimop ISA extension,
which is mandated on RVA23. Any userspace with shadow stack
instructions in it will fault on hardware that doesn't have support
for Zimop.  Thus, a shadow stack-enabled userspace can't be run on
hardware that doesn't support Zimop.

It's not known how Linux userspace providers will respond to this kind
of binary fragmentation.  In order to keep kernel portable across
different hardware, 'arch/riscv/kernel/vdso_cfi' is created which has
Makefile logic to compile 'arch/riscv/kernel/vdso' sources with CFI
flags, and 'arch/riscv/kernel/vdso.c' is modified to select the
appropriate vdso depending on whether the underlying CPU implements
the Zimop extension. Since the offset of vdso symbols will change due
to having two different vdso binaries, there is added logic to include
a new generated vdso offset header and dynamically select the offset
(like for rt_sigreturn).

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Acked-by: Charles Mirabile <cmirabil@redhat.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-24-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Jim Shu
37f57bd3fa arch/riscv: compile vdso with landing pad and shadow stack note
User mode tasks compiled with Zicfilp may call indirectly into the
vdso (like hwprobe indirect calls). Add support for compiling landing
pads into the vdso. Landing pad instructions in the vdso will be
no-ops for tasks which have not enabled landing pads. Furthermore, add
support for the C sources of the vdso to be compiled with shadow stack
and landing pads enabled as well.

Landing pad and shadow stack instructions are emitted only when the
VDSO_CFI cflags option is defined during compile.

Signed-off-by: Jim Shu <jim.shu@sifive.com>
Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-23-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description, issues reported by checkpatch]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
41213bf2ae riscv: enable kernel access to shadow stack memory via the FWFT SBI call
The kernel has to perform shadow stack operations on the user shadow stack.
During signal delivery and sigreturn, the shadow stack token must be
created and validated respectively. Thus shadow stack access for the kernel
must be enabled.

In the future, when kernel shadow stacks are enabled, they must be
enabled as early as possible for better coverage and to prevent any
imbalance between the regular stack and the shadow stack. After
'relocate_enable_mmu' has completed, this is the earliest that it can
be enabled.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-22-b55691eacf4f@rivosinc.com
[pjw@kernel.org: updated to apply; cleaned up commit message]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
c9b859c4d8 riscv: add kernel command line option to opt out of user CFI
Add a kernel command line option to disable part or all
of user CFI.  User backward CFI and forward CFI can be controlled
independently.  The kernel command line parameter "riscv_nousercfi" can
take the following values:
 - "all" : Disable forward and backward cfi both
 - "bcfi" : Disable backward cfi
 - "fcfi" : Disable forward cfi

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-21-b55691eacf4f@rivosinc.com
[pjw@kernel.org: fixed warnings from checkpatch; cleaned up patch description, doc, printk text]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
30c3099036 riscv/hwprobe: add zicfilp / zicfiss enumeration in hwprobe
Add enumeration of the zicfilp and zicfiss extensions in the hwprobe syscall.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-20-b55691eacf4f@rivosinc.com
[pjw@kernel.org: updated to apply; extend into RISCV_HWPROBE_KEY_IMA_EXT_1; clean patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Paul Walmsley
462a94fb8a riscv: hwprobe: add support for RISCV_HWPROBE_KEY_IMA_EXT_1
We've run out of bits to describe RISC-V ISA extensions in our initial
hwprobe key, RISCV_HWPROBE_KEY_IMA_EXT_0.  So, let's add
RISCV_HWPROBE_KEY_IMA_EXT_1, along with the framework to set the
appropriate hwprobe tuple, and add testing for it.

Based on a suggestion from Andrew Jones <andrew.jones@oss.qualcomm.com>,
also fix the documentation for RISCV_HWPROBE_KEY_IMA_EXT_0.

Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
2af7c9cf02 riscv/ptrace: expose riscv CFI status and state via ptrace and in core files
Expose a new register type NT_RISCV_USER_CFI for risc-v CFI status and
state. Intentionally, both landing pad and shadow stack status and
state are rolled into the CFI state. Creating two different
NT_RISCV_USER_XXX would not be useful and would waste a note
type. Enabling, disabling and locking the CFI feature is not allowed
via ptrace set interface. However, setting 'elp' state or setting
shadow stack pointer are allowed via the ptrace set interface.  It is
expected that 'gdb' might need to fixup 'elp' state or 'shadow stack'
pointer.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-19-b55691eacf4f@rivosinc.com
[pjw@kernel.org: updated to apply; cleaned patch description and comments; addressed checkpatch issues]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
9d0e75e25e riscv/kernel: update __show_regs() to print shadow stack register
Update __show_regs() to print the captured shadow stack pointer.  On
tasks where shadow stack is disabled, simply print 0.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-18-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
66c9c713de riscv/signal: save and restore the shadow stack on a signal
Save the shadow stack pointer in the sigcontext structure when
delivering a signal.  Restore the shadow stack pointer from sigcontext
on sigreturn.

As part of the save operation, the kernel uses the 'ssamoswap'
instruction to save a snapshot of the current shadow stack on the
shadow stack itself (this can be called a "save token"). During
restore on sigreturn, the kernel retrieves the save token from the top
of the shadow stack and validates it. This ensures that user mode
can't arbitrarily pivot to any shadow stack address without having a
token and thus provides a strong security assurance during the window
between signal delivery and sigreturn.

Use an ABI-compatible way of saving/restoring the shadow stack pointer
into the signal stack. This follows the vector extension, where extra
registers are placed in a form of extension header + extension body in
the stack.  The extension header indicates the size of the extra
architectural states plus the size of header itself, and a magic
identifier for the extension. Then, the extension body contains the
new architectural states in the form defined by uapi.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de>
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-17-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned patch description, code comments; resolved checkpatch warning]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
9d42fc28fc riscv/traps: Introduce software check exception and uprobe handling
The Zicfiss and Zicfilp extensions introduce a new exception, the
'software check exception', in the privileged ISA, with cause code =
18. This patch implements support for software check exceptions.

Additionally, the patch implements a CFI violation handler which
checks the code in the xtval register. If xtval=2, the software check
exception happened because of an indirect branch that didn't land on a
4 byte aligned PC or on a 'lpad' instruction, or the label value
embedded in 'lpad' didn't match the label value set in the x7
register. If xtval=3, the software check exception happened due to a
mismatch between the link register (x1 or x5) and the top of shadow
stack (on execution of `sspopchk`).

In case of a CFI violation, SIGSEGV is raised with code=SEGV_CPERR.
SEGV_CPERR was introduced by the x86 shadow stack patches.

To keep uprobes working, handle the uprobe event first before
reporting the CFI violation in the software check exception
handler. This is because, when the landing pad is activated, if the
uprobe point is set at the lpad instruction at the beginning of a
function, the system triggers a software check exception instead of an
ebreak exception due to the exception priority.  This would prevent
uprobe from working.

Reviewed-by: Zong Li <zong.li@sifive.com>
Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-15-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up the patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
8a9e22d2ca riscv: Implement indirect branch tracking prctls
This patch adds a RISC-V implementation of the following prctls:
PR_SET_INDIR_BR_LP_STATUS, PR_GET_INDIR_BR_LP_STATUS and
PR_LOCK_INDIR_BR_LP_STATUS.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de>
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-14-b55691eacf4f@rivosinc.com
[pjw@kernel.org: clean up patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:38:40 -07:00
Deepak Gupta
5ca243f6e3 prctl: add arch-agnostic prctl()s for indirect branch tracking
Three architectures (x86, aarch64, riscv) have support for indirect
branch tracking feature in a very similar fashion. On a very high
level, indirect branch tracking is a CPU feature where CPU tracks
branches which use a memory operand to transfer control. As part of
this tracking, during an indirect branch, the CPU expects a landing
pad instruction on the target PC, and if not found, the CPU raises
some fault (architecture-dependent).

x86 landing pad instr - 'ENDBRANCH'
arch64 landing pad instr - 'BTI'
riscv landing instr - 'lpad'

Given that three major architectures have support for indirect branch
tracking, this patch creates architecture-agnostic 'prctls' to allow
userspace to control this feature.  They are:
 - PR_GET_INDIR_BR_LP_STATUS: Get the current configured status for indirect
   branch tracking.
 - PR_SET_INDIR_BR_LP_STATUS: Set the configuration for indirect branch
   tracking.
   The following status options are allowed:
       - PR_INDIR_BR_LP_ENABLE: Enables indirect branch tracking on user
         thread.
       - PR_INDIR_BR_LP_DISABLE: Disables indirect branch tracking on user
         thread.
 - PR_LOCK_INDIR_BR_LP_STATUS: Locks configured status for indirect branch
   tracking for user thread.

Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-13-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description, code comments]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:36:32 -07:00
Deepak Gupta
61a0200211 riscv: Implement arch-agnostic shadow stack prctls
Implement an architecture-agnostic prctl() interface for setting and
getting shadow stack status.  The prctls implemented are
PR_GET_SHADOW_STACK_STATUS, PR_SET_SHADOW_STACK_STATUS and
PR_LOCK_SHADOW_STACK_STATUS.

As part of PR_SET_SHADOW_STACK_STATUS/PR_GET_SHADOW_STACK_STATUS, only
PR_SHADOW_STACK_ENABLE is implemented because RISCV allows each mode to
write to their own shadow stack using 'sspush' or 'ssamoswap'.

PR_LOCK_SHADOW_STACK_STATUS locks the current shadow stack enablement
configuration.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-12-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:34:39 -07:00
Deepak Gupta
fd44a4a855 riscv/shstk: If needed allocate a new shadow stack on clone
Userspace specifies CLONE_VM to share address space and spawn new
thread.  'clone' allows userspace to specify a new stack for a new
thread. However there is no way to specify a new shadow stack base
address without changing the API. This patch allocates a new shadow
stack whenever CLONE_VM is given.

In case of CLONE_VFORK, the parent is suspended until the child
finishes; thus the child can use the parent's shadow stack. In case of
!CLONE_VM, COW kicks in because entire address space is copied from
parent to child.

'clone3' is extensible and can provide mechanisms for specifying the
shadow stack as an input parameter. This is not settled yet and is
being extensively discussed on the mailing list. Once that's settled,
this code should be adapted.

Reviewed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-11-b55691eacf4f@rivosinc.com
[pjw@kernel.org: cleaned up patch description]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-01-29 02:34:21 -07:00
John Johansen
859b725579 apparmor: cleanup remove unused percpu critical sections in buffer management
There are two unused percpu critical sections in the buffer management
code. These are remanents from when a more complex hold algorithm was
used. Remove them, as they serve no purpose.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:55 -08:00
John Johansen
0b6a6b72b3 apparmor: document the buffer hold, add an overflow guard
The buffer hold is a measure of contention, but it is tracked per cpu
where the lock is a globabl resource. On some systems (eg. real time)
there is no guarantee that the code will be on the same cpu pre, and
post spinlock acquisition, nor that the buffer will be put back to
the same percpu cache when we are done with it.

Because of this the hold value can move asynchronous to the buffers on
the cache, meaning it is possible to underflow, and potentially in really
pathelogical cases overflow.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:55 -08:00
Zhengmian Hu
640cf2f095 apparmor: avoid per-cpu hold underflow in aa_get_buffer
When aa_get_buffer() pulls from the per-cpu list it unconditionally
decrements cache->hold. If hold reaches 0 while count is still non-zero,
the unsigned decrement wraps to UINT_MAX. This keeps hold non-zero for a
very long time, so aa_put_buffer() never returns buffers to the global
list, which can starve other CPUs and force repeated kmalloc(aa_g_path_max)
allocations.

Guard the decrement so hold never underflows.
Fixes: ea9bae12d0 ("apparmor: cache buffers on percpu list if there is lock contention")

Signed-off-by: Zhengmian Hu <huzhengmian@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:55 -08:00
John Johansen
796c146fa6 apparmor: split xxx_in_ns into its two separate semantic use cases
This patch doesn't change current functionality, it switches the two
uses of the in_ns fns and macros into the two semantically different
cases they are used for.

xxx_in_scope for checking mediation interaction between profiles
xxx_in_view to determine which profiles are visible.The scope will
always be a subset of the view as profiles that can not see each
other can not interact.

The split can not be completely done for label_match because it has to
distinct uses matching permission against label in scope, and checking
if a transition to a profile is allowed. The transition to a profile
can include profiles that are in view but not in scope, so retain this
distinction as a parameter.

While at the moment the two uses are very similar, in the future there
will be additional differences. So make sure the semantics differences
are present in the code.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:55 -08:00
John Johansen
a4c9efa4db apparmor: make label_match return a consistent value
compound match is inconsistent in returning a state or an integer error
this is problemati if the error is ever used as a state in the state
machine

Fixes: f1bd904175 ("apparmor: add the base fns() for domain labels")
Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:55 -08:00
John Johansen
b2e27be294 apparmor: remove apply_modes_to_perms from label_match
The modes shouldn't be applied at the point of label match, it just
results in them being applied multiple times. Instead they should be
applied after which is already being done by all callers so it can
just be dropped from label_match.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
John Johansen
9f79b1cee9 apparmor: fix fast path cache check for unix sockets
The fast path cache check is incorrect forcing more slow path
revalidations than necessary, because the unix logic check is inverted.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
John Johansen
6ca56813f4 apparmor: fix rlimit for posix cpu timers
Posix cpu timers requires an additional step beyond setting the rlimit.
Refactor the code so its clear when what code is setting the
limit and conditionally update the posix cpu timers when appropriate.

Fixes: baa73d9e47 ("posix-timers: Make them configurable")
Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
John Johansen
acf2a94ac4 apparmor: refactor/cleanup cred helper fns.
aa_cred_raw_label() and cred_label() now do the same things so
consolidate to cred_label()

Document the crit section use and constraints better and refactor
__begin_current_label_crit_section() into a base fn
__begin_cred_crit_section() and a wrapper that calls the base with
current cred.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
John Johansen
1301b95619 apparmor: fix label and profile debug macros
The label and profile debug macros were not correctly pasting their
var args.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
John Johansen
4a134723f9 apparmor: move check for aa_null file to cover all cases
files with a dentry pointing aa_null.dentry where already rejected as
part of file_inheritance. Unfortunately the check in
common_file_perm() is insufficient to cover all cases causing
unnecessary audit messages without the original files context.

Eg.
[ 442.886474] audit: type=1400 audit(1704822661.616:329): apparmor="DENIED" operation="file_inherit" class="file" namespace="root//lxd-juju-98527a-0_<var-snap-lxd-common-lxd>" profile="snap.lxd.activate" name="/apparmor/.null" pid=9525 comm="snap-exec"

Further examples of this are in the logs of
https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2120439
https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1952084
https://bugs.launchpad.net/snapd/+bug/2049099

These messages have no value and should not be sent to the logs.
AppArmor was already filtering the out in some cases but the original
patch did not catch all cases. Fix this by push the existing check
down into two functions that should cover all cases.

Link: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2122743
Fixes: 192ca6b55a ("apparmor: revalidate files during exec")
Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
John Johansen
e16eee7895 apparmor: guard against free routines being called with a NULL
aa_free_data() and free_attachment() don't guard against having
a NULL parameter passed to them. Fix this.

Reviewed-by: Ryan Lee <ryan.lee@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00
Ryan Lee
74b7105e53 apparmor: return -ENOMEM in unpack_perms_table upon alloc failure
In policy_unpack.c:unpack_perms_table, the perms struct is allocated via
kcalloc, with the position being reset if the allocation fails. However,
the error path results in -EPROTO being retured instead of -ENOMEM. Fix
this to return the correct error code.

Reported-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Fixes: fd1b2b95a2 ("apparmor: add the ability for policy to specify a permission table")
Reviewed-by: Tyler Hicks <code@tyhicks.com>
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2026-01-29 01:27:54 -08:00