5.15.221-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 805/935 selftests/bpf: Fix vmtest.sh getopts optstring
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Xu <[email protected]>
[ Upstream commit a7be0ab1eb1949f3564739784b4360e1233305f6 ]
Before, you could see the following errors:
$ ./vmtest.sh -j ./vmtest.sh: option requires an argument -- j ./vmtest.sh: line 357: OPTARG: unbound variable
$ ./vmtest.sh -z ./vmtest.sh: illegal option -- z ./vmtest.sh: line 357: OPTARG: unbound variable
Fix by adding ':' as first character of optstring. Reason is that getopts requires ':' as the first character for OPTARG to be set in the ? and : error cases.
Note that the ':' as the first character of the optstring switches getopts to silent mode. The desire to run in this mode seems to have been there all along, as the script takes care of reporting errors.
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/vmtest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/vmtest.sh +1 -1
@@ -304,7 +304,7 @@ main() local exit_command="poweroff -f" local debug_shell="no" - while getopts 'hskid:j:' opt; do + while getopts ':hskid:j:' opt; do case ${opt} in i) update_image="yes"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 806/935 selftests/bpf: Limit URLS parsing logic to actual scope in vmtest
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 0c3fc330be6d85febd0f68b66c657c752e9cd63c ]
The URLS array is only valid in the download_rootfs function and does not need to be parsed globally in advance. At the same time, the logic of loading rootfs is refactored to prepare vmtest for supporting local rootfs.
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/vmtest.sh | 39 +++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-)
tools/testing/selftests/bpf/vmtest.sh +19 -20
@@ -85,19 +85,6 @@ populate_url_map() fi } -download() -{ - local file="$1" - - if [[ ! -v URLS[$file] ]]; then - echo "$file not found" >&2 - return 1 - fi - - echo "Downloading $file..." >&2 - curl -Lsf "${URLS[$file]}" "${@:2}" -} - newest_rootfs_version() { {
@@ -111,16 +98,30 @@ newest_rootfs_version() download_rootfs() { - local rootfsversion="$1" - local dir="$2" + populate_url_map + + local rootfsversion="$(newest_rootfs_version)" + local file="${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" + + if [[ ! -v URLS[$file] ]]; then + echo "$file not found" >&2 + return 1 + fi + + echo "Downloading $file..." >&2 + curl -Lsf "${URLS[$file]}" "${@:2}" +} + +load_rootfs() +{ + local dir="$1" if ! which zstd &> /dev/null; then echo 'Could not find "zstd" on the system, please install zstd' exit 1 fi - download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | - zstd -d | sudo tar -C "$dir" -x + download_rootfs | zstd -d | sudo tar -C "$dir" -x } recompile_kernel()
@@ -220,7 +221,7 @@ create_vm_image() mkfs.ext4 -q "${rootfs_img}" mount_image - download_rootfs "$(newest_rootfs_version)" "${mount_dir}" + load_rootfs "${mount_dir}" unmount_image }
@@ -363,8 +364,6 @@ main() make_command="${make_command} KBUILD_OUTPUT=${KBUILD_OUTPUT}" fi - populate_url_map - local rootfs_img="${OUTPUT_DIR}/${ROOTFS_IMAGE}" local mount_dir="${OUTPUT_DIR}/${MOUNT_DIR}"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 807/935 selftests/bpf: Support local rootfs image for vmtest
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 2294073dce32af8535e9d4a32e1efdeea35c1786 ]
Support vmtest to use local rootfs image generated by [0] that is consistent with BPF CI. Now we can specify the local rootfs image through the -l parameter like as follows:
vmtest.sh -l ./libbpf-vmtest-rootfs-2024.08.22-noble-amd64.tar.zst -- ./test_progs
Meanwhile, some descriptions have been flushed.
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/README.rst | 2 -- tools/testing/selftests/bpf/vmtest.sh | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-)
tools/testing/selftests/bpf/README.rst +0 -2
@@ -36,8 +36,6 @@ For more information on about using the script, run: If you want to change pahole and llvm, you can change `PATH` environment variable in the beginning of script. -.. note:: The script currently only supports x86_64 and s390x architectures. - Additional information about selftest failures are documented here.
tools/testing/selftests/bpf/vmtest.sh +16 -5
@@ -4,9 +4,11 @@ set -u set -e -# This script currently only works for x86_64 and s390x, as -# it is based on the VM image used by the BPF CI, which is -# available only for these architectures. +# This script currently only works for the following platforms, +# as it is based on the VM image used by the BPF CI, which is +# available only for these architectures. We can also specify +# the local rootfs image generated by the following script: +# https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh ARCH="$(uname -m)" case "${ARCH}" in s390x)
@@ -28,6 +30,7 @@ x86_64) esac DEFAULT_COMMAND="./test_progs" MOUNT_DIR="mnt" +LOCAL_ROOTFS_IMAGE="" ROOTFS_IMAGE="root.img" OUTPUT_DIR="$HOME/.bpf_selftests" KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/config-latest.${ARCH}"
@@ -62,6 +65,7 @@ or Options: + -l) Specify the path to the local rootfs image. -i) Update the rootfs image with a newer version. -d) Update the output directory (default: ${OUTPUT_DIR}) -j) Number of jobs for compilation, similar to -j in make
@@ -121,7 +125,11 @@ load_rootfs() exit 1 fi - download_rootfs | zstd -d | sudo tar -C "$dir" -x + if [[ -n "${LOCAL_ROOTFS_IMAGE}" ]]; then + cat "${LOCAL_ROOTFS_IMAGE}" | zstd -d | sudo tar -C "$dir" -x + else + download_rootfs | zstd -d | sudo tar -C "$dir" -x + fi } recompile_kernel()
@@ -305,8 +313,11 @@ main() local exit_command="poweroff -f" local debug_shell="no" - while getopts ':hskid:j:' opt; do + while getopts ':hskl:id:j:' opt; do case ${opt} in + l) + LOCAL_ROOTFS_IMAGE="$OPTARG" + ;; i) update_image="yes" ;;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 808/935 selftests/bpf: Add description for running vmtest on RV64
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 95b1c5d17832f61d0438cd5060a997bafaf75f2c ]
Add description in tools/testing/selftests/bpf/README.rst for running vmtest on RV64.
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/README.rst | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
tools/testing/selftests/bpf/README.rst +32 -0
@@ -36,6 +36,38 @@ For more information on about using the script, run: If you want to change pahole and llvm, you can change `PATH` environment variable in the beginning of script. +Running vmtest on RV64 +====================== +To speed up testing and avoid various dependency issues, it is recommended to +run vmtest in a Docker container. Before running vmtest, we need to prepare +Docker container and local rootfs image. The overall steps are as follows: + +1. Create Docker container as shown in link [0]. + +2. Use mkrootfs_debian.sh script [1] to build local rootfs image: + +.. code-block:: console + + $ sudo ./mkrootfs_debian.sh --arch riscv64 --distro noble + +3. Start Docker container [0] and run vmtest in the container: + +.. code-block:: console + + $ PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \ + tools/testing/selftests/bpf/vmtest.sh \ + -l <path of local rootfs image> -- \ + ./test_progs -d \ + \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ + | cut -d'#' -f1 \ + | sed -e 's/^[[:space:]]*//' \ + -e 's/[[:space:]]*$//' \ + | tr -s '\n' ',' \ + )\" + +Link: https://github.com/pulehui/riscv-bpf-vmtest.git [0] +Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [1] + Additional information about selftest failures are documented here.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 809/935 selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
[ Upstream commit 3a59f11e0f989bdd637c87151992605a6559a7cb ]
vmtest.sh captures the trailing command with command="$@", which flattens the arguments into a single space-separated string, and then pastes it into the generated guest init script:
cd /root/bpf
echo ${command}
stdbuf -oL -eL ${command}That here-doc is unquoted, so the host expands ${command} and the flattened text lands in the script verbatim. The guest bash then parses those lines as shell source, re-splitting the text on whitespace and glob-expanding it against /root/bpf. As a result any command with a glob or an argument containing spaces is corrupted before it reaches the test binary. For example:
vmtest.sh -- ./test_progs -a 'verifier_*'
has 'verifier_*' expanded in the guest into the matching object/skeleton files (verifier_align.bpf.o verifier_align.skel.h ...), so test_progs is handed a list of filenames instead of the intended name filter and runs no matching tests.
Quote each argument with printf '%q ' so the command is reproduced verbatim inside the VM: the escaped text goes through exactly one round of quote removal when the guest parses the init script, yielding the original argv with globs and special characters intact. The common case (e.g. -t <name>) is unaffected.
Only do this when there is a command to quote. printf '%q ' with no arguments still applies the format once and emits '', which the -s (debug shell) path would take for a real command and try to run.
Note this makes the trailing command strictly an argv rather than a shell
snippet: passing it pre-quoted as one word, e.g.
vmtest.sh -- "./test_progs -t foo"
no longer works, and neither does embedding guest-side shell syntax such as ';' or a redirection. 'sh -c ...' still works.
The RV64 recipe in README.rst does depend on the old double parse: it wraps the denylist in \" so the literal quotes reach the guest, whose second parse of the init script removes them. Under %q those quotes now survive into argv, and parse_test_list() strtok_r()s on ',' turns them into junk filters:
-d ",exceptions," -> ["] [exceptions] ["]
That is harmless for DENYLIST.riscv64 only because its first line is a comment, so the leading field is empty. A denylist starting with a real entry would silently lose it - ["*arena*] never matches - so drop the backslashes and let the host consume the quotes instead.
--- tools/testing/selftests/bpf/README.rst | 4 ++-- tools/testing/selftests/bpf/vmtest.sh | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/README.rst +2 -2
@@ -58,12 +58,12 @@ Docker container and local rootfs image. The overall steps are as follows: tools/testing/selftests/bpf/vmtest.sh \ -l <path of local rootfs image> -- \ ./test_progs -d \ - \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ + "$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ | cut -d'#' -f1 \ | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//' \ | tr -s '\n' ',' \ - )\" + )" Link: https://github.com/pulehui/riscv-bpf-vmtest.git [0] Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [1]
tools/testing/selftests/bpf/vmtest.sh +11 -2
@@ -352,8 +352,17 @@ main() if [[ $# -eq 0 && "${debug_shell}" == "no" ]]; then echo "No command specified, will run ${DEFAULT_COMMAND} in the vm" - else - command="$@" + elif [[ $# -gt 0 ]]; then + # Quote each argument so the command survives into the guest: the + # host expands ${command} into the generated init script, which + # the guest bash then parses as shell source. Without the %q + # escapes an argument with a space or a glob (e.g. -a 'verifier_*') + # is re-split and expanded against /root/bpf there. + # + # Skip this when there is no command: printf '%q ' would still + # apply the format once and emit '', which is not the empty + # command that -s (debug shell) expects. + command=$(printf '%q ' "$@") fi local kconfig_file="${OUTPUT_DIR}/latest.config"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 810/935 spi: img-spfi: dont disable runtime PM on DMA deferred probe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 923e41ed59511cffe98357c7d58d0294a1c157ee ]
When dma_request_chan() returns -EPROBE_DEFER, the error path jumps to disable_pm and calls pm_runtime_disable() even though pm_runtime_enable() was never called, leaving disable_depth unbalanced and the device permanently PM-disabled.
Route the defer path through free_dma to skip pm_runtime_disable().
--- drivers/spi/spi-img-spfi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/spi-img-spfi.c +3 -2
@@ -617,7 +617,7 @@ static int img_spfi_probe(struct platform_device *pdev) ret =PTR_ERR (spfi->tx_ch); spfi->tx_ch =NULL ;if (ret == -EPROBE_DEFER ) - goto disable_pm; + goto free_dma; } spfi->rx_ch =dma_request_chan (spfi->dev,"rx" );
@@ -625,7 +625,7 @@ static int img_spfi_probe(struct platform_device *pdev) ret =PTR_ERR (spfi->rx_ch); spfi->rx_ch =NULL ;if (ret == -EPROBE_DEFER ) - goto disable_pm; + goto free_dma; }if (!spfi->tx_ch || !spfi->rx_ch) {
@@ -653,6 +653,7 @@ static int img_spfi_probe(struct platform_device *pdev) disable_pm:pm_runtime_disable (spfi->dev); +free_dma:if (spfi->rx_ch)dma_release_channel (spfi->rx_ch);if (spfi->tx_ch)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 811/935 power: supply: bd99954: Drop bad register fields
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 177299384a224377b4152242d875e752e5958c02 ]
The bd99954 driver creates regmap fields for all the registers. All the fields for VBUS_UCD_FCTRL_SET (extended command 0x33) are accidentally created for VCC_UCD_FCTRL_SET (extended command 0x2b), causing all reads/writes for the fields to access wrong register. Luckily the fields for VBUS_UCD_FCTRL_SET are unused.
Taking a look at the data-sheet all the fields in the VBUS_UCD_FCTRL_SET are marked as: "In normal operation, please don’t set these registers" with not much of additional documentation. As the fields are wrong and because there seems to be no users of the fields - it is better to just drop them. This will also decrease the memory footprint.
Drop incorrect VBUS_UCD_FCTRL_SET fields.
Datasheet: https://fscdn.rohm.com/en/products/databook/datasheet/ic/power/battery_management/bd99954xxx-e.pdf
--- drivers/power/supply/bd99954-charger.h | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/power/supply/bd99954-charger.h +1 -22
@@ -279,17 +279,7 @@ enum bd9995x_fields {F_VBUS_EXTID ,F_VBUS_IDRDET ,F_VBUS_INDO , -F_VBUS_UCDSWEN , -F_VBUS_RREF_EN , -F_VBUS_DPPU_EN , -F_VBUS_DPREF_EN , -F_VBUS_DMREF_EN , -F_VBUS_DPDET_EN , -F_VBUS_DMDET_EN , -F_VBUS_DPSINK_EN , -F_VBUS_DMSINK_EN , -F_VBUS_DP_BUFF_EN , -F_VBUS_DM_BUFF_EN , +F_VBUS_EXTCLKENBL ,F_VBUS_PLSTESTEN , F_VBUS_UCDSWEN_TSTENB,
@@ -626,17 +616,6 @@ static const struct reg_field bd9995x_reg_fields[] = { [F_VBUS_EXTID] = REG_FIELD(VBUS_IDD_STATUS, 5, 5), [F_VBUS_IDRDET] = REG_FIELD(VBUS_IDD_STATUS, 4, 4), [F_VBUS_INDO] = REG_FIELD(VBUS_IDD_STATUS, 0, 3), - [F_VBUS_UCDSWEN] = REG_FIELD(VCC_UCD_FCTRL_SET, 10, 10), - [F_VBUS_RREF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 9, 9), - [F_VBUS_DPPU_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 8, 8), - [F_VBUS_DPREF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 7, 7), - [F_VBUS_DMREF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 6, 6), - [F_VBUS_DPDET_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 5, 5), - [F_VBUS_DMDET_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 4, 4), - [F_VBUS_DPSINK_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 3, 3), - [F_VBUS_DMSINK_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 2, 2), - [F_VBUS_DP_BUFF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 1, 1), - [F_VBUS_DM_BUFF_EN] = REG_FIELD(VCC_UCD_FCTRL_SET, 0, 0), [F_VBUS_EXTCLKENBL] = REG_FIELD(VBUS_UCD_FCTRL_EN, 15, 15), [F_VBUS_PLSTESTEN] = REG_FIELD(VBUS_UCD_FCTRL_EN, 14, 14),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 812/935 power: supply: bq27xxx: bq27520g4: fix REG_TTES address
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit c774a623c821a173c950e1297f8e8c85a89455be ]
According to the technical reference manual the StandbyTimeToEmpty (TTES) register is at 0x1a, not 0x1c. At 0x1c StateOfHealth instead resides.
--- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -324,7 +324,7 @@ static u8 [BQ27XXX_REG_FLAGS] = 0x0a, [BQ27XXX_REG_TTE] = 0x16, [BQ27XXX_REG_TTF] = INVALID_REG_ADDR, - [BQ27XXX_REG_TTES] = 0x1c, + [BQ27XXX_REG_TTES] = 0x1a, [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR, [BQ27XXX_REG_NAC] = 0x0c, [BQ27XXX_REG_RC] = 0x10,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 813/935 power: supply: bq27xxx: bq28z610: fix invalid AverageEnergy address
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit e9387e9ab5121f330d313afb90430c02200f9782 ]
bq28z610 currently uses the AveragePower reg, 0x22, for reading both AveragePower and AvailableEnergy. The technical reference manual does not mention AvailableEnergy, and it does not make sense to read a cumulative, always positive, property like AvailableEnergy from a rate property like AveragePower. Set REG_AE as invalid to fix it.
--- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -510,7 +510,7 @@ static u8 [BQ27XXX_REG_RC] = 0x10, [BQ27XXX_REG_FCC] = 0x12, [BQ27XXX_REG_CYCT] = 0x2a, - [BQ27XXX_REG_AE] = 0x22, + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP] = 0x22,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 814/935 power: supply: bq27xxx: bq27z561: fix invalid AverageEnergy address
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit 2da28b059e0ddcd2e1956eeae383246207965573 ]
bq27z561 currently uses the AveragePower reg, 0x22, for reading both AveragePower and AvailableEnergy. The technical reference manual does not mention AvailableEnergy, and it does not make sense to read a cumulative, always positive, property like AvailableEnergy from a rate property like AveragePower. Set REG_AE as invalid to fix it.
--- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -489,7 +489,7 @@ static u8 [BQ27XXX_REG_RC] = 0x10, [BQ27XXX_REG_FCC] = 0x12, [BQ27XXX_REG_CYCT] = 0x2a, - [BQ27XXX_REG_AE] = 0x22, + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, [BQ27XXX_REG_SOC] = 0x2c, [BQ27XXX_REG_DCAP] = 0x3c, [BQ27XXX_REG_AP] = 0x22,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 815/935 xenbus: Unregister reboot notifier on init failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit d330fb86a7170f845123ae82d95df440fad9b707 ]
xs_init() registers xs_reboot_nb before initializing XenStore communications and starting xenwatch. If either operation fails, the notifier remains registered and a later initialization attempt can hit a duplicate registration.
Check the notifier registration result and unregister it on every subsequent failure path.
Message-ID: <[email protected]>
--- drivers/xen/xenbus/xenbus_xs.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/xen/xenbus/xenbus_xs.c +12 -4
@@ -952,19 +952,27 @@ int xs_init(void)int err;struct task_struct *task; -register_reboot_notifier (&xs_reboot_nb); + err =register_reboot_notifier (&xs_reboot_nb); +if (err) +return err;/* Initialize the shared memory rings to talk to xenstored */ err =xb_init_comms ();if (err) -return err; + goto err_unregister_reboot_notifier; task =kthread_run (xenwatch_thread,NULL ,"xenwatch" ); -if (IS_ERR (task)) -return PTR_ERR (task); +if (IS_ERR (task)) { + err =PTR_ERR (task); + goto err_unregister_reboot_notifier; + }/* shutdown watches for kexec boot */ xs_reset_watches ();return 0 ; + +err_unregister_reboot_notifier: +unregister_reboot_notifier (&xs_reboot_nb); +return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 816/935 s390/debug: Fix deadlock during unregister
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Oberparleiter <[email protected]>
[ Upstream commit 445c31ac638fd1af203d79bdf25fc0cb3149fbbc ]
Unregistering an s390dbf debug area while one of the associated debugfs files is being written to can cause a deadlock:
$ echo >.../vmur/level $ rmmod vmur
===================================================
debugfs write
debugfs_file_get()
debug_unregister()
mutex_lock(debug_mutex)
debugfs_remove()
wait for debugfs_file_put()
debug_file_ops.write()
debug_input()
mutex_lock(debug_mutex) ==> DEADLOCKFix this by splitting debug_unregister() into an s390dbf and debugfs part, and running only the s390dbf part with debug_mutex locked.
--- arch/s390/kernel/debug.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/s390/kernel/debug.c +8 -2
@@ -747,8 +747,8 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas)mutex_unlock (&debug_mutex); } -/* Remove debugfs entries and remove from internal list. */ -static void _debug_unregister (debug_info_t *id) +/* Remove debugfs entries. */ +static void _debug_unregister_debugfs (debug_info_t *id) {int i;
@@ -758,6 +758,11 @@ static void _debug_unregister(debug_info_t *id)debugfs_remove (id->debugfs_entries[i]); }debugfs_remove (id->debugfs_root_entry); +} + +/* Remove from internal list. */ +static void _debug_unregister (debug_info_t *id) +{if (id == debug_area_first) debug_area_first = id->next;if (id == debug_area_last)
@@ -783,6 +788,7 @@ void debug_unregister(debug_info_t *id)mutex_lock (&debug_mutex);_debug_unregister (id);mutex_unlock (&debug_mutex); +_debug_unregister_debugfs (id);debug_info_put (id); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 817/935 clocksource/drivers/clps711x: Do not unmap clocksource MMIO
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit e998c6300ef4e062a704ee17b5a812c0b595cf42 ]
clps711x_clksrc_init() stores the timer base address in the static tcd pointer and registers it as both the clocksource MMIO address and the sched_clock read address.
The clocksource init path must therefore keep the mapping alive after clps711x_timer_init() returns. However, the shared unmap_io exit path is also reached after successful clocksource registration, so the MMIO mapping is torn down while the clocksource and sched_clock readers may still access it.
Return directly after successful clocksource registration and leave the mapping alive for the registered readers. Keep the unmap_io path for the error paths and for the clockevent init path.
--- drivers/clocksource/clps711x-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/clps711x-timer.c +1 -1
@@ -94,7 +94,7 @@ static int __init clps711x_timer_init(struct device_node *np)switch (of_alias_get_id (np,"timer" )) {case CLPS711X_CLKSRC_CLOCKSOURCE :clps711x_clksrc_init (clock, base); -break ; +return 0 ;case CLPS711X_CLKSRC_CLOCKEVENT : ret =_clps711x_clkevt_init (clock, base, irq);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 818/935 clocksource/drivers/armada: Unwind timer clock on init failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 8b4127f6db40381229f3564d34ac35f36311c201 ]
The Armada timer init paths enable their clock before calling the common initialization routine. If that routine returns an error, the clock is left enabled even though the timer was not initialized successfully.
--- drivers/clocksource/timer-armada-370-xp.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/clocksource/timer-armada-370-xp.c +15 -3
@@ -349,7 +349,11 @@ static int __init armada_xp_timer_init(struct device_node *np) timer_clk =clk_get_rate (clk); -return armada_370_xp_timer_common_init (np); + ret =armada_370_xp_timer_common_init (np); +if (ret) +clk_disable_unprepare (clk); + +return ret; }TIMER_OF_DECLARE (armada_xp,"marvell,armada-xp-timer" , armada_xp_timer_init);
@@ -387,7 +391,11 @@ static int __init armada_375_timer_init(struct device_node *np) timer25Mhz = false; } -return armada_370_xp_timer_common_init (np); + ret =armada_370_xp_timer_common_init (np); +if (ret) +clk_disable_unprepare (clk); + +return ret; }TIMER_OF_DECLARE (armada_375,"marvell,armada-375-timer" , armada_375_timer_init);
@@ -410,7 +418,11 @@ static int __init armada_370_timer_init(struct device_node *np) timer_clk =clk_get_rate (clk) /TIMER_DIVIDER ; timer25Mhz = false; -return armada_370_xp_timer_common_init (np); + ret =armada_370_xp_timer_common_init (np); +if (ret) +clk_disable_unprepare (clk); + +return ret; }TIMER_OF_DECLARE (armada_370,"marvell,armada-370-timer" , armada_370_timer_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 819/935 x86/pkeys: Fix pkey_alloc() return value when pkeys are not supported
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bijan Tabatabai <[email protected]>
[ Upstream commit dee87e09b0dd63da9b1e1876167ccae37842dfd0 ]
The man page for pkey_alloc(2) specifies that it should return -1 with the errno set to ENOSPC when pkeys are not supported [1]. However, on x86 pkey_alloc() sets errno to EINVAL when called for the first time on a CPU that does not support pkeys.
The root cause of this is the x86 implementation of mm_pkey_alloc() not directly checking if pkeys are supported. It only checks if all the pkeys have been allocated by comparing the allocation map against all_pkeys_mask. When OSPKE is not enabled, init_new_context() skips the initialization of the allocation map, leaving it as 0, while all_pkeys_mask is 1. mm_pkey_alloc() interprets this as there being a pkey available and it returns pkey 0. Then, pkey_alloc() fails with -EINVAL from arch_set_user_pkey_access() instead of returning -ENOSPC. Subsequent calls to pkey_alloc() do return -ENOSPC because pkey 0 is left marked as allocated.
Change mm_pkey_alloc() to directly check if OSPKE is enabled, and return -1 if it is not, which causes pkey_alloc() to return -ENOSPC. The arm64 and powerpc implementations of mm_pkey_alloc() already do this check.
[1] https://man7.org/linux/man-pages/man2/pkey_alloc.2.html
[ dhansen: use arch_pkeys_enabled() to follow arm ]
--- arch/x86/include/asm/pkeys.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/pkeys.h +3 -0
@@ -92,6 +92,9 @@ int mm_pkey_alloc(struct mm_struct *mm)u16 all_pkeys_mask = ((1U <<arch_max_pkey ()) -1 );int ret; +if (!arch_pkeys_enabled ()) +return -1 ; +/* * Are we out of pkeys? We must handle this specially * because ffz() behavior is undefined if there are no
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 820/935 bpftool: Fix double close in map dump
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 259d60f5bfa41056fe01cbf2ba3f6f0331865a16 ]
map_dump() closes the map fd in its error path, and do_dump() then closes the same fd again after a successful dump. Closing an already closed fd leaves errno set to EBADF, which poisons later errno checks such as the batch file read check in do_batch(). Let do_dump() own the fd and remove the close from map_dump().
The same double-close pattern exists in do_show_subset(): both show_map_close_json() and show_map_close_plain() already close the fd, so drop the extra close() there as well.
Also propagate the error when bpf_map_get_info_by_fd() fails on a subsequent map in do_dump(): set err = -1 before breaking out of the loop, so a later failure is not silently hidden after an earlier iteration succeeded.
--- tools/bpf/bpftool/map.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/bpf/bpftool/map.c +1 -3
@@ -674,8 +674,6 @@ static int do_show_subset(int argc, char **argv)show_map_close_json (fds[i], &info); else show_map_close_plain(fds[i], &info); - -close (fds[i]); }if (json_output && nb_fds >1 )jsonw_end_array (json_wtr);/* root array */
@@ -899,7 +897,6 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr, exit_free:free (key);free (value); -close (fd);free_map_kv_btf (btf);return err;
@@ -948,6 +945,7 @@ static int do_dump(int argc, char **argv)for (i =0 ; i < nb_fds; i++) {if (bpf_obj_get_info_by_fd (fds[i], &info, &len)) {p_err ("can't get map info: %s" ,strerror (errno)); + err =-1 ;break ; } err =map_dump (fds[i], &info, wtr, nb_fds >1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 821/935 ocfs2: fix circular locking dependency in ocfs2_init_acl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krystian Kaniewski <[email protected]>
[ Upstream commit bd7c05fb4a4776dff5a87b19008d28458647d15d ]
A lockdep warning indicates a circular locking dependency between &oi->ip_xattr_sem and &journal->j_trans_barrier:
WARNING: possible circular locking dependency detected is trying to acquire lock:
(&oi->ip_xattr_sem){++++}-{4:4}, at: ocfs2_init_acl+0x2fd/0x7e0 fs/ocfs2/acl.c:367
but task is already holding lock:
(&journal->j_trans_barrier){.+.+}-{4:4}, at: ocfs2_start_trans+0x3ab/0x700 fs/ocfs2/journal.c:369
The deadlock involves two code paths: Path 1 (setxattr) where ocfs2_xattr_set() acquires ip_xattr_sem (write) and then starts a transaction, which acquires j_trans_barrier (read); and Path 2 (mkdir/mknod) where ocfs2_mknod() starts a transaction (j_trans_barrier read) and then calls ocfs2_init_acl(), which attempts to acquire ip_xattr_sem (read) on the parent directory to retrieve the default ACL.
Because rw_semaphores are subject to writer priority, a pending writer on j_trans_barrier (e.g., the journal commit thread) can cause Path 1 to block, while Path 2 is blocked waiting for Path 1 to release ip_xattr_sem.
The patch fixes the lock ordering by precomputing the ACL state before starting the OCFS2 transaction, while preserving POSIX ACL storage semantics and the existing inode/security initialization order. By reading the parent directory's default ACL and preparing the new inode's ACLs outside the transaction, ip_xattr_sem is always acquired before j_trans_barrier.
struct ocfs2_acl_state encapsulates the prepared ACL state, while ocfs2_acl_init_prepare() and ocfs2_acl_init_release() avoid code duplication between ocfs2_mknod() and ocfs2_init_security_and_acl(). ocfs2_calc_xattr_init() and ocfs2_init_acl() use this precomputed state, removing internal ip_xattr_sem acquisition and redundant disk reads.
Additionally, remove the ip_xattr_sem acquisition from ocfs2_xattr_set_handle(). This function is only used while initializing a new inode that has not yet been inserted into the inode hash or attached to a dentry, meaning there is no risk of concurrent access and the lock is unnecessary.
--- fs/ocfs2/acl.c | 135 ++++++++++++++++++++++++++++++----------------- fs/ocfs2/acl.h | 19 +++++-- fs/ocfs2/namei.c | 17 ++++-- fs/ocfs2/xattr.c | 86 ++++++++++++++++++------------ fs/ocfs2/xattr.h | 9 ++-- 5 files changed, 173 insertions(+), 93 deletions(-)
fs/ocfs2/acl.c +88 -47
@@ -109,8 +109,7 @@ static void *ocfs2_acl_to_xattr(const struct posix_acl *acl, size_t *size)return ocfs2_acl; } -static struct posix_acl *ocfs2_get_acl_nolock (struct inode *inode, -int type, +static struct posix_acl *ocfs2_get_acl_nolock (struct inode *inode,int type,struct buffer_head *di_bh) {int name_index;
@@ -347,63 +346,105 @@ int ocfs2_acl_chmod(struct inode *inode, struct buffer_head *bh)* Initialize the ACLs of a new inode. If parent directory has default ACL, * then clone to new inode. Called from ocfs2_mknod. */ -int ocfs2_init_acl (handle_t *handle, -struct inode *inode, -struct inode *dir, -struct buffer_head *di_bh, -struct buffer_head *dir_bh, -struct ocfs2_alloc_context *meta_ac, -struct ocfs2_alloc_context *data_ac) +void ocfs2_acl_init_release (struct ocfs2_acl_state *state) +{ +posix_acl_release (state->default_acl); +posix_acl_release (state->acl); + state->default_acl =NULL ; + state->acl =NULL ; +} + +int ocfs2_acl_init_prepare (struct inode *inode,struct inode *dir, +struct buffer_head *dir_bh, +struct ocfs2_acl_state *state) {struct ocfs2_super *osb =OCFS2_SB (inode->i_sb); -struct posix_acl *acl =NULL ; -int ret =0 , ret2; -umode_t mode; - -if (!S_ISLNK (inode->i_mode)) { -if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { -down_read (&OCFS2_I (dir)->ip_xattr_sem); - acl =ocfs2_get_acl_nolock (dir,ACL_TYPE_DEFAULT , - dir_bh); -up_read (&OCFS2_I (dir)->ip_xattr_sem); -if (IS_ERR (acl)) -return PTR_ERR (acl); +int ret =0 ; + + state->default_acl =NULL ; + state->acl =NULL ; + state->mode = inode->i_mode; + +if (S_ISLNK (inode->i_mode)) +return 0 ; + +if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +down_read (&OCFS2_I (dir)->ip_xattr_sem); + state->default_acl = +ocfs2_get_acl_nolock (dir,ACL_TYPE_DEFAULT , dir_bh); +up_read (&OCFS2_I (dir)->ip_xattr_sem); +if (IS_ERR (state->default_acl)) { + ret =PTR_ERR (state->default_acl); + state->default_acl =NULL ; +return ret; } -if (!acl) { - mode = inode->i_mode & ~current_umask (); - ret =ocfs2_acl_set_mode (inode, di_bh, handle, mode); -if (ret) { -mlog_errno (ret); +if (state->default_acl) { + state->acl =posix_acl_dup (state->default_acl); +if (!state->acl) { + ret = -ENOMEM ; goto cleanup; } + ret =__posix_acl_create (&state->acl,GFP_NOFS , + &state->mode); +if (ret <0 ) + goto cleanup; +if (ret ==0 ) { +posix_acl_release (state->acl); + state->acl =NULL ; + } +if (!S_ISDIR (inode->i_mode)) { +posix_acl_release (state->default_acl); + state->default_acl =NULL ; + } + }else { + state->mode &= ~current_umask (); } + }else { + state->mode &= ~current_umask (); } -if ((osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) && acl) { -if (S_ISDIR (inode->i_mode)) { + +return 0 ; +cleanup: +ocfs2_acl_init_release (state); +return ret; +} + +int ocfs2_init_acl (handle_t *handle,struct inode *inode, +struct buffer_head *di_bh, +struct ocfs2_alloc_context *meta_ac, +struct ocfs2_alloc_context *data_ac, +struct ocfs2_acl_state *state) +{ +struct ocfs2_super *osb =OCFS2_SB (inode->i_sb); +int ret =0 ; + +if (S_ISLNK (inode->i_mode)) +return 0 ; + +if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +if (S_ISDIR (inode->i_mode) && state->default_acl) { ret =ocfs2_set_acl (handle, inode, di_bh, -ACL_TYPE_DEFAULT , acl, - meta_ac, data_ac); +ACL_TYPE_DEFAULT , + state->default_acl, meta_ac, + data_ac);if (ret) - goto cleanup; +return ret; } - mode = inode->i_mode; - ret =__posix_acl_create (&acl,GFP_NOFS , &mode); -if (ret <0 ) -return ret; + } - ret2 =ocfs2_acl_set_mode (inode, di_bh, handle, mode); -if (ret2) { -mlog_errno (ret2); - ret = ret2; - goto cleanup; - } -if (ret >0 ) { - ret =ocfs2_set_acl (handle, inode, - di_bh,ACL_TYPE_ACCESS , - acl, meta_ac, data_ac); + ret =ocfs2_acl_set_mode (inode, di_bh, handle, state->mode); +if (ret) { +mlog_errno (ret); +return ret; + } + +if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +if (state->acl) { + ret =ocfs2_set_acl (handle, inode, di_bh, +ACL_TYPE_ACCESS , state->acl, + meta_ac, data_ac); } } -cleanup: -posix_acl_release (acl); +return ret; }
fs/ocfs2/acl.h +15 -4
@@ -20,9 +20,20 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu);int ocfs2_iop_set_acl (struct user_namespace *mnt_userns,struct inode *inode,struct posix_acl *acl,int type);extern int ocfs2_acl_chmod (struct inode *,struct buffer_head *); -extern int ocfs2_init_acl (handle_t *,struct inode *,struct inode *, -struct buffer_head *,struct buffer_head *, -struct ocfs2_alloc_context *, -struct ocfs2_alloc_context *); +struct ocfs2_acl_state { +struct posix_acl *default_acl; +struct posix_acl *acl; +umode_t mode; +}; + +int ocfs2_acl_init_prepare (struct inode *inode,struct inode *dir, +struct buffer_head *dir_bh, +struct ocfs2_acl_state *state); +void ocfs2_acl_init_release (struct ocfs2_acl_state *state); +int ocfs2_init_acl (handle_t *handle,struct inode *inode, +struct buffer_head *di_bh, +struct ocfs2_alloc_context *meta_ac, +struct ocfs2_alloc_context *data_ac, +struct ocfs2_acl_state *state);#endif /* OCFS2_ACL_H */
fs/ocfs2/namei.c +12 -5
@@ -252,6 +252,7 @@ static int ocfs2_mknod(struct user_namespace *mnt_userns,sigset_t oldset;int did_block_signals =0 ;struct ocfs2_dentry_lock *dl =NULL ; +struct ocfs2_acl_state acl_state = {0 }; trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno,
@@ -326,10 +327,14 @@ static int ocfs2_mknod(struct user_namespace *mnt_userns, } } + status =ocfs2_acl_init_prepare (inode, dir, parent_fe_bh, &acl_state); +if (status <0 ) + goto leave; +/* calculate meta data/clusters for setting security and acl xattr */ - status =ocfs2_calc_xattr_init (dir, parent_fe_bh, mode, - &si, &want_clusters, - &xattr_credits, &want_meta); + status =ocfs2_calc_xattr_init (dir, mode, &si, &want_clusters, + &xattr_credits, &want_meta, + &acl_state);if (status <0 ) {mlog_errno (status); goto leave;
@@ -407,8 +412,8 @@ static int ocfs2_mknod(struct user_namespace *mnt_userns,inc_nlink (dir); } - status =ocfs2_init_acl (handle, inode, dir, new_fe_bh, parent_fe_bh, - meta_ac, data_ac); + status =ocfs2_init_acl (handle, inode, new_fe_bh, meta_ac, data_ac, + &acl_state);if (status <0 ) {mlog_errno (status);
@@ -473,6 +478,8 @@ static int ocfs2_mknod(struct user_namespace *mnt_userns,brelse (parent_fe_bh);kfree (si.value); +ocfs2_acl_init_release (&acl_state); +ocfs2_free_dir_lookup_result (&lookup);if (inode_ac)
fs/ocfs2/xattr.c +52 -34
138 lines not on this page · raw message
fs/ocfs2/xattr.h +6 -3
@@ -55,9 +55,12 @@ int ocfs2_init_security_set(handle_t *, struct inode *,int ocfs2_calc_security_init (struct inode *,struct ocfs2_security_xattr_info *,int *,int *,struct ocfs2_alloc_context **); -int ocfs2_calc_xattr_init (struct inode *,struct buffer_head *, -umode_t ,struct ocfs2_security_xattr_info *, -int *,int *,int *); + +struct ocfs2_acl_state ; +int ocfs2_calc_xattr_init (struct inode *dir,umode_t mode, +struct ocfs2_security_xattr_info *si, +int *want_clusters,int *xattr_credits, +int *want_meta,struct ocfs2_acl_state *acl_state);/* * xattrs can live inside an inode, as part of an external xattr block,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 822/935 Squashfs: check block offset is not negative
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phillip Lougher <[email protected]>
[ Upstream commit e300eb5002925b29be803d2661af07266cfa267e ]
If a negative offset is read off disk (for example the offset into the decompressed fragment block), this will cause squashfs_copy_data() to perform an out of bounds access.
Fix by checking if offset is negative, and returning 0. This matches existing behaviour where an offset beyond the block returns 0 bytes copied.
To trigger this out of bounds access requires a crafted Squashfs filesystem and CAP_SYS_ADMIN to mount it. Unprivileged users will not be able to mount such a filesystem, but once mounted, an unprivileged user can trigger the out of bounds access by reading the crafted file with the negative offset.
--- fs/squashfs/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/cache.c +1 -1
@@ -295,7 +295,7 @@ int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry, {int remaining = length; -if (length ==0 ) +if (length ==0 || offset <0 )return 0 ;else if (buffer ==NULL )return min (length, entry->length - offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 823/935 scsi: mpt3sas: Avoid freeing unallocated PCIe SGL buffers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit b9f679dfe629004b593f018df33b330d799bcee4 ]
_base_release_memory_pools() unconditionally frees every ioc->pcie_sg_lookup[] entry, including ones the setup loop never allocated after a partial failure, causing a "bad dma" warning on debug kernels or a NULL pointer dereference otherwise.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -0
@@ -5713,6 +5713,8 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)if (ioc->pcie_sgl_dma_pool) {for (i =0 ; i < ioc->scsiio_depth; i++) { +if (!ioc->pcie_sg_lookup[i].pcie_sgl) +continue ;dma_pool_free (ioc->pcie_sgl_dma_pool, ioc->pcie_sg_lookup[i].pcie_sgl, ioc->pcie_sg_lookup[i].pcie_sgl_dma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 824/935 ALSA: core: Fix use-after-free in snd_card_do_free()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit 5ae1a690c522fea2900ff56c8c2ace7b059f5e04 ]
A use-after-free was detected in snd_card_do_free() when a sound card managed by devres is unbound while a user-space application still holds an open file descriptor.
For managed cards, the memory is allocated using devres_alloc(), and its release function is set to __snd_card_release(), which calls snd_card_free(). When the device is unbound, the unbind thread calls snd_card_free(), which drops a reference to the card's device. If the user thread still has an open file descriptor, the reference count does not reach zero, and the unbind thread blocks on wait_for_completion(&released).
When the user thread closes the file descriptor, it drops the final reference, invoking the device release callback release_card_device(), which calls snd_card_do_free(). snd_card_do_free() performs cleanup and calls complete(card->release_completion). This wakes up the unbind thread, which returns from snd_card_free() and __snd_card_release(). The devres core then immediately frees the memory block containing the snd_card structure.
Meanwhile, the user thread continues execution in snd_card_do_free() and evaluates if (!card->managed). It reads the managed boolean from the snd_card structure that was just freed by the unbind thread, triggering a KASAN use-after-free.
Fix this by caching the value of card->managed in a local variable before calling complete(). This ensures that the card pointer is not dereferenced after the unbind thread has been woken up and potentially freed the card.
BUG: KASAN: use-after-free in snd_card_do_free sound/core/init.c:604 [inline] BUG: KASAN: use-after-free in release_card_device+0x1ab/0x1b0 sound/core/init.c:153 Read of size 1 at addr ffff8881912ec909 by task syz-executor130/5857 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_address_description+0x55/0x1e0 mm/kasan/report.c:378 print_report+0x58/0x70 mm/kasan/report.c:482 kasan_report+0x117/0x150 mm/kasan/report.c:595 snd_card_do_free sound/core/init.c:604 [inline] release_card_device+0x1ab/0x1b0 sound/core/init.c:153 device_release+0xc4/0x1f0 drivers/base/core.c:-1 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x222/0x550 lib/kobject.c:737 snd_card_file_remove+0x331/0x390 sound/core/init.c:1125 snd_pcm_release+0x12c/0x160 sound/core/pcm_native.c:2986 __fput+0x418/0xa50 fs/file_table.c:512 fput_close_sync+0x11f/0x240 fs/file_table.c:617 __do_sys_close fs/open.c:1511 [inline] __se_sys_close fs/open.c:1496 [inline] __x64_sys_close+0x7e/0x110 fs/open.c:1496 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
--- sound/core/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/init.c +3 -1
@@ -580,6 +580,8 @@ EXPORT_SYMBOL_GPL(snd_card_disconnect_sync);static int snd_card_do_free (struct snd_card *card) { +bool managed = card->managed; + card->releasing = true;#if IS_ENABLED (CONFIG_SND_MIXER_OSS )if (snd_mixer_oss_notify_callback)
@@ -598,7 +600,7 @@ static int snd_card_do_free(struct snd_card *card)#endif if (card->release_completion)complete (card->release_completion); -if (!card->managed) +if (!managed)kfree (card);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 825/935 tracing: Remove "__attribute__()" from the type field of event format
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 1a967e92bf47cf5170336b88d748117c700edc47 ]
With CONFIG_DEBUG_INFO_BTF=y and PAHOLE_HAS_BTF_TAG=y, __user is converted to __attribute__((btf_type_tag("user"))). In this case, some syscall events have it for __user data, like below;
/sys/kernel/tracing # cat events/syscalls/sys_enter_openat/format
name: sys_enter_openat
ID: 720
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:int __syscall_nr; offset:8; size:4; signed:1;
field:int dfd; offset:16; size:8; signed:0;
field:const char __attribute__((btf_type_tag("user"))) * filename; offset:24; size:8; signed:0;
field:int flags; offset:32; size:8; signed:0;
field:umode_t mode; offset:40; size:8; signed:0;Then the trace event filter fails to set the string acceptable flag (FILTER_PTR_STRING) to the field and rejects setting string filter;
# echo 'filename.ustring ~ "*ftracetest-dir.wbx24v*"' \
Quoted 1 line
Quoted 1 line
events/syscalls/sys_enter_openat/filter
sh: write error: Invalid argument
# cat error_log [ 723.743637] event filter parse error: error: Expecting numeric field Command: filename.ustring ~ "*ftracetest-dir.wbx24v*"
Since this __attribute__ makes format parsing complicated and not needed, remove the __attribute__(.*) from the type string.
Stable-dep-of: ae70b04ab9c7 ("tracing: Have trace_event_update_all() only handle module that is loading")
--- kernel/trace/trace.c | 28 +++++--- kernel/trace/trace.h | 4 +- kernel/trace/trace_events.c | 128 ++++++++++++++++++++++++++++++------ 3 files changed, 127 insertions(+), 33 deletions(-)
kernel/trace/trace.c +18 -10
@@ -6163,17 +6163,27 @@ static inline void trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start, int len) { }#endif /* !CONFIG_TRACE_EVAL_MAP_FILE */ -static void trace_insert_eval_map (struct module *mod, -struct trace_eval_map **start,int len) +static void +trace_event_update_with_eval_map (struct module *mod, +struct trace_eval_map **start, +int len) {struct trace_eval_map **map; -if (len <=0 ) -return ; +/* Always run sanitizer only if btf_type_tag attr exists. */ +if (len <=0 ) { +if (!(IS_ENABLED (CONFIG_DEBUG_INFO_BTF ) && +IS_ENABLED (CONFIG_PAHOLE_HAS_BTF_TAG ) && +__has_attribute (btf_type_tag))) +return ; + } map = start; -trace_event_eval_update (map, len); +trace_event_update_all (map, len); + +if (len <=0 ) +return ;trace_insert_eval_map_file (mod, start, len); }
@@ -9783,7 +9793,7 @@ static void __init eval_map_work_func(struct work_struct *work)int len; len = __stop_ftrace_eval_maps - __start_ftrace_eval_maps; -trace_insert_eval_map (NULL , __start_ftrace_eval_maps, len); +trace_event_update_with_eval_map (NULL , __start_ftrace_eval_maps, len); }static int __init trace_eval_init (void )
@@ -9816,9 +9826,6 @@ late_initcall_sync(trace_eval_sync);#ifdef CONFIG_MODULES static void trace_module_add_evals (struct module *mod) { -if (!mod->num_trace_evals) -return ; -/* * Modules with bad taint do not have events created, do * not bother with enums either.
@@ -9826,7 +9833,8 @@ static void trace_module_add_evals(struct module *mod)if (trace_module_has_bad_taint (mod))return ; -trace_insert_eval_map (mod, mod->trace_evals, mod->num_trace_evals); +/* Even if no trace_evals, this need to sanitize field types. */ +trace_event_update_with_eval_map (mod, mod->trace_evals, mod->num_trace_evals); }#ifdef CONFIG_TRACE_EVAL_MAP_FILE
kernel/trace/trace.h +2 -2
@@ -1910,13 +1910,13 @@ static inline const char *get_syscall_name(int syscall)#ifdef CONFIG_EVENT_TRACING void trace_event_init (void ); -void trace_event_eval_update (struct trace_eval_map **map,int len); +void trace_event_update_all (struct trace_eval_map **map,int len);/* Used from boot time tracer */ extern int ftrace_set_clr_event (struct trace_array *tr,char *buf,int set);extern int trigger_process_regex (struct trace_event_file *file,char *buff);#else static inline void __init trace_event_init (void ) { } -static inline void trace_event_eval_update (struct trace_eval_map **map,int len) { } +static inline void trace_event_update_all (struct trace_eval_map **map,int len) { }#endif #ifdef CONFIG_TRACER_SNAPSHOT
kernel/trace/trace_events.c +107 -21
178 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 826/935 tracing: Have trace_event_update_all() only handle module that is loading
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit ae70b04ab9c7f6162a8c0fdd18a62a945c133142 ]
The function trace_event_update_all() does a scan of events looking to replace enums with their values in the strings that get exported to the event format files. It's run at boot up on all events and again when a module loads.
The issue is that when a module loads, it still runs on *all* events. There's no reason to process every event when a module loads as the previous events have already been processed. Only execute on the events that are loaded with the module.
--- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 4 ++-- kernel/trace/trace_events.c | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-)
kernel/trace/trace.c +1 -1
@@ -6180,7 +6180,7 @@ trace_event_update_with_eval_map(struct module *mod, map = start; -trace_event_update_all (map, len); +trace_event_update_all (map, len, mod);if (len <=0 )return ;
kernel/trace/trace.h +2 -2
@@ -1910,13 +1910,13 @@ static inline const char *get_syscall_name(int syscall)#ifdef CONFIG_EVENT_TRACING void trace_event_init (void ); -void trace_event_update_all (struct trace_eval_map **map,int len); +void trace_event_update_all (struct trace_eval_map **map,int len,struct module *mod);/* Used from boot time tracer */ extern int ftrace_set_clr_event (struct trace_array *tr,char *buf,int set);extern int trigger_process_regex (struct trace_event_file *file,char *buff);#else static inline void __init trace_event_init (void ) { } -static inline void trace_event_update_all (struct trace_eval_map **map,int len) { } +static inline void trace_event_update_all (struct trace_eval_map **map,int len,struct module *mod) { }#endif #ifdef CONFIG_TRACER_SNAPSHOT
kernel/trace/trace_events.c +5 -1
@@ -2947,7 +2947,7 @@ static void update_event_fields(struct trace_event_call *call, }/* Update all events for replacing eval and sanitizing */ -void trace_event_update_all (struct trace_eval_map **map,int len) +void trace_event_update_all (struct trace_eval_map **map,int len,struct module *mod) {struct trace_event_call *call, *p;const char *last_system =NULL ;
@@ -2959,6 +2959,10 @@ void trace_event_update_all(struct trace_eval_map **map, int len)mutex_lock (&event_mutex);down_write (&trace_event_sem);list_for_each_entry_safe (call, p, &ftrace_events, list) { + +if (mod && call->module != mod) +continue ; +/* events are usually grouped together with systems */ if (!last_system || call->class->system != last_system) { first = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 827/935 bpf: Fix pending_pos walk on 32-bit ring position wrap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Israel Téllez García <[email protected]>
[ Upstream commit 6ff5b56a50c5351aeeb180e34327736576c038fa ]
The reservation path caches the position of the oldest not-yet-committed record in rb->pending_pos and advances it past already committed records on every reservation:
while (pend_pos < prod_pos) {consumer_pos, producer_pos and pending_pos are unsigned long, i.e. 32-bit on 32-bit architectures, and Documentation/bpf/ringbuf.rst states that these counters may wrap around there. Every other comparison in the file is written as a difference, so modular arithmetic keeps them correct across the wrap. This one is an ordering comparison, and it is not wrap-safe.
Once producer_pos wraps past 2^32, prod_pos is small while pend_pos still holds its pre-wrap value, so the loop condition is false and pending_pos is never advanced again. Reservations keep succeeding for a while, because bpf_ringbuf_has_space() uses differences, but new_prod_pos - pend_pos grows as the producer advances, and once it exceeds rb->mask every subsequent __bpf_ringbuf_reserve() call fails:
the kernel believes a pending record spans the whole buffer. The ring never recovers, bpf_ringbuf_output() drops every event from then on, and nothing is logged.
Observed on four armv7 devices (i.MX7 Dual, 6.6.52) running a tracepoint-based collector with a 512 KiB ring and 160-byte records. Every one of them stopped delivering after exactly 26846821 records and 4295491360 bytes had passed through the ring, at event rates between 441 and 862 records/s, that is after 8 h to 17 h of uptime: the trigger is the byte count, not time or load. That figure is 2^32 plus 524064 bytes, and the excess is one ring's worth of grace period, as expected while new_prod_pos - pend_pos is still below rb->mask. The last reservation that fits is the largest record boundary X with X + 160 <= 524287, and since 2^32 mod 160 = 96 the boundaries after the wrap sit at X = 64 (mod 160), giving X = 524064. Userspace kept consuming normally until the producer stopped, then read zero records for good. With this patch applied, one of the four devices took 10 GiB through the same ring with no stall, while the three unpatched ones kept wedging at the same byte count.
64-bit hosts are unaffected in practice: their counters would need 16 EiB to wrap.
Compare the two positions as a difference instead. pending_pos never runs ahead of producer_pos, so the unsigned difference is the real distance between them and stays correct across the wrap.
--- kernel/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/ringbuf.c +1 -1
@@ -334,7 +334,7 @@ static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size) prod_pos = rb->producer_pos; new_prod_pos = prod_pos + len; -while (pend_pos < prod_pos) { +while (prod_pos - pend_pos >0 ) { hdr = (void *)rb->data + (pend_pos & rb->mask); hdr_len =READ_ONCE (hdr->len);if (hdr_len &BPF_RINGBUF_BUSY_BIT )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 828/935 crypto: hisilicon/sec2 - fix CCM algorithm long packet failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhushuai Yin <[email protected]>
[ Upstream commit b82f60be50c87b3d75e207852c5ca74fa18f66cf ]
In the CCM B0 block the message-length field Q spans L bytes, where L (cl in the driver) is derived from the cipher IV flags byte as c_ivin[0] + 1. set_aead_auth_iv() hardcoded writing only the last 2 bytes of a_ivin with cryptlen, implicitly assuming cl = 2.
When cl = 3 (a shorter nonce yielding a 3-byte length field) and the packet is longer than 65535 bytes, cryptlen no longer fits in 2 bytes. The dropped high byte made the auth IV built by the driver differ from the one consumed by the hardware, so the software/hardware comparison failed and the CCM request errored out.
Write the last cl bytes of a_ivin in a loop driven by the IV's CL value, so the length-field width always matches the algorithm configuration instead of assuming a fixed 2-byte field.
--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/hisilicon/sec2/sec_crypto.c +6 -6
@@ -95,7 +95,6 @@#define IV_FLAGS_OFFSET 0x6#define IV_CM_OFFSET 0x3#define IV_LAST_BYTE1 1 -#define IV_LAST_BYTE2 2#define IV_LAST_BYTE_MASK 0xFF#define IV_CTR_INIT 0x1#define IV_BYTE_OFFSET 0x8
@@ -1411,7 +1410,7 @@ static void set_aead_auth_iv(struct sec_ctx *ctx, struct sec_req *req)struct sec_cipher_req *c_req = &req->c_req;u32 data_size = aead_req->cryptlen;u8 flage =0 ; -u8 cm, cl; +u8 cm, cl, i;/* the specification has been checked in aead_iv_demension_check() */ cl = c_req->c_ivin[0 ] +1 ;
@@ -1435,15 +1434,16 @@ static void set_aead_auth_iv(struct sec_ctx *ctx, struct sec_req *req)* the last 32bit is counter's initial number, * but the nonce uses the first 16bit * the tail 16bit fill with the cipher length +* When CL is 3, the tail 24bit fill with the cipher length. */ if (!c_req->encrypt) data_size = aead_req->cryptlen - authsize; - a_req->a_ivin[ctx->c_ctx.ivsize -IV_LAST_BYTE1 ] = - data_size &IV_LAST_BYTE_MASK ; - data_size >>=IV_BYTE_OFFSET ; - a_req->a_ivin[ctx->c_ctx.ivsize -IV_LAST_BYTE2 ] = +for (i =1 ; i <= cl; i++) { + a_req->a_ivin[ctx->c_ctx.ivsize - i] = data_size &IV_LAST_BYTE_MASK ; + data_size >>=IV_BYTE_OFFSET ; + } }static void sec_aead_set_iv (struct sec_ctx *ctx,struct sec_req *req)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 829/935 perf dso: Guard close() against invalid fd in dso__decompress_kmodule_path()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 10f452dc2de401be76ae8e7395c9663313df8b53 ]
dso__decompress_kmodule_path() unconditionally calls close(fd) on the return value of decompress_kmodule(). When decompression fails or the DSO is not compressed, decompress_kmodule() returns -1. close(-1) fails with EBADF and clobbers errno, which callers up the chain (dso__get_filename → __open_dso) depend on for error propagation.
Guard the close() call with fd >= 0 so only valid file descriptors are closed.
--- tools/perf/util/dso.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/dso.c +3 -1
@@ -345,7 +345,9 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name, {int fd =decompress_kmodule (dso, name, pathname, len); -close (fd); +/* decompress_kmodule() returns -1 on failure, don't close(-1) */ +if (fd >=0 ) +close (fd);return fd >=0 ?0 :-1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 830/935 perf dso: Guard against cache underflow on short reads in dso_cache__memcpy()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 390a9461cd73bdd13acc0f6d763618ae1ff8fa17 ]
dso_cache__memcpy() computes cache_offset = offset - cache->offset, then cache_size = min(cache->size - cache_offset, size). The RB tree lookup in __dso_cache__find() matches using the full DSO__DATA_CACHE_SIZE window, but cache->size reflects the actual pread return value from dso_cache__populate().
A short pread (e.g. near end-of-file) makes cache->size smaller than DSO__DATA_CACHE_SIZE. If a subsequent access targets an offset past cache->offset + cache->size but within the DSO__DATA_CACHE_SIZE window, the cache entry is found but cache_offset exceeds cache->size. Since both are u64, the subtraction cache->size - cache_offset wraps to a large value, min() selects the caller's size, and memcpy reads out of bounds.
Return 0 for an offset past the valid cached data. For a regular file a short pread only happens at end-of-file, so 0 is what a direct pread() at that offset would return: cached_io() stops its read loop as on EOF. Re-reading from the backing file would not help — a second pread at the same offset returns the same short count.
--- tools/perf/util/dso.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
tools/perf/util/dso.c +14 -1
@@ -860,7 +860,20 @@ static ssize_t dso_cache__memcpy(struct dso_cache *cache, u64 offset, u8 *data, u64 size, bool out) {u64 cache_offset = offset - cache->offset; -u64 cache_size =min (cache->size - cache_offset, size); +u64 cache_size; + +/* +* The RB tree matches using DSO__DATA_CACHE_SIZE, but a short +* pread may leave cache->size smaller. For a regular file a +* short pread only happens at end-of-file, so an offset past +* the valid data is EOF: return 0, matching what a direct +* pread() at that offset would return, and cached_io() then +* stops its read loop. +*/ +if (cache_offset >= cache->size) +return 0 ; + + cache_size =min (cache->size - cache_offset, size);if (out)memcpy (data, cache->data + cache_offset, cache_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 831/935 mailbox: rockchip: disable pclk on probe failure and unbind
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit ded48fcbdc1e3ed1dc8e1974b7fe9639fcea6dd6 ]
rockchip_mbox_probe() enables the peripheral clock and then keeps going. None of the later failure paths - platform_get_irq(), devm_request_threaded_irq() and devm_mbox_controller_register() - disables it again. The driver has no remove callback either, so the clock also stays prepared and enabled once the device is unbound, and its enable count keeps growing over bind/unbind cycles.
Use devm_clk_get_enabled() to tie disabling and unpreparing the clock to the device lifetime. It is registered before the interrupts and the mailbox controller, so devres releases it after both are gone.
While rewriting the error path, switch it to dev_err_probe() so that a deferred probe is not reported as an error.
--- drivers/mailbox/rockchip-mailbox.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/mailbox/rockchip-mailbox.c +4 -13
@@ -207,19 +207,10 @@ static int rockchip_mbox_probe(struct platform_device *pdev)/* Each channel has two buffers for A2B and B2A */ mb->buf_size = (size_t )resource_size (res) / (drv_data->num_chans *2 ); - mb->pclk =devm_clk_get (&pdev->dev,"pclk_mailbox" ); -if (IS_ERR (mb->pclk)) { - ret =PTR_ERR (mb->pclk); -dev_err (&pdev->dev,"failed to get pclk_mailbox clock: %d\n" , - ret); -return ret; - } - - ret =clk_prepare_enable (mb->pclk); -if (ret) { -dev_err (&pdev->dev,"failed to enable pclk: %d\n" , ret); -return ret; - } + mb->pclk =devm_clk_get_enabled (&pdev->dev,"pclk_mailbox" ); +if (IS_ERR (mb->pclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (mb->pclk), +"failed to get and enable pclk_mailbox clock\n" );for (i =0 ; i < mb->mbox.num_chans; i++) { irq =platform_get_irq (pdev, i);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 832/935 hwmon: (emc1403) Add support for EMC1442
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Delphine CC Chiu <[email protected]>
[ Upstream commit 9350163aff24530f2aa3357ee1c7bd8771a443e4 ]
Add support for EMC1442 which is compatible with EMC1402.
Stable-dep-of: 75f2c0b36907 ("hwmon: (emc1403) Drop hysteresis for low limit temperature")
--- drivers/hwmon/emc1403.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/emc1403.c +5 -1
@@ -346,6 +346,9 @@ static int emc1403_detect(struct i2c_client *client,case 0x27 :strlcpy (info->type,"emc1424" ,I2C_NAME_SIZE );break ; +case 0x60 : +strscpy (info->type,"emc1442" ,I2C_NAME_SIZE ); +break ;default :return -ENODEV ; }
@@ -430,7 +433,7 @@ static int emc1403_probe(struct i2c_client *client) }static const unsigned short emc1403_address_list[] = { -0x18 ,0x1c ,0x29 ,0x4c ,0x4d ,0x5c ,I2C_CLIENT_END +0x18 ,0x1c ,0x29 ,0x3c ,0x4c ,0x4d ,0x5c ,I2C_CLIENT_END };/* Last digit of chip name indicates number of channels */
@@ -444,6 +447,7 @@ static const struct i2c_device_id emc1403_idtable[] = { { "emc1422", emc1402 }, { "emc1423", emc1403 }, { "emc1424", emc1404 }, + { "emc1442", emc1402 }, { } };MODULE_DEVICE_TABLE (i2c, emc1403_idtable);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 833/935 smb/server: preserve error status in smb2_handle_negotiate()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhangGuoDong <[email protected]>
[ Upstream commit 73541bd2bab77e7e8e89b1edb5d342f4190dd4d0 ]
smb2_handle_negotiate() records specific failures such as STATUS_INVALID_PARAMETER or STATUS_NOT_SUPPORTED.
--- fs/ksmbd/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ksmbd/smb2pdu.c +2 -2
@@ -1175,7 +1175,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work) GFP_KERNEL);if (!conn->preauth_info) { rc = -ENOMEM ; - rsp->hdr.Status =STATUS_INVALID_PARAMETER ; + rsp->hdr.Status =STATUS_INSUFFICIENT_RESOURCES ; goto err_out; }
@@ -1271,7 +1271,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)ksmbd_conn_set_need_negotiate (conn); err_out: -if (rc) +if (rc && rsp->hdr.Status ==STATUS_SUCCESS ) rsp->hdr.Status =STATUS_INSUFFICIENT_RESOURCES ;if (!rc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 834/935 lwt_bpf: Restore reserved headroom after xmit program
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junseo Lim <[email protected]>
[ Upstream commit 5fe7007aed9ad069b2bd77e5d0c875c64f5c0269 ]
ip_finish_output2() expands an skb to LL_RESERVED_SPACE(dev) before LWT xmit. An LWT_XMIT BPF program can then modify the skb head and still return BPF_OK, so bpf_xmit() rechecks the remaining headroom before the skb continues to neighbour output.
That recheck uses dst->dev->hard_header_len. This is not enough for the neighbour cached-header path: neigh_hh_output() copies the cached hardware header using the aligned hh_cache size, HH_DATA_MOD for short headers or HH_DATA_ALIGN(hh_len) otherwise.
On Ethernet, hard_header_len is 14 but the cached copy needs 16 bytes. If an LWT_XMIT BPF program calls bpf_skb_change_head(skb, 1, 0), the skb can still have 15 bytes of headroom after the program. The existing check accepts that, after which neigh_hh_output() hits its headroom warning and drops the skb.
Use LL_RESERVED_SPACE(dst->dev) in the post-BPF headroom check to match the reservation made before LWT xmit.
--- net/core/lwt_bpf.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/core/lwt_bpf.c +9 -6
@@ -157,10 +157,10 @@ static int bpf_output(struct net *net, struct sock *sk, struct sk_buff *skb)return dst->lwtstate->orig_output (net, sk, skb); } -static int xmit_check_hhlen (struct sk_buff *skb,int hh_len) +static int xmit_check_headroom (struct sk_buff *skb,int hroom) { -if (skb_headroom (skb) < hh_len) { -int nhead =HH_DATA_ALIGN (hh_len -skb_headroom (skb)); +if (skb_headroom (skb) < hroom) { +int nhead = hroom -skb_headroom (skb);if (pskb_expand_head (skb, nhead,0 ,GFP_ATOMIC ))return -ENOMEM ;
@@ -272,7 +272,7 @@ static int bpf_xmit(struct sk_buff *skb) bpf =bpf_lwt_lwtunnel (dst->lwtstate);if (bpf->xmit.prog) { -int hh_len = dst->dev->hard_header_len; +int hroom =LL_RESERVED_SPACE (dst->dev);__be16 proto = skb->protocol;int ret;
@@ -288,9 +288,12 @@ static int bpf_xmit(struct sk_buff *skb)return -EINVAL ; }/* If the header was expanded, headroom might be too -* small for L2 header to come, expand as needed. +* small for the L2 header to come, expand as needed. +* neigh_hh_output() copies the cached header in +* HH_DATA_MOD aligned chunks, so match the reservation +* made before LWT xmit. */ - ret =xmit_check_hhlen (skb, hh_len); + ret =xmit_check_headroom (skb, hroom);if (unlikely (ret))return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 835/935 bpf: Reject negative optlen in cgroup getsockopt hook
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junseo Lim <[email protected]>
[ Upstream commit 1b5aacd5b2419b0790e955e466d389a61c79b4b1 ]
A cgroup getsockopt BPF program can shrink ctx->optlen after the kernel getsockopt handler has run. The kernel-buffer variant, used by TCP_ZEROCOPY_RECEIVE, only rejects values larger than the original length.
If BPF writes a negative optlen, that value is accepted and propagated back to the TCP getsockopt code. It can then be passed to copy_to_sockptr() as a size_t and trigger the hardened usercopy bytes > INT_MAX warning.
Reject negative ctx.optlen in __cgroup_bpf_run_filter_getsockopt_kern(), matching the lower-bound validation already present in the sockptr-based getsockopt hook.
--- kernel/bpf/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/cgroup.c +1 -1
@@ -1661,7 +1661,7 @@ int __cgroup_bpf_run_filter_getsockopt_kern(struct sock *sk, int level,if (!ret)return -EPERM ; -if (ctx.optlen > *optlen) +if (ctx.optlen > *optlen || ctx.optlen <0 )return -EFAULT ;/* BPF programs only allowed to set retval to 0, not some
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 836/935 ksmbd: limit repeated connections from clients with the same IP
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit e6bb9193974059ddbb0ce7763fa3882bd60d4dc3 ]
Repeated connections from clients with the same IP address may exhaust the max connections and prevent other normal client connections. This patch limit repeated connections from clients with the same IP.
Stable-dep-of: 39f203209671 ("smb/server: fix tree connection leak in smb2_tree_connect()")
--- fs/ksmbd/connection.h | 1 + fs/ksmbd/transport_tcp.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
fs/ksmbd/connection.h +1 -0
@@ -45,6 +45,7 @@ struct ksmbd_conn {struct mutex srv_mutex;int status;unsigned int cli_cap; +__be32 inet_addr;char *request_buf;struct ksmbd_transport *transport;struct nls_table *local_nls;
fs/ksmbd/transport_tcp.c +17 -0
@@ -88,6 +88,7 @@ static struct tcp_transport *alloc_transport(struct socket *client_sk)return NULL ; } + conn->inet_addr =inet_sk (client_sk->sk)->inet_daddr; conn->transport =KSMBD_TRANS (t);KSMBD_TRANS (t)->conn = conn;KSMBD_TRANS (t)->ops = &ksmbd_tcp_transport_ops;
@@ -229,6 +230,8 @@ static int ksmbd_kthread_fn(void *p) {struct socket *client_sk =NULL ;struct interface *iface = (struct interface *)p; +struct inet_sock *csk_inet; +struct ksmbd_conn *conn;int ret;while (!kthread_should_stop ()) {
@@ -247,6 +250,20 @@ static int ksmbd_kthread_fn(void *p)continue ; } +/* +* Limits repeated connections from clients with the same IP. +*/ + csk_inet =inet_sk (client_sk->sk); +down_read (&conn_list_lock); +list_for_each_entry (conn, &conn_list, conns_list) +if (csk_inet->inet_daddr == conn->inet_addr) { + ret = -EAGAIN ; +break ; + } +up_read (&conn_list_lock); +if (ret == -EAGAIN ) +continue ; +if (server_conf.max_connections &&atomic_inc_return (&active_num_conn) > server_conf.max_connections) { pr_info_ratelimited("Limit the maximum number of connections(%u)\n",
Signature · 1 line
2.53.0
Re: [PATCH 5.15 836/935] ksmbd: limit repeated connections from clients with the same IP
Please hold this patch unless a 5.15 backport of upstream commit 98a5fd31cbf7 ("ksmbd: close accepted socket when per-IP limit rejects connection") can also be included.
The new -EAGAIN path continues after kernel_accept() without releasing client_sk.
I reproduced this on 5.15.221-rc1 in QEMU: with one connection held open, five rejected connections from the same address left five server-side port-445 sockets in CLOSE_WAIT and raised "sockets: used" from 4 to 9.
With only the applicable 98a5fd31cbf7 hunk applied, the same test left no sockets in CLOSE_WAIT and the used count stayed at 4.
Thanks,
Karl
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 836/935] ksmbd: limit repeated connections from clients with the same IP
Quoted 7 lines · Karl Mehltretter
Please hold this patch unless a 5.15 backport of upstream commit
98a5fd31cbf7("ksmbd: close accepted socket when per-IP limit rejects connection") can also be included.The new
-EAGAINpath continues afterkernel_accept()without releasingclient_sk.
Quoted 7 lines
I reproduced this on 5.15.221-rc1 in QEMU: with one connection held open, five rejected connections from the same address left five server-side port-445 sockets in
CLOSE_WAITand raised "sockets: used" from 4 to 9.With only the applicable
98a5fd31cbf7hunk applied, the same test left no sockets inCLOSE_WAITand the used count stayed at 4.
Now dropped as it really wan't needed here.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 837/935 ksmbd: extend the connection limiting mechanism to support IPv6
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit c0d41112f1a5828c194b59cca953114bc3776ef2 ]
Update the connection tracking logic to handle both IPv4 and IPv6 address families.
Stable-dep-of: 39f203209671 ("smb/server: fix tree connection leak in smb2_tree_connect()")
--- fs/ksmbd/connection.h | 7 ++++++- fs/ksmbd/transport_tcp.c | 26 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-)
fs/ksmbd/connection.h +6 -1
@@ -45,7 +45,12 @@ struct ksmbd_conn {struct mutex srv_mutex;int status;unsigned int cli_cap; -__be32 inet_addr; +union { +__be32 inet_addr; +#if IS_ENABLED (CONFIG_IPV6 ) +u8 inet6_addr[16 ]; +#endif + };char *request_buf;struct ksmbd_transport *transport;struct nls_table *local_nls;
fs/ksmbd/transport_tcp.c +23 -3
@@ -88,7 +88,14 @@ static struct tcp_transport *alloc_transport(struct socket *client_sk)return NULL ; } +#if IS_ENABLED (CONFIG_IPV6 ) +if (client_sk->sk->sk_family ==AF_INET6 ) +memcpy (&conn->inet6_addr, &client_sk->sk->sk_v6_daddr,16 ); +else + conn->inet_addr =inet_sk (client_sk->sk)->inet_daddr; +#else conn->inet_addr =inet_sk (client_sk->sk)->inet_daddr; +#endif conn->transport =KSMBD_TRANS (t);KSMBD_TRANS (t)->conn = conn;KSMBD_TRANS (t)->ops = &ksmbd_tcp_transport_ops;
@@ -230,7 +237,6 @@ static int ksmbd_kthread_fn(void *p) {struct socket *client_sk =NULL ;struct interface *iface = (struct interface *)p; -struct inet_sock *csk_inet;struct ksmbd_conn *conn;int ret;
@@ -253,13 +259,27 @@ static int ksmbd_kthread_fn(void *p)/* * Limits repeated connections from clients with the same IP. */ - csk_inet =inet_sk (client_sk->sk);down_read (&conn_list_lock); list_for_each_entry(conn, &conn_list, conns_list) -if (csk_inet->inet_daddr == conn->inet_addr) { +#if IS_ENABLED (CONFIG_IPV6 ) +if (client_sk->sk->sk_family ==AF_INET6 ) { +if (memcmp (&client_sk->sk->sk_v6_daddr, + &conn->inet6_addr,16 ) ==0 ) { + ret = -EAGAIN ; +break ; + } + }else if (inet_sk (client_sk->sk)->inet_daddr == + conn->inet_addr) { + ret = -EAGAIN ; +break ; + } +#else +if (inet_sk (client_sk->sk)->inet_daddr == + conn->inet_addr) { ret = -EAGAIN ;break ; } +#endif up_read (&conn_list_lock);if (ret == -EAGAIN )continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 838/935 nfs: replace atomic bitops sequence with clear_and_wake_up_bit helper
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaud Bonnet <[email protected]>
[ Upstream commit 61461050da42401b484d03e0fdac02878d235fe6 ]
Commit 8236b0ae31c83 ("bdi: wake up concurrent wb_shutdown() callers.") introduces the clear_and_wake_up_bit() helper as a wrapper for the common clear -> barrier -> wake up bitops sequence.
Use the helper in nfs_clear_invalid_mapping as inode.c already relies on functions from <linux/wait_bit.h> and to homogenize with other subsystems.
--- fs/nfs/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/nfs/inode.c +1 -3
@@ -1382,9 +1382,7 @@ int nfs_clear_invalid_mapping(struct address_space *mapping) ret =nfs_invalidate_mapping (inode, mapping);trace_nfs_invalidate_mapping_exit (inode, ret); -clear_bit_unlock (NFS_INO_INVALIDATING , bitlock); -smp_mb__after_atomic (); -wake_up_bit (bitlock,NFS_INO_INVALIDATING ); +clear_and_wake_up_bit (NFS_INO_INVALIDATING , bitlock); out:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 839/935 nfs: refactor pNFS functions using clear_and_wake_up_bit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaud Bonnet <[email protected]>
[ Upstream commit 187bfc974eefa9e5d88a0b4ee9d08ae8fe485df4 ]
Commit 8236b0ae31c83 ("bdi: wake up concurrent wb_shutdown() callers.") introduces the clear_and_wake_up_bit() helper as a wrapper for the common clear -> barrier -> wake up bitops sequence.
The file pnfs.c has several helpers with identical contents. Thus they are replaced with the more recent clean_and_wake_up_bit() global helper which describes accurately its effects at the call and still specifies the cleared bit. This also homogenizes the code with other subsystems.
Since the helpers are no longer used after this, they can be safely removed.
--- fs/nfs/pnfs.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-)
fs/nfs/pnfs.c +10 -25
@@ -1940,15 +1940,6 @@ static bool pnfs_is_first_layoutget(struct pnfs_layout_hdr *lo)return test_bit (NFS_LAYOUT_FIRST_LAYOUTGET , &lo->plh_flags); } -static void pnfs_clear_first_layoutget (struct pnfs_layout_hdr *lo) -{ -unsigned long *bitlock = &lo->plh_flags; - -clear_bit_unlock (NFS_LAYOUT_FIRST_LAYOUTGET , bitlock); -smp_mb__after_atomic (); -wake_up_bit (bitlock,NFS_LAYOUT_FIRST_LAYOUTGET ); -} -static void _add_to_server_list (struct pnfs_layout_hdr *lo,struct nfs_server *server) {
@@ -2122,7 +2113,8 @@ pnfs_update_layout(struct inode *ino, iomode, lo, lseg, PNFS_UPDATE_LAYOUT_INVALID_OPEN);nfs4_schedule_stateid_recovery (server, ctx->state); -pnfs_clear_first_layoutget (lo); +clear_and_wake_up_bit (NFS_LAYOUT_FIRST_LAYOUTGET , + &lo->plh_flags);pnfs_put_layout_hdr (lo); goto lookup_again; }
@@ -2189,7 +2181,8 @@ pnfs_update_layout(struct inode *ino, }if (lseg) {if (first) -pnfs_clear_first_layoutget (lo); +clear_and_wake_up_bit (NFS_LAYOUT_FIRST_LAYOUTGET , + &lo->plh_flags);trace_pnfs_update_layout (ino, pos, count, iomode, lo, lseg,PNFS_UPDATE_LAYOUT_RETRY );pnfs_put_layout_hdr (lo);
@@ -2201,7 +2194,7 @@ pnfs_update_layout(struct inode *ino, out_put_layout_hdr:if (first) -pnfs_clear_first_layoutget (lo); +clear_and_wake_up_bit (NFS_LAYOUT_FIRST_LAYOUTGET , &lo->plh_flags);trace_pnfs_update_layout (ino, pos, count, iomode, lo, lseg,PNFS_UPDATE_LAYOUT_EXIT );pnfs_put_layout_hdr (lo);
@@ -2293,7 +2286,7 @@ static void _lgopen_prepare_attached(struct nfs4_opendata *data, lgp =pnfs_alloc_init_layoutget_args (ino, ctx, ¤t_stateid, &rng,GFP_KERNEL );if (!lgp) { -pnfs_clear_first_layoutget (lo); +clear_and_wake_up_bit (NFS_LAYOUT_FIRST_LAYOUTGET , &lo->plh_flags);nfs_layoutget_end (lo);pnfs_put_layout_hdr (lo);return ;
@@ -2397,7 +2390,8 @@ void nfs4_lgopen_release(struct nfs4_layoutget *lgp) {if (lgp !=NULL ) {if (lgp->lo) { -pnfs_clear_first_layoutget (lgp->lo); +clear_and_wake_up_bit (NFS_LAYOUT_FIRST_LAYOUTGET , + &lgp->lo->plh_flags);nfs_layoutget_end (lgp->lo); }pnfs_layoutget_free (lgp);
@@ -3122,15 +3116,6 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc) }EXPORT_SYMBOL_GPL (pnfs_generic_pg_readpages); -static void pnfs_clear_layoutcommitting (struct inode *inode) -{ -unsigned long *bitlock = &NFS_I (inode)->flags; - -clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); -smp_mb__after_atomic (); -wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); -} -/* * There can be multiple RW segments. */
@@ -3155,7 +3140,7 @@ static void pnfs_list_write_lseg_done(struct inode *inode, struct list_head *lispnfs_put_lseg (lseg); } -pnfs_clear_layoutcommitting (inode); +clear_and_wake_up_bit (NFS_INO_LAYOUTCOMMITTING , &NFS_I (inode)->flags); }void pnfs_set_lo_fail (struct pnfs_layout_segment *lseg)
@@ -3295,7 +3280,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)spin_unlock (&inode->i_lock);kfree (data); clear_layoutcommitting: -pnfs_clear_layoutcommitting (inode); +clear_and_wake_up_bit (NFS_INO_LAYOUTCOMMITTING , &NFS_I (inode)->flags); goto out; }EXPORT_SYMBOL_GPL (pnfs_layoutcommit_inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 840/935 NFSv4: remove callback IDR entry on client allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit d05c2007b3d84ccba11dc6e9cb3202768cc72f14 ]
nfs4_alloc_client() allocates an NFSv4.0 callback identifier before it finishes setting up the client. If any later initialization step fails, the error path frees the nfs_client directly with nfs_free_client(). That bypasses nfs_put_client(), which is where the callback IDR entry is removed during normal teardown.
A failed allocation can therefore leave cb_ident_idr pointing at a freed nfs_client. A later NFSv4.0 callback lookup by cb_ident would find the stale pointer and take a reference to it.
Make the callback IDR removal helper callable by the allocation failure path, and remove the callback identifier before freeing the client.
This was found by a local static-analysis checker for publish-before-free lifetime bugs and confirmed by manual inspection.
--- fs/nfs/client.c | 14 +++++++++++++- fs/nfs/internal.h | 1 + fs/nfs/nfs4client.c | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)
fs/nfs/client.c +13 -1
@@ -209,9 +209,21 @@ static void nfs_cb_idr_remove_locked(struct nfs_client *clp) {struct nfs_net *nn =net_generic (clp->cl_net, nfs_net_id); -if (clp->cl_cb_ident) +if (clp->cl_cb_ident) {idr_remove (&nn->cb_ident_idr, clp->cl_cb_ident); + clp->cl_cb_ident =0 ; + } +} + +void nfs_cb_idr_remove (struct nfs_client *clp) +{ +struct nfs_net *nn =net_generic (clp->cl_net, nfs_net_id); + +spin_lock (&nn->nfs_client_lock); +nfs_cb_idr_remove_locked (clp); +spin_unlock (&nn->nfs_client_lock); } +EXPORT_SYMBOL_GPL (nfs_cb_idr_remove);static void pnfs_init_server (struct nfs_server *server) {
fs/nfs/internal.h +1 -0
@@ -214,6 +214,7 @@ void nfs_server_copy_userdata(struct nfs_server *, struct nfs_server *);extern void nfs_put_client (struct nfs_client *);extern void nfs_free_client (struct nfs_client *); +void nfs_cb_idr_remove (struct nfs_client *clp);extern struct nfs_client *nfs4_find_client_ident (struct net *,int );extern struct nfs_client * nfs4_find_client_sessionid(struct net *, const struct sockaddr *,
fs/nfs/nfs4client.c +1 -0
@@ -268,6 +268,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)return clp; error: +nfs_cb_idr_remove (clp);nfs_free_client (clp);return ERR_PTR (err); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 841/935 net: kcm: Hold RCU read lock while running BPF parser
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junseo Lim <[email protected]>
[ Upstream commit b0346dd64e4905291cc9c479f2e6cf1884ced4e6 ]
kcm_parse_func_strparser() calls bpf_prog_run_pin_on_cpu() which prevents CPU migration, but does not establish an RCU read-side critical section. Consequently, BPF map operations can trigger WARN_ON_ONCE(!bpf_rcu_lock_held()) when called from the KCM strparser program.
Hold the RCU read lock while running the program.
--- net/kcm/kcmsock.c | 3 +++ 1 file changed, 3 insertions(+)
net/kcm/kcmsock.c +3 -0
@@ -5,6 +5,7 @@* Copyright (c) 2016 Tom Herbert <[email protected]> */ +#include <linux/rcupdate.h> #include <linux/bpf.h> #include <linux/errno.h> #include <linux/errqueue.h>
@@ -385,7 +386,9 @@ static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)struct bpf_prog *prog = psock->bpf_prog;int res; +rcu_read_lock (); res =bpf_prog_run_pin_on_cpu (prog, skb); +rcu_read_unlock ();return res; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 842/935 pppox: drain queued packets on channel handoff
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 92c1bf630abf0af646562398eaa36f80b5ff677d ]
PPPIOCGCHAN both returns the channel index and marks a PPPOX socket as bound to generic PPP, despite its getter semantic. Packets received before that transition are queued on sk_receive_queue, but a bound socket is no longer readable. Such packets therefore remain queued until the socket is destroyed.
After marking a socket bound, wait for receive paths that observed the old state to finish queueing packets, and then drain the queue into generic PPP.
--- drivers/net/ppp/pppox.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/ppp/pppox.c +17 -0
@@ -74,7 +74,9 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)switch (cmd) {case PPPIOCGCHAN : { +struct sk_buff *skb;int index; + rc = -ENOTCONN ;if (!(sk->sk_state &PPPOX_CONNECTED ))break ;
@@ -85,7 +87,22 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)break ; rc =0 ; +/* PPPIOCGCHAN historically marks the userspace handoff to +* generic PPP; pppd then attaches the returned channel to +* /dev/ppp. +*/ sk->sk_state |=PPPOX_BOUND ; +/* Let lockless receive paths finish queueing against the old +* state. +*/ +synchronize_net (); +/* Drain packets queued before the handoff because a bound +* socket is no longer readable. +*/ +while ((skb =skb_dequeue (&sk->sk_receive_queue))) { +skb_orphan (skb); +ppp_input (&po->chan, skb); + }break ; }default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 843/935 hsr: Use a single struct for self_node.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 20d3c1e9b861b85e1a774e1876d6adeeb0251fc3 ]
self_node_db is a list_head with one entry of struct hsr_node. The purpose is to hold the two MAC addresses of the node itself. It is convenient to recycle the structure. However having a list_head and fetching always the first entry is not really optimal.
Created a new data strucure contaning the two MAC addresses named hsr_self_node. Access that structure like an RCU protected pointer so it can be replaced on the fly without blocking the reader.
Stable-dep-of: 7f16289b91eb ("net: hsr: free learned nodes on device setup failure")
--- net/hsr/hsr_device.c | 1 - net/hsr/hsr_framereg.c | 63 +++++++++++++++++++----------------------- net/hsr/hsr_main.h | 8 +++++- 3 files changed, 35 insertions(+), 37 deletions(-)
net/hsr/hsr_device.c +0 -1
@@ -637,7 +637,6 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], hsr =netdev_priv (hsr_dev);INIT_LIST_HEAD (&hsr->ports);INIT_LIST_HEAD (&hsr->node_db); -INIT_LIST_HEAD (&hsr->self_node_db);spin_lock_init (&hsr->list_lock);eth_hw_addr_set (hsr_dev, slave[0 ]->dev_addr);
net/hsr/hsr_framereg.c +28 -35
99 lines not on this page · raw message
net/hsr/hsr_main.h +7 -1
@@ -192,11 +192,17 @@ struct hsr_proto_ops {void (*update_san_info)(struct hsr_node *node,bool is_sup); }; +struct hsr_self_node { +unsigned char macaddress_A[ETH_ALEN ]; +unsigned char macaddress_B[ETH_ALEN ]; +struct rcu_head rcu_head; +}; +struct hsr_priv {struct rcu_head rcu_head;struct list_head ports;struct list_head node_db;/* Known HSR nodes */ -struct list_head self_node_db;/* MACs of slaves */ +struct hsr_self_node __rcu *self_node;/* MACs of slaves */ struct timer_list announce_timer;/* Supervision frame dispatch */ struct timer_list prune_timer;int announce_count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 844/935 net: hsr: Use full string description when opening HSR network device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukasz Majewski <[email protected]>
[ Upstream commit 10e52ad5ced2a7dcdb3fb18c9cef111d5f30471d ]
Up till now only single character ('A' or 'B') was used to provide information of HSR slave network device status.
As it is also possible and valid, that Interlink network device may be supported as well, the description must be more verbose. As a result the full string description is now used.
Stable-dep-of: 7f16289b91eb ("net: hsr: free learned nodes on device setup failure")
--- net/hsr/hsr_device.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
net/hsr/hsr_device.c +6 -7
@@ -142,30 +142,29 @@ static int hsr_dev_open(struct net_device *dev) {struct hsr_priv *hsr;struct hsr_port *port; -char designation; +const char *designation =NULL ; hsr =netdev_priv (dev); - designation ='\0' ;hsr_for_each_port_rtnl (hsr, port) {if (port->type ==HSR_PT_MASTER )continue ;switch (port->type) {case HSR_PT_SLAVE_A : - designation ='A' ; + designation ="Slave A" ;break ;case HSR_PT_SLAVE_B : - designation ='B' ; + designation ="Slave B" ;break ;default : - designation ='?' ; + designation ="Unknown" ; }if (!is_slave_up (port->dev)) -netdev_warn (dev,"Slave %c (%s) is not up; please bring it up to get a fully working HSR network\n" , +netdev_warn (dev,"%s (%s) is not up; please bring it up to get a fully working HSR network\n" , designation, port->dev->name); } -if (designation =='\0' ) +if (!designation)netdev_warn (dev,"No slave devices configured\n" );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 845/935 ipvs: fix integer overflow in ftp helper port/address parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit e625a9477d12baaff4025c5f9989184a907ea8fc ]
ip_vs_ftp_get_addrport() accumulates decimal digits into a __u16 (hport) and into unsigned char (p[]) without checking for overflow. A crafted FTP PASV/EPSV response with an over-long port or address octet wraps the value, so the helper configures the data connection with a truncated port/address.
The netfilter conntrack FTP helper had the same defect, fixed in commit 2b413fc689ba ("netfilter: nf_conntrack_ftp: avoid u16 overflows"). Apply the equivalent fix here: widen the port accumulator to u32 and reject values above 65535, and reject address octets above 255.
--- net/netfilter/ipvs/ip_vs_ftp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/netfilter/ipvs/ip_vs_ftp.c +8 -2
@@ -103,7 +103,7 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit,char *s, c;unsigned char p[6 ];char edelim; -__u16 hport; +__u32 hport;int i =0 ;if (data_limit - data < plen) {
@@ -145,7 +145,11 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit,return -1 ; c = *data;if (isdigit (c)) { - p[i] = p[i]*10 + c -'0' ; +unsigned int val = p[i] *10 + c -'0' ; + +if (val >255 ) +return -1 ; + p[i] = val; }else if (c ==',' && i <5 ) { i++; p[i] =0 ;
@@ -223,6 +227,8 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit,if (!isdigit (*s))break ; hport = hport *10 + *s -'0' ; +if (hport >65535 ) +return -1 ; }if (s == data_limit || !hport || *s != edelim)return -1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 846/935 net: bridge: vlan: fix inverted default vlan notification
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 21040c7f931502070dcc66bb0f1aeed07dec032b ]
A notification should be emitted only when the vlan delete was successful and not otherwise. The proper check is if br/nbp_vlan_delete returned 0.
--- net/bridge/br_vlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_vlan.c +2 -2
@@ -1072,7 +1072,7 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,if (err) goto out; -if (br_vlan_delete (br, old_pvid)) +if (!br_vlan_delete (br, old_pvid))br_vlan_notify (br,NULL , old_pvid,0 ,RTM_DELVLAN );br_vlan_notify (br,NULL , pvid,0 ,RTM_NEWVLAN );set_bit (0 , changed);
@@ -1094,7 +1094,7 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid, &vlchange, extack);if (err) goto err_port; -if (nbp_vlan_delete (p, old_pvid)) +if (!nbp_vlan_delete (p, old_pvid))br_vlan_notify (br, p, old_pvid,0 ,RTM_DELVLAN );br_vlan_notify (p->br, p, pvid,0 ,RTM_NEWVLAN );set_bit (p->port_no, changed);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 847/935 cuse: wait for pending RCU callbacks on module exit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 4deb3edead0c0e172cc7349e8855d741d3c5e162 ]
Since commit 053fc4f755ad ("fuse: fix UAF in rcu pathwalks"), fuse_conn_put() frees the fuse_conn through call_rcu() rather than synchronously. For cuse, fc->release is cuse_fc_release(), which lives in the cuse module. If the module is removed before the RCU grace period ends, the callback jumps into freed module memory:
userspace / module unload | RCU softirq
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
close(/dev/cuse) |
cuse_channel_release() |
fuse_dev_release() |
fuse_conn_put(fch->conn) |
call_rcu(delayed_release) ------+---> callback queued
|
rmmod cuse |
cuse_exit() |
cuse_channel_destroy() |
... |
return |
|
<module text freed> |
| rcu_do_batch()
| delayed_release()
| fc->release()
| -> cuse_fc_release()
| ^^^ freed text!The freed module text is unmapped by vfree(), so the jump into the stale callback triggers a page-fault Oops. If the virtual address is subsequently reused, the callback could execute unrelated code (undefined behaviour).
Fix this by calling rcu_barrier() in cuse_exit() so that any pending fuse_conn release callback completes before the module is removed.
--- fs/fuse/cuse.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/fuse/cuse.c +5 -0
@@ -646,6 +646,11 @@ static void __exit cuse_exit(void) {misc_deregister (&cuse_miscdev);class_destroy (cuse_class); +/* +* Wait for pending call_rcu() callbacks that call back into +* this module via fc->release (cuse_fc_release). +*/ +rcu_barrier (); }module_init (cuse_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 848/935 fs/ntfs3: fix out-of-bounds read in read_log_rec_buf()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit de603b9d377fab57a5e6432fa84a9f36b32c1636 ]
read_log_rec_buf() copies a log record into a caller buffer starting at
u32 off = lsn_to_page_off(log, lsn) + log->record_header_len;
log->record_header_len (and log->data_off, used for the following pages) comes verbatim from the on-disk restart area and is only checked for 8-byte alignment in is_rst_area_valid(), so off can exceed log->page_size. "tail = log->page_size - off" then underflows and memcpy() reads past the page_size-sized buffer returned by read_log_page(), spilling adjacent slab memory into the replay buffer.
This is reachable by mounting a crafted NTFS image:
BUG: KASAN: slab-out-of-bounds in read_log_rec_buf+0x216/0x580 Read of size 64 at addr ffff88800a877ff8 by task exploit/127 read_log_rec_buf fs/ntfs3/fslog.c:2299 log_replay fs/ntfs3/fslog.c:4216 ntfs_loadlog_and_replay fs/ntfs3/fsntfs.c:324 ntfs_fill_super fs/ntfs3/super.c:1392 get_tree_bdev_flags fs/super.c:1694 __x64_sys_mount fs/namespace.c:4360 The buggy address is located 4088 bytes to the right of the 4096-byte region [ffff88800a876000, ffff88800a877000)
Reject an in-page offset outside the current page before the copy.
--- fs/ntfs3/fslog.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/ntfs3/fslog.c +9 -1
@@ -2303,7 +2303,15 @@ static int read_log_rec_buf(struct ntfs_log *log,*/ for (;;) {bool usa_error; -u32 tail = log->page_size - off; +u32 tail; + +/* off comes from the on-disk restart area; bound it. */ +if (off > log->page_size) { + err = -EINVAL ; + goto out; + } + + tail = log->page_size - off;if (tail >= data_len) tail = data_len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 849/935 fs/ntfs3: validate ef->size covers the records name and value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit c22f91d82cb9a29d22bdffdce6c803467984ad0c ]
When an EA record has a non-zero ef->size, ntfs_read_ea() only checks that the record fits in the remaining buffer (ea_size > bytes), not that ef->size is large enough to hold the record's own name_len + 1 + elength.
A crafted image can pass validation with, e.g., ef->size = 24 but elength = 0xffff. ntfs_get_ea() then trusts elength and copies it out of the undersized record, reading past the kmalloc(info->size) allocation and leaking heap memory to userspace via getxattr():
BUG: KASAN: slab-out-of-bounds in ntfs_get_ea (fs/ntfs3/xattr.c:302) Read of size 65535 at addr ffff888100794550 by task exploit __asan_memcpy (mm/kasan/shadow.c:105) ntfs_get_ea (fs/ntfs3/xattr.c:302) ntfs_getxattr (fs/ntfs3/xattr.c:848) __vfs_getxattr (fs/xattr.c:441) vfs_getxattr (fs/xattr.c:474) do_getxattr (fs/xattr.c:800) path_getxattrat (fs/xattr.c:868) do_syscall_64 (arch/x86/entry/syscall_64.c:94)
The buggy address is located 80 bytes inside of
allocated 84-byte region in cache kmalloc-96
Compute the size the record needs and require ef->size to cover it.
--- fs/ntfs3/xattr.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
fs/ntfs3/xattr.c +12 -9
@@ -145,26 +145,29 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,for (off =0 ; off < size; off += ea_size) {const struct EA_FULL *ef =Add2Ptr (ea_p, off);u32 bytes = size - off; +size_t need;/* Check if we can use field ea->size. */ if (bytes <sizeof (ef->size)) goto out1; +/* Check if we can use fields ef->name_len and ef->elength. */ +if (bytes < offsetof(struct EA_FULL , name)) + goto out1; + +/* Size needed to hold this record's name and value. */ + need =struct_size (ef, name, +1 + ef->name_len +le16_to_cpu (ef->elength)); +if (ef->size) { ea_size =le32_to_cpu (ef->size); -if (ea_size > bytes) +/* ef->size must fit the list and cover the record. */ +if (ea_size > bytes || ea_size < need) goto out1;continue ; } -/* Check if we can use fields ef->name_len and ef->elength. */ -if (bytes < offsetof(struct EA_FULL , name)) - goto out1; - - ea_size =ALIGN (struct_size (ef, name, -1 + ef->name_len + -le16_to_cpu (ef->elength)), -4 ); + ea_size =ALIGN (need,4 );if (ea_size > bytes) goto out1; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 850/935 ALSA: hda: Fix connection list comparison in proc output
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <[email protected]>
[ Upstream commit c139e7e44f58a6f8ddc9d850ea9924d34963b5da ]
print_conn_list() compares the raw hardware connection list with the connection list cached by the HDA driver. When they differ, it prints an additional "In-driver Connection" line so that /proc/asound/card*/codec#* shows the topology actually used by the driver.
The comparison currently passes conn_len directly to memcmp(). However, conn_len is a number of connection-list entries, while memcmp() expects a size in bytes. Both list and conn are arrays of hda_nid_t, which is u16, so only half of the connection data is compared.
For example, for two-entry lists such as:
hardware: 0x0c 0x0d
cached: 0x0c 0x0e
conn_len is 2, and the current comparison checks only the first hda_nid_t. The lists are therefore incorrectly treated as identical even though the second connection differs.
This can happen legitimately when codec fixups replace a cached connection list with snd_hda_override_conn_list(). The codec routing used by the driver is not affected, but the proc output can hide the overridden driver-visible routing and provide misleading topology information during codec debugging.
Convert the entry count to a byte size so that memcmp() covers the complete connection list.
--- sound/pci/hda/hda_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/hda_proc.c +1 -1
@@ -624,7 +624,7 @@ static void print_conn_list(struct snd_info_buffer *buffer,/* Get Cache connections info */ cache_len =snd_hda_get_conn_list (codec, nid, &list);if (cache_len >=0 && (cache_len != conn_len || -memcmp (list, conn, conn_len) !=0 )) { +memcmp (list, conn, conn_len *sizeof (*conn)) !=0 )) {snd_iprintf (buffer," In-driver Connection: %d\n" , cache_len);if (cache_len >0 ) {snd_iprintf (buffer," " );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 851/935 8139cp: fix Rx and Tx not being disabled in cp_suspend
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit cb7643b78d35392f0f434774d78b4c77b80f677f ]
On QEMU rtl8139 model, frames that arrive while the interface is suspended still end up in the stack after resume. With pm_test=devices, which keeps devices suspended for 5s, 200 frames sent to interface during that time and 50 frames after resume, eth0 reports 113 received frames.
cp_suspend() is supposed to stop receiver and the transmitter, but the mask is wrong: (~RxOn | ~TxOn) is ~0, nothing is cleared and Cmd still reads 0x0d when cp_suspend() returns.
Use ~(RxOn | TxOn) so both bits are actually cleared.
--- drivers/net/ethernet/realtek/8139cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/realtek/8139cp.c +1 -1
@@ -2063,7 +2063,7 @@ static int __maybe_unused cp_suspend(struct device *device)/* Disable Rx and Tx */ cpw16 (IntrMask,0 ); -cpw8 (Cmd,cpr8 (Cmd) & (~RxOn | ~TxOn)); +cpw8 (Cmd,cpr8 (Cmd) & ~(RxOn | TxOn));spin_unlock_irqrestore (&cp->lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 852/935 platform/x86: dell-wmi-sysman: Fix instance ID bounds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 5ab078e3241da0beec2022254b5811a8a52cff84 ]
The get_instance_id() macro walks the per-type attribute array with 'i <= instances_count'. Each array is allocated with exactly instances_count entries, so the valid range is [0, instances_count) and the last iteration reads one element past the end. On a name miss that out-of-bounds attribute_name is handed to strcmp(), which reads on until it finds a NUL byte.
Every kobject in these ksets is built from an entry that was populated, so a miss does not look reachable from sysfs today. The bound is wrong either way and the read is out of bounds.
The matching macro in hp-bioscfg carried the same off-by-one and was corrected by commit 25150715e0b0 ("platform/x86: hp-bioscfg: Fix kernel panic in GET_INSTANCE_ID macro"). That macro takes a kobject pointer out of the out-of-bounds element and dereferences it, so it could fault. This one reads a char array.
Use '<' to match the allocation.
--- drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +1 -1
@@ -107,7 +107,7 @@ enum { static int get_##type##_instance_id(struct kobject *kobj) \ { \ int i; \ - for (i = 0; i <= wmi_priv.type##_instances_count; i++) { \ + for (i = 0; i < wmi_priv.type##_instances_count; i++) { \ if (!(strcmp(kobj->name, wmi_priv.type##_data[i].attribute_name)))\ return i; \ } \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 853/935 vsock: use sock_error() to consume sk_err after a failed connect
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Dinh Phi <[email protected]>
[ Upstream commit 96cbf89993091a163bfedec52a3bd683dc94b3b4 ]
vsock_connect() returns sk_err to userspace but does not clear it:
if (sk->sk_err) {
err = -sk->sk_err;For a blocking connect() the error has already been delivered as connect()'s return value, so leaving it set causes subsequent operations like poll()/epoll() to keep reporting POLLERR even though the connect failure was already delivered.
The error should be consumed once it has been returned to userspace. Switch to sock_error(), which reads and clears sk_err atomically, matching the behavior of other protocol implementations such as __inet_stream_connect().
--- net/vmw_vsock/af_vsock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/vmw_vsock/af_vsock.c +2 -4
@@ -1533,12 +1533,10 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,prepare_to_wait (sk_sleep (sk), &wait,TASK_INTERRUPTIBLE ); } -if (sk->sk_err) { - err = -sk->sk_err; + err =sock_error (sk); +if (err) { sk->sk_state =TCP_CLOSE ; sock->state =SS_UNCONNECTED ; - }else { - err =0 ; } out_wait:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 854/935 bonding: initialize err for empty target lists
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 8ccc9bf9afeeb46a437081c07154fbf5964682b2 ]
Empty NLA_NESTED attributes are valid, and bonding uses them to clear the ARP and NS target lists. When either target attribute is empty, nla_for_each_nested() does not execute, so err retains an uninitialized value before it is tested. The request can consequently return an unpredictable error after clearing the targets.
Initialize err to zero so an empty target list completes successfully. Non-empty lists still propagate errors from __bond_opt_set() unchanged.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/net/bonding/bond_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_netlink.c +1 -1
@@ -169,7 +169,7 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],struct bonding *bond =netdev_priv (bond_dev);struct bond_opt_value newval;int miimon =0 ; -int err; +int err =0 ;if (!data)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 855/935 i3c: mipi-i3c-hci: Fix DAT/DCT entry sizes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Nikula <[email protected]>
[ Upstream commit 0676bfebf5766f0a60549f74ba597115028fa39c ]
MIPI I3C HCI specification v1.1 describes the ENTRY_SIZE field for the Device Address Table (DAT) and the Device Characteristics Table (DCT) section offset registers (DAT_SECTION_OFFSET and DCT_SECTION_OFFSET). That field is not documented in earlier version.
ENTRY_SIZE value 0 is meant to be backward compatible. For the DAT entry size it is interpreted as 2 DWORDs (8-bytes) and for the DCT entry size as 4 DWORDs (16-bytes). Values 1-15 are reserved for future use.
New version I believe fixes also the TABLE_SIZE field description. Before it was defined in DWORDs which I believe is incorrect since the DAT/DCT table entry structures, and sizes, are described having 8-bytes/16-bytes entries.
This is more clear in the specification v1.1 which states the TABLE_SIZE fields are interpreted as number of entries in the DAT/DCT tables. I believe this same holds also in earlier version, at least it makes more sense.
Fix code accordingly and let the DAT_entry_size and the DCT_entry_size variables carry the size as bytes. Which is how it is already interpreted in the dat_v1.c: hci_dat_v1_init().
Stable-dep-of: 308ecb824db3 ("i3c: mipi-i3c-hci: Fix missing STAT_IBI_STATUS_THLD in PIO mode")
--- drivers/i3c/master/mipi-i3c-hci/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +4 -4
@@ -610,17 +610,17 @@ static int i3c_hci_init(struct i3c_hci *hci) offset =FIELD_GET (DAT_TABLE_OFFSET , regval); hci->DAT_regs = offset ? hci->base_regs + offset :NULL ; hci->DAT_entries =FIELD_GET (DAT_TABLE_SIZE , regval); - hci->DAT_entry_size =FIELD_GET (DAT_ENTRY_SIZE , regval); + hci->DAT_entry_size =FIELD_GET (DAT_ENTRY_SIZE , regval) ?0 :8 ;dev_info (&hci->master.dev,"DAT: %u %u-bytes entries at offset %#x\n" , - hci->DAT_entries, hci->DAT_entry_size *4 , offset); + hci->DAT_entries, hci->DAT_entry_size, offset); regval =reg_read (DCT_SECTION ); offset =FIELD_GET (DCT_TABLE_OFFSET , regval); hci->DCT_regs = offset ? hci->base_regs + offset :NULL ; hci->DCT_entries =FIELD_GET (DCT_TABLE_SIZE , regval); - hci->DCT_entry_size =FIELD_GET (DCT_ENTRY_SIZE , regval); + hci->DCT_entry_size =FIELD_GET (DCT_ENTRY_SIZE , regval) ?0 :16 ;dev_info (&hci->master.dev,"DCT: %u %u-bytes entries at offset %#x\n" , - hci->DCT_entries, hci->DCT_entry_size *4 , offset); + hci->DCT_entries, hci->DCT_entry_size, offset); regval =reg_read (RING_HEADERS_SECTION ); offset =FIELD_GET (RING_HEADERS_OFFSET , regval);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 856/935 i3c: mipi-i3c-hci: Fix number of DAT/DCT entries for HCI versions < 1.1
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Nikula <[email protected]>
[ Upstream commit be90ae1ba14a83962b33c4d4c854ef081186b0e4 ]
I was wrong about the TABLE_SIZE field description in the commit 0676bfebf576 ("i3c: mipi-i3c-hci: Fix DAT/DCT entry sizes").
For the MIPI I3C HCI versions 1.0 and earlier the TABLE_SIZE field in the registers DAT_SECTION_OFFSET and DCT_SECTION_OFFSET is indeed defined in DWORDs and not number of entries like it is defined in later versions.
Where above fix allowed driver initialization to continue the wrongly interpreted TABLE_SIZE field leads variables DAT_entries being twice and DCT_entries four times as big as they really are.
That in turn leads clearing the DAT table over the boundary in the dat_v1.c: hci_dat_v1_init().
So interprete the TABLE_SIZE field in DWORDs for HCI versions < 1.1 and fix number of DAT/DCT entries accordingly.
Stable-dep-of: 308ecb824db3 ("i3c: mipi-i3c-hci: Fix missing STAT_IBI_STATUS_THLD in PIO mode")
--- drivers/i3c/master/mipi-i3c-hci/core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/i3c/master/mipi-i3c-hci/core.c +8 -0
@@ -583,6 +583,7 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)static int i3c_hci_init (struct i3c_hci *hci) {u32 regval, offset; +bool size_in_dwords;int ret;/* Validate HCI hardware version */
@@ -606,11 +607,16 @@ static int i3c_hci_init(struct i3c_hci *hci) hci->caps =reg_read (HC_CAPABILITIES );DBG ("caps = %#x" , hci->caps); + size_in_dwords = hci->version_major <1 || + (hci->version_major ==1 && hci->version_minor <1 ); + regval =reg_read (DAT_SECTION ); offset =FIELD_GET (DAT_TABLE_OFFSET , regval); hci->DAT_regs = offset ? hci->base_regs + offset :NULL ; hci->DAT_entries =FIELD_GET (DAT_TABLE_SIZE , regval); hci->DAT_entry_size =FIELD_GET (DAT_ENTRY_SIZE , regval) ?0 :8 ; +if (size_in_dwords) + hci->DAT_entries =4 * hci->DAT_entries / hci->DAT_entry_size;dev_info (&hci->master.dev,"DAT: %u %u-bytes entries at offset %#x\n" , hci->DAT_entries, hci->DAT_entry_size, offset);
@@ -619,6 +625,8 @@ static int i3c_hci_init(struct i3c_hci *hci) hci->DCT_regs = offset ? hci->base_regs + offset :NULL ; hci->DCT_entries =FIELD_GET (DCT_TABLE_SIZE , regval); hci->DCT_entry_size =FIELD_GET (DCT_ENTRY_SIZE , regval) ?0 :16 ; +if (size_in_dwords) + hci->DCT_entries =4 * hci->DCT_entries / hci->DCT_entry_size;dev_info (&hci->master.dev,"DCT: %u %u-bytes entries at offset %#x\n" , hci->DCT_entries, hci->DCT_entry_size, offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 857/935 i3c: mipi-i3c-hci: Quieten initialization messages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 581d5b7953b8f24d2f379c8c56ceaa7d163488ce ]
The copious initialization messages are at most useful only for debugging. Change them from dev_info() or dev_notice() to dev_dbg().
Stable-dep-of: 308ecb824db3 ("i3c: mipi-i3c-hci: Fix missing STAT_IBI_STATUS_THLD in PIO mode")
--- drivers/i3c/master/mipi-i3c-hci/core.c | 18 +++---- drivers/i3c/master/mipi-i3c-hci/dma.c | 4 +- drivers/i3c/master/mipi-i3c-hci/ext_caps.c | 55 ++++++++++------------ drivers/i3c/master/mipi-i3c-hci/pio.c | 16 +++---- 4 files changed, 45 insertions(+), 48 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +9 -9
@@ -617,8 +617,8 @@ static int i3c_hci_init(struct i3c_hci *hci) hci->DAT_entry_size =FIELD_GET (DAT_ENTRY_SIZE , regval) ?0 :8 ;if (size_in_dwords) hci->DAT_entries =4 * hci->DAT_entries / hci->DAT_entry_size; -dev_info (&hci->master.dev,"DAT: %u %u-bytes entries at offset %#x\n" , - hci->DAT_entries, hci->DAT_entry_size, offset); +dev_dbg (&hci->master.dev,"DAT: %u %u-bytes entries at offset %#x\n" , + hci->DAT_entries, hci->DAT_entry_size, offset); regval =reg_read (DCT_SECTION ); offset =FIELD_GET (DCT_TABLE_OFFSET , regval);
@@ -627,23 +627,23 @@ static int i3c_hci_init(struct i3c_hci *hci) hci->DCT_entry_size =FIELD_GET (DCT_ENTRY_SIZE , regval) ?0 :16 ;if (size_in_dwords) hci->DCT_entries =4 * hci->DCT_entries / hci->DCT_entry_size; -dev_info (&hci->master.dev,"DCT: %u %u-bytes entries at offset %#x\n" , - hci->DCT_entries, hci->DCT_entry_size, offset); +dev_dbg (&hci->master.dev,"DCT: %u %u-bytes entries at offset %#x\n" , + hci->DCT_entries, hci->DCT_entry_size, offset); regval =reg_read (RING_HEADERS_SECTION ); offset =FIELD_GET (RING_HEADERS_OFFSET , regval); hci->RHS_regs = offset ? hci->base_regs + offset :NULL ; -dev_info (&hci->master.dev,"Ring Headers at offset %#x\n" , offset); +dev_dbg (&hci->master.dev,"Ring Headers at offset %#x\n" , offset); regval =reg_read (PIO_SECTION ); offset =FIELD_GET (PIO_REGS_OFFSET , regval); hci->PIO_regs = offset ? hci->base_regs + offset :NULL ; -dev_info (&hci->master.dev,"PIO section at offset %#x\n" , offset); +dev_dbg (&hci->master.dev,"PIO section at offset %#x\n" , offset); regval =reg_read (EXT_CAPS_SECTION ); offset =FIELD_GET (EXT_CAPS_OFFSET , regval); hci->EXTCAPS_regs = offset ? hci->base_regs + offset :NULL ; -dev_info (&hci->master.dev,"Extended Caps at offset %#x\n" , offset); +dev_dbg (&hci->master.dev,"Extended Caps at offset %#x\n" , offset); ret =i3c_hci_parse_ext_caps (hci);if (ret)
@@ -713,7 +713,7 @@ static int i3c_hci_init(struct i3c_hci *hci) ret = -EIO ; }else { hci->io = &mipi_i3c_hci_dma; -dev_info (&hci->master.dev,"Using DMA\n" ); +dev_dbg (&hci->master.dev,"Using DMA\n" ); } }
@@ -725,7 +725,7 @@ static int i3c_hci_init(struct i3c_hci *hci) ret = -EIO ; }else { hci->io = &mipi_i3c_hci_pio; -dev_info (&hci->master.dev,"Using PIO\n" ); +dev_dbg (&hci->master.dev,"Using PIO\n" ); } }
drivers/i3c/master/mipi-i3c-hci/dma.c +2 -2
@@ -216,7 +216,7 @@ static int hci_dma_init(struct i3c_hci *hci) regval =rhs_reg_read (CONTROL ); nr_rings =FIELD_GET (MAX_HEADER_COUNT_CAP , regval); -dev_info (&hci->master.dev,"%d DMA rings available\n" , nr_rings); +dev_dbg (&hci->master.dev,"%d DMA rings available\n" , nr_rings);if (unlikely (nr_rings >8 )) {dev_err (&hci->master.dev,"number of rings should be <= 8\n" ); nr_rings =8 ;
@@ -232,7 +232,7 @@ static int hci_dma_init(struct i3c_hci *hci)for (i =0 ; i < rings->total; i++) {u32 offset =rhs_reg_read (RHn_OFFSET (i)); -dev_info (&hci->master.dev,"Ring %d at offset %#x\n" , i, offset); +dev_dbg (&hci->master.dev,"Ring %d at offset %#x\n" , i, offset); ret = -EINVAL ;if (!offset) goto err_out;
drivers/i3c/master/mipi-i3c-hci/ext_caps.c +26 -29
154 lines not on this page · raw message
drivers/i3c/master/mipi-i3c-hci/pio.c +8 -8
@@ -149,14 +149,14 @@ static int hci_pio_init(struct i3c_hci *hci)spin_lock_init (&pio->lock); size_val =pio_reg_read (QUEUE_SIZE ); -dev_info (&hci->master.dev,"CMD/RESP FIFO = %ld entries\n" , -FIELD_GET (CR_QUEUE_SIZE , size_val)); -dev_info (&hci->master.dev,"IBI FIFO = %ld bytes\n" , -4 *FIELD_GET (IBI_STATUS_SIZE , size_val)); -dev_info (&hci->master.dev,"RX data FIFO = %d bytes\n" , -4 * (2 <<FIELD_GET (RX_DATA_BUFFER_SIZE , size_val))); -dev_info (&hci->master.dev,"TX data FIFO = %d bytes\n" , -4 * (2 <<FIELD_GET (TX_DATA_BUFFER_SIZE , size_val))); +dev_dbg (&hci->master.dev,"CMD/RESP FIFO = %ld entries\n" , +FIELD_GET (CR_QUEUE_SIZE , size_val)); +dev_dbg (&hci->master.dev,"IBI FIFO = %ld bytes\n" , +4 *FIELD_GET (IBI_STATUS_SIZE , size_val)); +dev_dbg (&hci->master.dev,"RX data FIFO = %d bytes\n" , +4 * (2 <<FIELD_GET (RX_DATA_BUFFER_SIZE , size_val))); +dev_dbg (&hci->master.dev,"TX data FIFO = %d bytes\n" , +4 * (2 <<FIELD_GET (TX_DATA_BUFFER_SIZE , size_val)));/* * Let's initialize data thresholds to half of the actual FIFO size.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 858/935 i3c: mipi-i3c-hci: Switch PIO data allocation to devm_kzalloc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 11d17c2855bfc04550557017eae02e92f3eeab1c ]
The driver already uses managed resources, so convert the PIO data structure allocation to devm_zalloc(). Remove the manual kfree().
Stable-dep-of: 308ecb824db3 ("i3c: mipi-i3c-hci: Fix missing STAT_IBI_STATUS_THLD in PIO mode")
--- drivers/i3c/master/mipi-i3c-hci/pio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i3c/master/mipi-i3c-hci/pio.c +1 -3
@@ -141,7 +141,7 @@ static int hci_pio_init(struct i3c_hci *hci)struct hci_pio_data *pio;u32 val, size_val, rx_thresh, tx_thresh, ibi_val; - pio =kzalloc (sizeof (*pio),GFP_KERNEL ); + pio =devm_kzalloc (hci->master.dev.parent,sizeof (*pio),GFP_KERNEL );if (!pio)return -ENOMEM ;
@@ -219,8 +219,6 @@ static void hci_pio_cleanup(struct i3c_hci *hci)BUG_ON (pio->curr_rx);BUG_ON (pio->curr_tx);BUG_ON (pio->curr_resp); -kfree (pio); - hci->io_data =NULL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 859/935 i3c: mipi-i3c-hci: Refactor PIO register initialization
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit ca4d4682d353bf4e7e5db7b025e9ecd80bc67b27 ]
Move the PIO register setup logic out of hci_pio_init() into a new helper, __hci_pio_init(). This refactoring prepares for Runtime PM support by allowing PIO registers to be reinitialized independently after resume.
Stable-dep-of: 308ecb824db3 ("i3c: mipi-i3c-hci: Fix missing STAT_IBI_STATUS_THLD in PIO mode")
--- drivers/i3c/master/mipi-i3c-hci/pio.c | 45 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-)
drivers/i3c/master/mipi-i3c-hci/pio.c +28 -17
@@ -136,27 +136,14 @@ struct hci_pio_data {u32 enabled_irqs; }; -static int hci_pio_init (struct i3c_hci *hci) +static void __hci_pio_init (struct i3c_hci *hci,u32 *size_val_ptr) { -struct hci_pio_data *pio;u32 val, size_val, rx_thresh, tx_thresh, ibi_val; - - pio =devm_kzalloc (hci->master.dev.parent,sizeof (*pio),GFP_KERNEL ); -if (!pio) -return -ENOMEM ; - - hci->io_data = pio; -spin_lock_init (&pio->lock); +struct hci_pio_data *pio = hci->io_data; size_val =pio_reg_read (QUEUE_SIZE ); -dev_dbg (&hci->master.dev,"CMD/RESP FIFO = %ld entries\n" , -FIELD_GET (CR_QUEUE_SIZE , size_val)); -dev_dbg (&hci->master.dev,"IBI FIFO = %ld bytes\n" , -4 *FIELD_GET (IBI_STATUS_SIZE , size_val)); -dev_dbg (&hci->master.dev,"RX data FIFO = %d bytes\n" , -4 * (2 <<FIELD_GET (RX_DATA_BUFFER_SIZE , size_val))); -dev_dbg (&hci->master.dev,"TX data FIFO = %d bytes\n" , -4 * (2 <<FIELD_GET (TX_DATA_BUFFER_SIZE , size_val))); +if (size_val_ptr) + *size_val_ptr = size_val;/* * Let's initialize data thresholds to half of the actual FIFO size.
@@ -202,6 +189,30 @@ static int hci_pio_init(struct i3c_hci *hci)/* Always accept error interrupts (will be activated on first xfer) */ pio->enabled_irqs =STAT_ALL_ERRORS ; +} + +static int hci_pio_init (struct i3c_hci *hci) +{ +struct hci_pio_data *pio; +u32 size_val; + + pio =devm_kzalloc (hci->master.dev.parent,sizeof (*pio),GFP_KERNEL ); +if (!pio) +return -ENOMEM ; + + hci->io_data = pio; +spin_lock_init (&pio->lock); + +__hci_pio_init (hci, &size_val); + +dev_dbg (&hci->master.dev,"CMD/RESP FIFO = %ld entries\n" , +FIELD_GET (CR_QUEUE_SIZE , size_val)); +dev_dbg (&hci->master.dev,"IBI FIFO = %ld bytes\n" , +4 *FIELD_GET (IBI_STATUS_SIZE , size_val)); +dev_dbg (&hci->master.dev,"RX data FIFO = %d bytes\n" , +4 * (2 <<FIELD_GET (RX_DATA_BUFFER_SIZE , size_val))); +dev_dbg (&hci->master.dev,"TX data FIFO = %d bytes\n" , +4 * (2 <<FIELD_GET (TX_DATA_BUFFER_SIZE , size_val)));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 860/935 i3c: mipi-i3c-hci: Fix missing STAT_IBI_STATUS_THLD in PIO mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian-Ming Liao <[email protected]>
[ Upstream commit 308ecb824db329a8e22dd0b10f2a3411a6fbbde3 ]
In PIO mode initialization, STAT_IBI_STATUS_THLD was missing from pio->enabled_irqs. As a result, the host controller interrupt signal for IBI threshold was never enabled when transfer starts, preventing IBI status descriptors from being properly processed in PIO mode.
Include STAT_IBI_STATUS_THLD in pio->enabled_irqs so that the IBI threshold interrupt is activated alongside error interrupts upon the first transfer.
--- drivers/i3c/master/mipi-i3c-hci/pio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/i3c/master/mipi-i3c-hci/pio.c +5 -2
@@ -187,8 +187,11 @@ static void __hci_pio_init(struct i3c_hci *hci, u32 *size_val_ptr)pio_reg_write (INTR_SIGNAL_ENABLE ,0x0 );pio_reg_write (INTR_STATUS_ENABLE ,0xffffffff ); -/* Always accept error interrupts (will be activated on first xfer) */ - pio->enabled_irqs =STAT_ALL_ERRORS ; +/* +* Always accept error interrupts and IBI threshold interrupt +* (will be activated on first xfer). +*/ + pio->enabled_irqs =STAT_ALL_ERRORS |STAT_IBI_STATUS_THLD ; }static int hci_pio_init (struct i3c_hci *hci)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 861/935 virtio_balloon: disable indirect descriptors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <[email protected]>
[ Upstream commit 281eb4732aae5473141b84e106fe906c69b2ff3d ]
The page reporting callback submits an sg list to the reporting virtqueue. With VIRTIO_RING_F_INDIRECT_DESC negotiated and total_sg > 1 (which it typically is), virtqueue_add reports it to the host by allocating an indirect descriptor via kmalloc(GFP_KERNEL).
This is not pretty: the reporting worker isolates potentially hundreds of MB of free pages from the buddy allocator (reported pages are at least pageblock_order, and the sg can contain up to PAGE_REPORTING_CAPACITY entries of varying orders). As the result, very theoretically, the kmalloc might trigger OOM when we have in fact a ton of free memory.
Clear VIRTIO_RING_F_INDIRECT_DESC, to avoid using indirect descriptors.
Message-ID: <73fac8a629fd9aca7bb3265ac243a769c28af25d.1783232420.git.mst@redhat.com>
--- drivers/virtio/virtio_balloon.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/virtio/virtio_balloon.c +6 -0
@@ -7,6 +7,7 @@*/ #include <linux/virtio.h> +#include <uapi/linux/virtio_ring.h> #include <linux/virtio_balloon.h> #include <linux/swap.h> #include <linux/workqueue.h>
@@ -1138,6 +1139,11 @@ static int virtballoon_validate(struct virtio_device *vdev)else if (!virtio_has_feature (vdev,VIRTIO_BALLOON_F_PAGE_POISON ))__virtio_clear_bit (vdev,VIRTIO_BALLOON_F_REPORTING ); +/* +* Disable indirect descriptors to avoid memory allocation in +* virtqueue_add during page reporting. +*/ +__virtio_clear_bit (vdev,VIRTIO_RING_F_INDIRECT_DESC );__virtio_clear_bit (vdev,VIRTIO_F_ACCESS_PLATFORM );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 862/935 vdpa/mlx5: fix wrong list iterated in add_direct_chain error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 23ae56d9e74c122f95cae71ae3b9fc259fb88446 ]
In add_direct_chain(), newly allocated direct MR entries are added to the local list 'tmp', which is spliced into mr->head only on success. On the error path, the cleanup loop was incorrectly iterating over mr->head instead of tmp.
Fix by iterating over 'tmp' in the err_alloc cleanup path.
Message-ID: <[email protected]>
--- drivers/vdpa/mlx5/core/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/mlx5/core/mr.c +1 -1
@@ -345,7 +345,7 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev, u64 start, u64 size, u8return 0 ; err_alloc: -list_for_each_entry_safe (dmr, n, &mr->head, list) { +list_for_each_entry_safe (dmr, n, &tmp, list) {list_del_init (&dmr->list);unmap_direct_mr (mvdev, dmr);kfree (dmr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 863/935 rtc: pcf8563: fix clock provider leak on unbind
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Ding <[email protected]>
[ Upstream commit 9c48a53685040bb0de45a640b34055cbbfc69d4f ]
pcf8563_clkout_register_clk() registers the CLKOUT clock provider with of_clk_add_provider(), but nothing ever unwinds it: there is no of_clk_del_provider() call and the driver has no remove callback. Each of_clk_add_provider() allocates a struct of_clk_provider, takes a reference on the OF node and adds an entry to the global of_clk_providers list, none of which is released when the device is unbound. Every bind/unbind (or module reload) therefore leaks a provider structure and an of_node reference.
The clock itself is already device-managed (devm_clk_register()); only the provider registration was not. Use devm_of_clk_add_hw_provider() so the provider is removed automatically on unbind. Tie it to the parent i2c device, whose OF node carries the #clock-cells and clock-output-names properties (the RTC class device has no OF node of its own).
--- drivers/rtc/rtc-pcf8563.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/rtc/rtc-pcf8563.c +3 -1
@@ -507,7 +507,9 @@ static struct clk *pcf8563_clkout_register_clk(struct pcf8563 *pcf8563) clk =devm_clk_register (&client->dev, &pcf8563->clkout_hw);if (!IS_ERR (clk)) -of_clk_add_provider (node, of_clk_src_simple_get, clk); +devm_of_clk_add_hw_provider (pcf8563->rtc->dev.parent, + of_clk_hw_simple_get, + &pcf8563->clkout_hw);return clk; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 864/935 prctl: fix PR_SET_MM_AUXV losing the forced AT_NULL terminator
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit 5146e0688d86f0654263e4b0e4ff1719b4072f16 ]
prctl_set_auxv() copies the user vector into a stack buffer, forces AT_NULL on the last two entries there, and then copies only len bytes into mm->saved_auxv. Which is fine until the vector is shorter than the buffer, because then the forced terminator sits past the end of the copy and never lands in saved_auxv at all.
The code even says
/* Make sure the last entry is always AT_NULL */
and it does, just not in the part that gets copied.
So mm->saved_auxv keeps the stale tail from exec. Reproducing it is easy:
from a process with CAP_SYS_RESOURCE (just run it as root), call prctl(PR_SET_MM, PR_SET_MM_AUXV, ...) with a vector that has a couple of entries and no AT_NULL inside len (32 bytes on arm64), and then hexdump /proc/self/auxv, or gcore the process and look at the AUXV note with readelf -n. This is arm64, the new vector was just { AT_UID, 0x1111, AT_GID, 0x2222 }:
idx before (from exec) after the prctl
[0] AT_SYSINFO_EHDR 0x7ed1d6e000 AT_UID 0x1111 <- new
[1] AT_MINSIGSTKSZ 0x1270 AT_GID 0x2222 <- new
[2] AT_HWCAP 0x119fff AT_HWCAP 0x119fff <- stale
[3] AT_PAGESZ 0x1000 AT_PAGESZ 0x1000 <- stale
... 16 more entries ... <- stale
[20] AT_NULL 0x0 AT_NULL 0x021 entries before the prctl, still 21 after: the two new ones plus all 19 left over from exec.
Every consumer walks the vector until AT_NULL, so what they get now is a vector that never existed at exec, the head from the prctl glued onto the tail of the old binary. gdb and crash pull the AUXV note out of coredumps to find AT_PHDR, AT_ENTRY, AT_SYSINFO_EHDR and friends, and a mixed vector points them at the wrong layout. /proc/<pid>/auxv and PR_GET_AUXV hand the same mess out to live processes too. Nothing crashes, everything just quietly reads a frankenstein auxv.
And callers that terminate their own vector hide the whole thing, which is likely why nobody noticed since PR_SET_MM_AUXV landed in 2012. Nothing exciting security wise either, I mean it needs CAP_SYS_RESOURCE to begin with.
prctl_set_mm_map() right above already copies the whole buffer for exactly this reason, so just do the same here. user_auxv is zero initialized and only partially filled from userspace, so the rest is zeros and nothing leaks.
--- kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sys.c +1 -1
@@ -2109,7 +2109,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,BUILD_BUG_ON (sizeof (user_auxv) !=sizeof (mm->saved_auxv));task_lock (current); -memcpy (mm->saved_auxv, user_auxv, len); +memcpy (mm->saved_auxv, user_auxv,sizeof (user_auxv));task_unlock (current);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 865/935 ALSA: control: Use automatic cleanup of kfree()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 1052d988226948493eb9730b3424308972eca5f4 ]
There are common patterns where a temporary buffer is allocated and freed at the exit, and those can be simplified with the recent cleanup mechanism via __free(kfree).
A caveat is that some allocations are memdup_user() and they return an error pointer instead of NULL. Those need special cares and the value has to be cleared with no_free_ptr() at the allocation error path.
Other than that, the conversions are straightforward.
No functional changes, only code refactoring.
Stable-dep-of: d736eba9c453 ("ALSA: ice1712: Fix the card leak at probe error with the auto-cleanup")
--- sound/core/control.c | 23 +++++-------- sound/core/control_compat.c | 69 ++++++++++++++----------------------- 2 files changed, 34 insertions(+), 58 deletions(-)
sound/core/control.c +8 -15
@@ -722,7 +722,7 @@ EXPORT_SYMBOL(snd_ctl_find_id);static int snd_ctl_card_info (struct snd_card *card,struct snd_ctl_file * ctl,unsigned int cmd,void __user *arg) { -struct snd_ctl_card_info *info; + struct snd_ctl_card_info *info __free(kfree) = NULL; info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info)
@@ -736,11 +736,8 @@ static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl,strscpy (info->mixername, card->mixername,sizeof (info->mixername));strscpy (info->components, card->components,sizeof (info->components));up_read (&snd_ioctl_rwsem); -if (copy_to_user (arg, info,sizeof (struct snd_ctl_card_info ))) { -kfree (info); +if (copy_to_user (arg, info,sizeof (struct snd_ctl_card_info )))return -EFAULT ; - } -kfree (info);return 0 ; }
@@ -1127,12 +1124,10 @@ static int snd_ctl_elem_read_user(struct snd_card *card, result =snd_ctl_elem_read (card, control);if (result <0 ) - goto error; +return result;if (copy_to_user (_control, control,sizeof (*control))) - result = -EFAULT ; - error: -kfree (control); +return -EFAULT ;return result; }
@@ -1183,23 +1178,21 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,static int snd_ctl_elem_write_user (struct snd_ctl_file *file,struct snd_ctl_elem_value __user *_control) { -struct snd_ctl_elem_value *control; + struct snd_ctl_elem_value *control __free(kfree) = NULL;struct snd_card *card;int result; control =memdup_user (_control,sizeof (*control));if (IS_ERR (control)) -return PTR_ERR (control); +return PTR_ERR (no_free_ptr (control)); card = file->card; result =snd_ctl_elem_write (card, file, control);if (result <0 ) - goto error; +return result;if (copy_to_user (_control, control,sizeof (*control))) - result = -EFAULT ; - error: -kfree (control); +return -EFAULT ;return result; }
sound/core/control_compat.c +26 -43
193 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 866/935 RDMA/ucma: Allow path records to exactly fit the output buffer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serhat Kumral <[email protected]>
[ Upstream commit 8049741ac93acd3a590dac070e12571fddf0e294 ]
ucma_query_path() emits a path record only when the remaining output buffer is strictly larger than struct ib_path_rec_data. A buffer sized exactly for the response header and N complete records therefore gets only N - 1 records, while resp->num_paths still advertises N. A caller sizing its buffer for a single record gets a header claiming one path and no path data at all.
ucma_query_ib_service() in the same file computes the record count with a plain division and so accepts an exact fit; make ucma_query_path() behave the same way.
Current librdmacm is unaffected because it always sizes the response for six records while the kernel currently reports at most two paths. Other users of the UAPI that provide an exactly sized buffer can observe the truncated response.
--- drivers/infiniband/core/ucma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +1 -1
@@ -923,7 +923,7 @@ static ssize_t ucma_query_path(struct ucma_context *ctx, resp->num_paths = ctx->cm_id->route.num_paths;for (i =0 , out_len -=sizeof (*resp); - i < resp->num_paths && out_len >sizeof (struct ib_path_rec_data ); + i < resp->num_paths && out_len >=sizeof (struct ib_path_rec_data ); i++, out_len -=sizeof (struct ib_path_rec_data )) {struct sa_path_rec *rec = &ctx->cm_id->route.path_rec[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 867/935 net: bridge: Reject descending VLAN tunnel ranges
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit b74a072d8fb71d3c9ffba4a17d5943e63266fb38 ]
A pair of descending VLAN and tunnel IDs can pass the tunnel range span check. The VLAN subtraction produces a negative int, which is converted to unsigned when compared with the u32 tunnel ID subtraction. It can therefore equal the wrapped tunnel ID delta.
The range loop then performs no iterations. Since the batched notification handling added a post-loop error check, this leaves err uninitialized and makes the request's return value unpredictable.
Reject descending VLAN ranges before comparing the spans. Valid ascending and single-entry ranges remain unchanged, while malformed descending ranges consistently return -EINVAL.
This issue was found by a static analysis checker and confirmed by manual source review.
--- net/bridge/br_netlink_tunnel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_netlink_tunnel.c +2 -1
@@ -299,7 +299,8 @@ int br_process_vlan_tunnel_info(const struct net_bridge *br,if (!(tinfo_last->flags &BRIDGE_VLAN_INFO_RANGE_BEGIN ))return -EINVAL ; -if ((tinfo_curr->vid - tinfo_last->vid) != +if (tinfo_curr->vid < tinfo_last->vid || + (tinfo_curr->vid - tinfo_last->vid) != (tinfo_curr->tunid - tinfo_last->tunid))return -EINVAL ; t = tinfo_last->tunid;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 868/935 net: thunderbolt: Count delivered packets in rx_packets and rx_bytes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Ye <[email protected]>
[ Upstream commit c5ae83ee02c04487b1be1d143b791ec2caca888e ]
tbnet_poll() increments rx_packets once per received frame because that is the NAPI work unit, and then adds the same number to stats.rx_packets. An skb is handed to the stack only when the last frame of a packet arrives, so once the MTU exceeds TBNET_MAX_PAYLOAD_SIZE the statistic reports frames. tx_packets is bumped once per skb, so the two ends of a link
disagree: at MTU 65330 the receiver reports 16 times the packets its sender sent.
rx_bytes has the matching problem: frames of a packet that is later dropped mid-assembly are already accounted, so it does not correspond to rx_packets as documented. Account for both where the packet is completed, and leave the NAPI work counter alone.
--- drivers/net/thunderbolt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/thunderbolt.c +3 -3
@@ -850,17 +850,17 @@ static int tbnet_poll(struct napi_struct *napi, int budget) last = net->rx_hdr.frame_index == net->rx_hdr.frame_count -1 ; rx_packets++; - net->stats.rx_bytes += frame_size;if (last) { +/* Before eth_type_trans() pulls the Ethernet header. */ + net->stats.rx_packets++; + net->stats.rx_bytes += skb->len; skb->protocol =eth_type_trans (skb, net->dev);napi_gro_receive (&net->napi, skb); net->skb =NULL ; } } - net->stats.rx_packets += rx_packets; -if (cleaned_count)tbnet_alloc_rx_buffers (net, cleaned_count);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 869/935 forcedeth: stop the tx_timeout register dump past the requested window
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
[ Upstream commit cfa9178ce2e5b4f2e2a9e8b577a6cff841665aa0 ]
nv_tx_timeout() dumps the register window in rows of eight dwords:
for (i = 0; i <= np->register_size; i += 32) {
netdev_info(dev, "%3x: %08x ... %08x\n", i,
readl(base + i + 0), ..., readl(base + i + 28));The loop bound only checks the row's starting offset, so the final row reads a full 32 bytes from a position that is below the end of the window but too close to it. base is mapped with exactly that length:
np->base = ioremap(addr, np->register_size);
so the tail of that row is read from beyond the length the driver asked for. Per variant, the last iteration reads past register_size by:
NV_PCI_REGSZ_VER1 (0x270): row 0x260 reads to 0x27f, 16 bytes over NV_PCI_REGSZ_VER2 (0x2d4): row 0x2c0 reads to 0x2df, 12 bytes over NV_PCI_REGSZ_VER3 (0x604): row 0x600 reads to 0x61f, 28 bytes over
This happens on every supported device, not just one of them. Note that it is not a consequence of the sizes being odd: with i <= register_size the offending row is reached whatever the size, and a size that were a multiple of 32 would overrun by a full row rather than by a remainder.
To be precise about the severity: the reads stay inside the BAR. Memory BAR sizes are powers of two, the driver only accepts a region with pci_resource_len() >= register_size (forcedeth.c:5757-5762), and the next power of two at or above each register_size already covers the offending row: 0x400 for 0x270 and 0x2d4, 0x800 for 0x604. ioremap() also rounds the mapped length up to page granularity, so the reads land inside the mapping the CPU has as well. What they leave is the window the driver asked for, not the BAR and not the mapping. That is still a driver reading registers it did not ask for, and it is trivial to avoid, but nobody should expect a fault from it.
Changing <= to < is not enough: register_size is a length and every size above is larger than its last row start, so i still reaches the offending row. Check that the whole row fits instead.
The trade-off is that a partial trailing row is no longer dumped: 16 bytes for VER1, 20 for VER2, 4 for VER3. That seemed preferable to reading outside the requested window, and to open-coding a second, narrower dump for the remainder in what is a debug-only path. Extending the dump to cover the tail can be done on top if anyone misses those registers.
Only reachable with the debug_tx_timeout module parameter, which defaults to false. It has not been observed at runtime: forcing a genuine TX timeout on the reference machine is not something I can do safely, so this rests on the arithmetic above and on a build test, not on a reproduction. UBSAN does not catch it either, since these are MMIO reads rather than an array access. It was found by reading the function while fixing the saved_config_space off-by-one in nv_suspend() and nv_resume().
The dump was introduced with a fixed 0x400 bound while ioremap() mapped only NV_PCI_REGSZ (0x270), so it read about 0x190 bytes too far from the start. Commit 86a0f04387bf ("[PATCH] forcedeth: fix initialization") later replaced 0x400 with np->register_size, which shrank the overrun to the remainder but did not remove it.
--- drivers/net/ethernet/nvidia/forcedeth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/nvidia/forcedeth.c +1 -1
@@ -2754,7 +2754,7 @@ static void nv_tx_timeout(struct net_device *dev, unsigned int txqueue)netdev_info (dev,"Ring at %lx\n" , (unsigned long )np->ring_addr);netdev_info (dev,"Dumping tx registers\n" ); -for (i =0 ; i <= np->register_size; i +=32 ) { +for (i =0 ; i +32 <= np->register_size; i +=32 ) { netdev_info(dev, "%3x: %08x %08x %08x %08x " "%08x %08x %08x %08x\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 870/935 net: ipa: report when the driver has been removed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Elder <[email protected]>
[ Upstream commit 3c91c86d1bb61bd59d3b9a0b8003fe272fc9e774 ]
When the IPA driver has completed its initialization and setup stages, it emits a brief message to the log. Add a small message that reports when it has been removed.
Stable-dep-of: 6b9eaa61ff2d ("net: ipa: balance runtime PM reference on remove error")
--- drivers/net/ipa/ipa_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ipa/ipa_main.c +2 -0
@@ -836,6 +836,8 @@ static int ipa_remove(struct platform_device *pdev)kfree (ipa);ipa_power_exit (power); +dev_info (dev,"IPA driver removed" ); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 871/935 net: ipa: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit a92dbb9cdf0465d56c7e0fc5d674e6834f7c6a79 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 6b9eaa61ff2d ("net: ipa: balance runtime PM reference on remove error")
--- drivers/net/ipa/ipa_main.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/net/ipa/ipa_main.c +13 -16
@@ -795,7 +795,7 @@ static int ipa_probe(struct platform_device *pdev)return ret; } -static int ipa_remove (struct platform_device *pdev) +static void ipa_remove (struct platform_device *pdev) {struct ipa *ipa =dev_get_drvdata (&pdev->dev);struct ipa_power *power = ipa->power;
@@ -818,8 +818,16 @@ static int ipa_remove(struct platform_device *pdev)usleep_range (USEC_PER_MSEC ,2 *USEC_PER_MSEC ); ret =ipa_modem_stop (ipa); } -if (ret) -return ret; +if (ret) { +/* +* Not cleaning up here properly might also yield a +* crash later on. As the device is still unregistered +* in this case, this might even yield a crash later on. +*/ +dev_err (dev,"Failed to stop modem (%pe), leaking resources\n" , +ERR_PTR (ret)); +return ; + }ipa_teardown (ipa); }
@@ -837,17 +845,6 @@ static int ipa_remove(struct platform_device *pdev)ipa_power_exit (power);dev_info (dev,"IPA driver removed" ); - -return 0 ; -} - -static void ipa_shutdown (struct platform_device *pdev) -{ -int ret; - - ret =ipa_remove (pdev); -if (ret) -dev_err (&pdev->dev,"shutdown: remove returned %d\n" , ret); }static const struct attribute_group *ipa_attribute_groups[] = {
@@ -859,8 +856,8 @@ static const struct attribute_group *ipa_attribute_groups[] = {static struct platform_driver ipa_driver = { .probe = ipa_probe, - .remove = ipa_remove, - .shutdown = ipa_shutdown, + .remove_new = ipa_remove, + .shutdown = ipa_remove, .driver = { .name ="ipa" , .pm = &ipa_pm_ops,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 872/935 net: ipa: balance runtime PM reference on remove error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 6b9eaa61ff2df63c6eb35d5cd025e2cef0861d76 ]
ipa_remove() takes a runtime PM reference before accessing IPA hardware during teardown. If a concurrent modem start or stop keeps ipa_modem_stop() busy across both attempts, the callback intentionally returns without releasing the remaining resources because proceeding with teardown could crash. That return also skips the matching pm_runtime_put_noidle(), leaving the callback's usage-count reference held.
Drop only this runtime PM reference before returning. pm_runtime_put_noidle() does not request an idle transition, so the hardware and resources retained on this exceptional path remain untouched while the usage count stays balanced.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/net/ipa/ipa_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ipa/ipa_main.c +3 -3
@@ -820,12 +820,12 @@ static void ipa_remove(struct platform_device *pdev) }if (ret) {/* -* Not cleaning up here properly might also yield a -* crash later on. As the device is still unregistered -* in this case, this might even yield a crash later on. +* Continuing teardown after failing to stop the modem +* could crash, so leave the remaining resources allocated. */ dev_err (dev,"Failed to stop modem (%pe), leaking resources\n" ,ERR_PTR (ret)); +pm_runtime_put_noidle (dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 873/935 net/smc: free pending qentry in smc_llc_flow_stop() before memset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahanta Jambigi <[email protected]>
[ Upstream commit 5ee0ceddc7785c6dcf4a8107fef01f0414a354f4 ]
smc_llc_flow_stop() resets a flow struct with a blind memset:
spin_lock_bh(&lgr->llc_flow_lock); memset(flow, 0, sizeof(*flow)); flow->type = SMC_LLC_FLOW_NONE; spin_unlock_bh(&lgr->llc_flow_lock);
If flow->qentry is non-NULL at this point the pointer is overwritten without the allocation being freed, leaking one kmalloc object.
A late-arriving duplicate CONFIRM_LINK or ADD_LINK_CONT message can set flow->qentry after the legitimate message has been consumed by the waiter via smc_llc_flow_qentry_clr() (which NULLs the pointer but leaves flow->type non-zero) but before the flow completes and smc_llc_flow_stop() runs. In that window the duplicate is stashed into flow->qentry, and then lost when smc_llc_flow_stop() zeros the struct.
Call smc_llc_flow_qentry_del() inside the lock before the memset. smc_llc_flow_qentry_del() already checks flow->qentry before freeing, so the normal case where no entry is pending is a no-op.
--- net/smc/smc_llc.c | 1 + 1 file changed, 1 insertion(+)
net/smc/smc_llc.c +1 -0
@@ -276,6 +276,7 @@ int smc_llc_flow_initiate(struct smc_link_group *lgr,void smc_llc_flow_stop (struct smc_link_group *lgr,struct smc_llc_flow *flow) {spin_lock_bh (&lgr->llc_flow_lock); +smc_llc_flow_qentry_del (flow);memset (flow,0 ,sizeof (*flow)); flow->type =SMC_LLC_FLOW_NONE ;spin_unlock_bh (&lgr->llc_flow_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 874/935 NFSv4.2: fix LAYOUTSTATS send buffer exhaustion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit c75ef2137e749f2673f0617cfdaae53b2bb7195a ]
encode_layoutstats_maxsz budgets XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE), i.e. 256 bytes, for the layoutupdate4 body written by the layout driver. The flexfiles record can exceed that.
ff_layout_encode_ff_layoutupdate() emits, per data server, a netaddr4, an nfs_fh4, two ff_io_latency4, an nfstime4 and a bool. A data server whose filehandle is NFS_MAXFHSIZE bytes long already accounts for 132 of those bytes, and the two ff_io_latency4 at 64 bytes each, the nfstime4 and the bool add a further 144, so the body passes 256 bytes before the netaddr4 is encoded at all. encode_layoutstats() additionally writes the deviceid4 and the layoutupdate4 lou_type word, neither of which the macro accounts for.
The filehandle and the address are both chosen by the server, through LAYOUTGET and GETDEVICEINFO, so it can drive the encoder past the end of the send buffer. xdr_reserve_space() returns NULL once that happens, and the two ff_layout_encode_io_latency() calls run with dss_info->mirror->lock held, so a NULL return there leaves the lock permanently held.
Raise PNFS_LAYOUTSTATS_MAXSIZE to 384 so that the record fits inside the reservation.
--- include/linux/nfs_xdr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nfs_xdr.h +1 -1
@@ -348,7 +348,7 @@ struct nfs4_layoutreturn {struct nfs4_xdr_opaque_data ld_private; }; -#define PNFS_LAYOUTSTATS_MAXSIZE 256 +#define PNFS_LAYOUTSTATS_MAXSIZE 384struct nfs42_layoutstat_args ;struct nfs42_layoutstat_devinfo ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 875/935 nfs: move the nfs4_data_server_cache into struct nfs_net
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit d5fb22a7c585b12ec3e6cef150689f7386e8cfd0 ]
Since struct nfs4_pnfs_ds should not be shared between net namespaces, move from a global list of objects to a per-netns list and spinlock.
Stable-dep-of: 13c23c5cb977 ("NFSv4/pnfs: key the data server cache on the NFS version")
--- fs/nfs/client.c | 7 +++++++ fs/nfs/netns.h | 6 +++++- fs/nfs/pnfs_nfs.c | 31 +++++++++++++++++-------------- 3 files changed, 29 insertions(+), 15 deletions(-)
fs/nfs/client.c +7 -0
@@ -1182,6 +1182,10 @@ void nfs_clients_init(struct net *net)INIT_LIST_HEAD (&nn->nfs_volume_list);#if IS_ENABLED (CONFIG_NFS_V4 )idr_init (&nn->cb_ident_idr); +#endif +#if IS_ENABLED (CONFIG_NFS_V4_1 ) +INIT_LIST_HEAD (&nn->nfs4_data_server_cache); +spin_lock_init (&nn->nfs4_data_server_lock);#endif spin_lock_init (&nn->nfs_client_lock); nn->boot_time =ktime_get_real ();
@@ -1199,6 +1203,9 @@ void nfs_clients_exit(struct net *net)nfs_cleanup_cb_ident_idr (net);WARN_ON_ONCE (!list_empty (&nn->nfs_client_list));WARN_ON_ONCE (!list_empty (&nn->nfs_volume_list)); +#if IS_ENABLED (CONFIG_NFS_V4_1 ) +WARN_ON_ONCE (!list_empty (&nn->nfs4_data_server_cache)); +#endif }#ifdef CONFIG_PROC_FS
fs/nfs/netns.h +5 -1
@@ -31,7 +31,11 @@ struct nfs_net {unsigned short nfs_callback_tcpport;unsigned short nfs_callback_tcpport6;int cb_users[NFS4_MAX_MINOR_VERSION +1 ]; -#endif +#endif /* CONFIG_NFS_V4 */ +#if IS_ENABLED (CONFIG_NFS_V4_1 ) +struct list_head nfs4_data_server_cache; +spinlock_t nfs4_data_server_lock; +#endif /* CONFIG_NFS_V4_1 */ struct nfs_netns_client *nfs_client;spinlock_t nfs_client_lock;ktime_t boot_time;
fs/nfs/pnfs_nfs.c +17 -14
@@ -16,6 +16,7 @@#include "nfs4session.h" #include "internal.h" #include "pnfs.h" +#include "netns.h" #define NFSDBG_FACILITY NFSDBG_PNFS
@@ -551,14 +552,14 @@ EXPORT_SYMBOL_GPL(pnfs_generic_commit_pagelist);/* * Data server cache * -* Data servers can be mapped to different device ids. -* nfs4_pnfs_ds reference counting +* Data servers can be mapped to different device ids, but should +* never be shared between net namespaces. +* +* nfs4_pnfs_ds reference counting: * - set to 1 on allocation * - incremented when a device id maps a data server already in the cache. * - decremented when deviceid is removed from the cache. */ -static DEFINE_SPINLOCK (nfs4_ds_cache_lock); -static LIST_HEAD (nfs4_data_server_cache);/* Debug routines */ static void
@@ -651,12 +652,12 @@ _same_data_server_addrs_locked(const struct list_head *dsaddrs1,* Lookup DS by addresses. nfs4_ds_cache_lock is held */ static struct nfs4_pnfs_ds * -_data_server_lookup_locked (const struct net *net,const struct list_head *dsaddrs) +_data_server_lookup_locked (const struct nfs_net *nn,const struct list_head *dsaddrs) {struct nfs4_pnfs_ds *ds; -list_for_each_entry (ds, &nfs4_data_server_cache, ds_node) -if (ds->ds_net == net &&_same_data_server_addrs_locked (&ds->ds_addrs, dsaddrs)) +list_for_each_entry (ds, &nn->nfs4_data_server_cache, ds_node) +if (_same_data_server_addrs_locked (&ds->ds_addrs, dsaddrs))return ds;return NULL ; }
@@ -700,10 +701,11 @@ static void destroy_ds(struct nfs4_pnfs_ds *ds)void nfs4_pnfs_ds_put (struct nfs4_pnfs_ds *ds) { -if (refcount_dec_and_lock (&ds->ds_count, - &nfs4_ds_cache_lock)) { +struct nfs_net *nn =net_generic (ds->ds_net, nfs_net_id); + +if (refcount_dec_and_lock (&ds->ds_count, &nn->nfs4_data_server_lock)) {list_del_init (&ds->ds_node); -spin_unlock (&nfs4_ds_cache_lock); +spin_unlock (&nn->nfs4_data_server_lock);destroy_ds (ds); } }
@@ -765,6 +767,7 @@ nfs4_pnfs_remotestr(struct list_head *dsaddrs, gfp_t gfp_flags)struct nfs4_pnfs_ds *nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,gfp_t gfp_flags) { +struct nfs_net *nn =net_generic (net, nfs_net_id);struct nfs4_pnfs_ds *tmp_ds, *ds =NULL ;char *remotestr;
@@ -780,8 +783,8 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_fla/* this is only used for debugging, so it's ok if its NULL */ remotestr =nfs4_pnfs_remotestr (dsaddrs, gfp_flags); -spin_lock (&nfs4_ds_cache_lock); - tmp_ds =_data_server_lookup_locked (net, dsaddrs); +spin_lock (&nn->nfs4_data_server_lock); + tmp_ds =_data_server_lookup_locked (nn, dsaddrs);if (tmp_ds ==NULL ) {INIT_LIST_HEAD (&ds->ds_addrs);list_splice_init (dsaddrs, &ds->ds_addrs);
@@ -790,7 +793,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_flaINIT_LIST_HEAD (&ds->ds_node); ds->ds_net = net; ds->ds_clp =NULL ; -list_add (&ds->ds_node, &nfs4_data_server_cache); +list_add (&ds->ds_node, &nn->nfs4_data_server_cache);dprintk ("%s add new data server %s\n" , __func__, ds->ds_remotestr); }else {
@@ -802,7 +805,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_fla refcount_read(&tmp_ds->ds_count)); ds = tmp_ds; } -spin_unlock (&nfs4_ds_cache_lock); +spin_unlock (&nn->nfs4_data_server_lock); out:return ds; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 876/935 NFSv4/pnfs: key the data server cache on the NFS version
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 13c23c5cb977f66390795437fd3837887ce1fd75 ]
nfs4_pnfs_ds_add() keys the per-net data server cache on the multipath address set alone, and struct nfs4_pnfs_ds records no version. That suffices for the files layout driver, which always connects with version 4, but flexfiles takes its version tuple from GETDEVICEINFO per device, and one address can legitimately serve both NFSv3 and NFSv4.
Two deviceids on one address with different ds_versions[0].version therefore share a single nfs4_pnfs_ds, and whichever mirror connects first pins ds_clp to its own version. The other one is handed that client anyway, so it selects rpc_call_ops for a version the connection does not speak, and the mismatched sequence-slot handling dereferences NULL.
Add the version to the cache key so the two cannot alias, giving each version its own nfs4_pnfs_ds and connection while both mirrors stay usable. Only the major version is compared, since that is what selects rpc_call_ops and rpc_ops; v4.0 and v4.1 keep sharing a client. The files layout driver passes the 4 it already hardcodes at connect time.
--- fs/nfs/filelayout/filelayoutdev.c | 3 ++- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 3 ++- fs/nfs/pnfs.h | 3 ++- fs/nfs/pnfs_nfs.c | 14 +++++++++----- 4 files changed, 15 insertions(+), 8 deletions(-)
fs/nfs/filelayout/filelayoutdev.c +2 -1
@@ -171,7 +171,8 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_free_deviceid; } - dsaddr->ds_list[i] =nfs4_pnfs_ds_add (net, &dsaddrs, gfp_flags); + dsaddr->ds_list[i] =nfs4_pnfs_ds_add (net, &dsaddrs,4 , + gfp_flags);if (!dsaddr->ds_list[i]) goto out_err_drain_dsaddrs;
fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 -1
@@ -147,7 +147,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, new_ds->ds_versions = ds_versions; new_ds->ds_versions_cnt = version_count; - new_ds->ds =nfs4_pnfs_ds_add (net, &dsaddrs, gfp_flags); + new_ds->ds =nfs4_pnfs_ds_add (net, &dsaddrs, ds_versions[0 ].version, + gfp_flags);if (!new_ds->ds) goto out_err_drain_dsaddrs;
fs/nfs/pnfs.h +2 -1
@@ -62,6 +62,7 @@ struct nfs4_pnfs_ds {const struct net *ds_net;struct nfs_client *ds_clp;refcount_t ds_count; +u32 ds_version;/* cache key, with ds_addrs */ unsigned long ds_state;#define NFS4DS_CONNECTING 0/* ds is establishing connection */ };
@@ -406,7 +407,7 @@ void pnfs_generic_write_commit_done(struct rpc_task *task, void *data);void nfs4_pnfs_ds_put (struct nfs4_pnfs_ds *ds);struct nfs4_pnfs_ds *nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs, -gfp_t gfp_flags); +u32 version,gfp_t gfp_flags);void nfs4_pnfs_v3_ds_connect_unload (void ); int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, struct nfs4_deviceid_node *devid, unsigned int timeo,
fs/nfs/pnfs_nfs.c +9 -5
@@ -649,15 +649,17 @@ _same_data_server_addrs_locked(const struct list_head *dsaddrs1, }/* -* Lookup DS by addresses. nfs4_ds_cache_lock is held +* Lookup DS by addresses and NFS version. nfs4_ds_cache_lock is held */ static struct nfs4_pnfs_ds * -_data_server_lookup_locked (const struct nfs_net *nn,const struct list_head *dsaddrs) +_data_server_lookup_locked (const struct nfs_net *nn, +const struct list_head *dsaddrs,u32 version) {struct nfs4_pnfs_ds *ds;list_for_each_entry (ds, &nn->nfs4_data_server_cache, ds_node) -if (_same_data_server_addrs_locked (&ds->ds_addrs, dsaddrs)) +if (ds->ds_version == version && +_same_data_server_addrs_locked (&ds->ds_addrs, dsaddrs))return ds;return NULL ; }
@@ -765,7 +767,8 @@ nfs4_pnfs_remotestr(struct list_head *dsaddrs, gfp_t gfp_flags)* uncached and return cached struct nfs4_pnfs_ds. */ struct nfs4_pnfs_ds * -nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,gfp_t gfp_flags) +nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,u32 version, +gfp_t gfp_flags) {struct nfs_net *nn =net_generic (net, nfs_net_id);struct nfs4_pnfs_ds *tmp_ds, *ds =NULL ;
@@ -784,7 +787,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_fla remotestr =nfs4_pnfs_remotestr (dsaddrs, gfp_flags);spin_lock (&nn->nfs4_data_server_lock); - tmp_ds =_data_server_lookup_locked (nn, dsaddrs); + tmp_ds =_data_server_lookup_locked (nn, dsaddrs, version);if (tmp_ds ==NULL ) {INIT_LIST_HEAD (&ds->ds_addrs);list_splice_init (dsaddrs, &ds->ds_addrs);
@@ -793,6 +796,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_flaINIT_LIST_HEAD (&ds->ds_node); ds->ds_net = net; ds->ds_clp =NULL ; + ds->ds_version = version;list_add (&ds->ds_node, &nn->nfs4_data_server_cache);dprintk ("%s add new data server %s\n" , __func__, ds->ds_remotestr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 877/935 scsi: qla2xxx: Fix an loop timeout test
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 11e48f5201fd86ffa038809dd9c41144d43ee2e4 ]
This loop timeout with "retries" set to -1, not 0. Fix the test for failure.
--- drivers/scsi/qla2xxx/qla_nx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_nx2.c +1 -1
@@ -3510,7 +3510,7 @@ qla8044_poll_flash_status_reg(struct scsi_qla_host *vha)msleep (QLA8044_FLASH_STATUS_REG_POLL_DELAY ); } -if (!retries) +if (retries ==-1 ) ret_val =QLA_FUNCTION_FAILED ;return ret_val;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 878/935 Bluetooth: compute LE flow credits based on recvbuf space
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Urban <[email protected]>
[ Upstream commit ce60b9231b66710b6ee24042ded26efee120ecfc ]
Previously LE flow credits were returned to the
sender even if the socket's receive buffer was
full. This meant that no back-pressure
was applied to the sender, thus it continued to
send data, resulting in data loss without any
error being reported. Furthermore, the amount
of credits was essentially fixed to a small
amount, leading to reduced performance.
This is fixed by computing the number of returned
LE flow credits based on the estimated available
space in the receive buffer of an L2CAP socket.
Consequently, if the receive buffer is full, no
credits are returned until the buffer is read and
thus cleared by user-space.
Since the computation of available receive buffer
space can only be performed approximately (due tosk_buff overhead) and the receive buffer size may
be changed by user-space after flow credits have
been sent, superfluous received data is temporary
stored within l2cap_pinfo. This is necessary
because Bluetooth LE provides no retransmission
mechanism once the data has been acked by the
physical layer.
If receive buffer space estimation is not possible at the moment, we fall back to providing credits for one full packet as before. This is currently the case during connection setup, when MPS is not yet available.
Stable-dep-of: d4bfa78fd679 ("Bluetooth: L2CAP: reject accept queue add unless BT_LISTEN")
--- include/net/bluetooth/l2cap.h | 11 ++++- net/bluetooth/l2cap_core.c | 56 ++++++++++++++++++--- net/bluetooth/l2cap_sock.c | 91 ++++++++++++++++++++++++++++------- 3 files changed, 132 insertions(+), 26 deletions(-)
include/net/bluetooth/l2cap.h +10 -1
@@ -587,6 +587,9 @@ struct l2cap_chan {__u16 tx_credits;__u16 rx_credits; +/* estimated available receive buffer space or -1 if unknown */ +ssize_t rx_avail; +__u8 tx_state;__u8 rx_state;
@@ -727,10 +730,15 @@ struct l2cap_user {/* ----- L2CAP socket info ----- */ #define l2cap_pi (sk) ((struct l2cap_pinfo *) sk) +struct l2cap_rx_busy { +struct list_head list; +struct sk_buff *skb; +}; +struct l2cap_pinfo {struct bt_sock bt;struct l2cap_chan *chan; -struct sk_buff *rx_busy_skb; +struct list_head rx_busy; };enum {
@@ -989,6 +997,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,int l2cap_chan_reconfigure (struct l2cap_chan *chan,__u16 mtu);int l2cap_chan_send (struct l2cap_chan *chan,struct msghdr *msg,size_t len);void l2cap_chan_busy (struct l2cap_chan *chan,int busy); +void l2cap_chan_rx_avail (struct l2cap_chan *chan,ssize_t rx_avail);int l2cap_chan_check_security (struct l2cap_chan *chan,bool initiator);void l2cap_chan_set_defaults (struct l2cap_chan *chan);int l2cap_ertm_init (struct l2cap_chan *chan);
net/bluetooth/l2cap_core.c +49 -7
104 lines not on this page · raw message
net/bluetooth/l2cap_sock.c +73 -18
166 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 879/935 bluetooth/l2cap: sync sock recv cb and release
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit 89e856e124f9ae548572c56b1b70c2255705f8fe ]
The problem occurs between the system call to close the sock and hci_rx_work, where the former releases the sock and the latter accesses it without lock protection.
CPU0 CPU1
---- ----
sock_close hci_rx_work
l2cap_sock_release hci_acldata_packet
l2cap_sock_kill l2cap_recv_frame
sk_free l2cap_conless_channel l2cap_sock_recv_cb
If hci_rx_work processes the data that needs to be received before the sock is closed, then everything is normal; Otherwise, the work thread may access the released sock when receiving data.
Add a chan mutex in the rx callback of the sock to achieve synchronization between the sock release and recv cb.
Sock is dead, so set chan data to NULL, avoid others use invalid sock pointer.
Stable-dep-of: d4bfa78fd679 ("Bluetooth: L2CAP: reject accept queue add unless BT_LISTEN")
--- net/bluetooth/l2cap_sock.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
net/bluetooth/l2cap_sock.c +22 -3
@@ -1270,6 +1270,10 @@ static void l2cap_sock_kill(struct sock *sk)BT_DBG ("sk %p state %s" , sk,state_to_string (sk->sk_state)); +/* Sock is dead, so set chan data to NULL, avoid other task use invalid +* sock pointer. +*/ +l2cap_pi (sk)->chan->data =NULL ;/* Kill poor orphan */ l2cap_chan_put (l2cap_pi (sk)->chan);
@@ -1552,12 +1556,25 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)static int l2cap_sock_recv_cb (struct l2cap_chan *chan,struct sk_buff *skb) { -struct sock *sk = chan->data; -struct l2cap_pinfo *pi =l2cap_pi (sk); +struct sock *sk; +struct l2cap_pinfo *pi;int err; -lock_sock (sk); +/* To avoid race with sock_release, a chan lock needs to be added here +* to synchronize the sock. +*/ +l2cap_chan_hold (chan); +l2cap_chan_lock (chan); + sk = chan->data; +if (!sk) { +l2cap_chan_unlock (chan); +l2cap_chan_put (chan); +return -ENXIO ; + } + + pi =l2cap_pi (sk); +lock_sock (sk);if (chan->mode ==L2CAP_MODE_ERTM && !list_empty (&pi->rx_busy)) { err = -ENOMEM ; goto done;
@@ -1606,6 +1623,8 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) done:release_sock (sk); +l2cap_chan_unlock (chan); +l2cap_chan_put (chan);return err; }
Signature · 1 line
2.53.0
Re: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Please hold this patch unless the applicable L2CAP hunks from upstream commit f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock") can also be included.
The connected receive path already holds chan->lock when it calls l2cap_sock_recv_cb(), so the lock added here recursively acquires the same mutex and blocks hci_rx_work.
I reproduced this on the exact 5.15.221-rc1 tip 0dce236725a538e8ddc0601eb0fb0bc43fc2c87b in QEMU with two linked virtual BR/EDR controllers. One normal 64-byte basic-mode L2CAP SDU triggered lockdep's recursive-lock deadlock report, left the hci0 receive worker blocked in __mutex_lock(), and was not delivered to the receiver.
With the two applicable f1a8f402f13f hunks applied, the same test received all 64 bytes, both endpoints completed, lockdep stayed silent and no worker was blocked.
The tested adaptation removes the callback's channel hold and lock, and adds channel locking within l2cap_conless_channel().
Thanks,
Karl
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Quoted 14 lines · Karl Mehltretter
Please hold this patch unless the applicable L2CAP hunks from upstream commit
f1a8f402f13f("Bluetooth: L2CAP: Fix deadlock") can also be included.The connected receive path already holds
chan->lockwhen it callsl2cap_sock_recv_cb(), so the lock added here recursively acquires the same mutex and blockshci_rx_work.I reproduced this on the exact 5.15.221-rc1 tip
0dce236725a538e8ddc0601eb0fb0bc43fc2c87bin QEMU with two linked virtual BR/EDR controllers. One normal 64-byte basic-mode L2CAP SDU triggered lockdep's recursive-lock deadlock report, left the hci0 receive worker blocked in__mutex_lock(), and was not delivered to the receiver.
Quoted 6 lines
With the two applicable
f1a8f402f13fhunks applied, the same test received all 64 bytes, both endpoints completed, lockdep stayed silent and no worker was blocked.The tested adaptation removes the callback's channel hold and lock, and adds channel locking within
l2cap_conless_channel().
Now dropped from 5.10.y and 5.15.y as for some reason this is marked as adep of something that is not actually in the queue.
thanks,
greg k-h
Sasha Levin
maintainerRe: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Quoted 2 lines
Now dropped from 5.10.y and 5.15.y as for some reason this is marked as adep of something that is not actually in the queue.
5.15 dropped it, but 5.10 did not: the backport of 89e856e124f9 ("bluetooth/l2cap: sync sock recv cb and release") is in v5.10.270. So the recursive chan->lock deadlock Karl reproduced is live in a released 5.10 kernel. I have queued a revert for 5.10.
f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock") cannot fill the gap on either tree, since hci_sync.c and hci_sync.h do not exist there.
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Quoted 11 lines · Sasha Levin
Quoted 2 lines
Now dropped from 5.10.y and 5.15.y as for some reason this is marked as adep of something that is not actually in the queue.
5.15 dropped it, but 5.10 did not: the backport of
89e856e124f9("bluetooth/l2cap: sync sock recv cb and release") is in v5.10.270. So the recursivechan->lockdeadlock Karl reproduced is live in a released 5.10 kernel. I have queued a revert for 5.10.
f1a8f402f13f("Bluetooth: L2CAP: Fix deadlock") cannot fill the gap on either tree, sincehci_sync.candhci_sync.hdo not exist there.
Those files are only touched by an unrelated cleanup in that commit, a conversion of hci_dev_cmd() off the old hci_request API. The deadlock fix itself is the two l2cap hunks, and both apply to 5.10.y and 5.15.y unchanged.
While testing I hit something else. Without 89e856e124f9 there is no NULL check in l2cap_sock_recv_cb(), but l2cap_sock_destruct() still sets chan->data to NULL, so recv_cb does lock_sock(NULL). Closing receiving sockets while L2CAP data is inbound, under QEMU+KASAN:
v5.15.221 as released NULL deref in recv_cb, fatal v5.10.270 + the queued revert same l2cap hunks + the guard clean
BUG: kernel NULL pointer dereference, address: 000000000000008c
Workqueue: hci0 hci_rx_work
lock_sock_nested
l2cap_sock_recv_cb+0x36/0xf0
l2cap_recv_frameSo the revert on its own trades the deadlock for this. I will send the l2cap_core.c hunk, which also fixes the unbalanced unlock you found, plus 89e856e124f9 without the recv_cb locking. I will repeat the runs and test on some real hardware before sending.
Thanks,
Karl
Sasha Levin
maintainerRe: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Quoted 4 lines
So the revert on its own trades the deadlock for this. I will send the
l2cap_core.chunk, which also fixes the unbalanced unlock you found, plus89e856e124f9without therecv_cblocking. I will repeat the runs and test on some real hardware before sending.
Thank you for running that down. I am holding the queued 5.10 revert of 89e856e124f9 ("bluetooth/l2cap: sync sock recv cb and release") out of the next release until your series arrives, since shipping it alone reopens the NULL deref you reproduced.
I also withdraw my objection that f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock") is unlandable on these trees. You are right that the fix is the l2cap_core.c and l2cap_sock.c hunks and that the hci_sync and hci_core hunks are an unrelated hci_dev_cmd() refactor.
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Quoted 11 lines · Sasha Levin
Thank you for running that down. I am holding the queued 5.10 revert of
89e856e124f9("bluetooth/l2cap: sync sock recv cb and release") out of the next release until your series arrives, since shipping it alone reopens the NULL deref you reproduced.I also withdraw my objection that
f1a8f402f13f("Bluetooth: L2CAP: Fix deadlock") is unlandable on these trees. You are right that the fix is thel2cap_core.candl2cap_sock.chunks and that thehci_syncandhci_corehunks are an unrelatedhci_dev_cmd()refactor.
Both are now posted.
5.10.y, one patch:
https://lore.kernel.org/stable/[email protected]/
5.15.y, two patches:
https://lore.kernel.org/stable/[email protected]/
5.10.y needs only the one patch because it already has 89e856e124f9, so both L2CAP hunks of f1a8f402f13f apply there unchanged. 5.15.y never received 89e856e124f9, so it needs the conless lock first and the guard second.
Thanks,
Karl
PATCH 1/1 Bluetooth: L2CAP: Fix deadlock
In reply to Karl MehltretterFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f1a8f402f13f94263cf349216c257b2985100927 ]
This fixes the following deadlock introduced by 39a92a55be13 ("bluetooth/l2cap: sync sock recv cb and release")
============================================
WARNING: possible recursive locking detected 6.10.0-rc3-g4029dba6b6f1 #6823 Not tainted
--------------------------------------------
kworker/u5:0/35 is trying to acquire lock:ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:l2cap_sock_recv_cb+0x44/0x1e0
but task is already holding lock:ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:l2cap_get_chan_by_scid+0xaf/0xd0
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&chan->lock#2/1);
lock(&chan->lock#2/1);
*** DEADLOCK ***
May be due to missing lock nesting notation
3 locks held by kworker/u5:0/35:
#0: ffff888002b8a940 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
process_one_work+0x750/0x930
#1: ffff888002c67dd0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
at: process_one_work+0x44e/0x930
#2: ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:
l2cap_get_chan_by_scid+0xaf/0xd0To fix the original problem this introduces l2cap_chan_lock at l2cap_conless_channel to ensure that l2cap_sock_recv_cb is called with chan->lock held.
[ Karl Mehltretter: only the l2cap_core.c and l2cap_sock.c hunks apply
to this tree. hci_sync.c and hci_sync.h do not exist here, and the hci_core.c change is an unrelated conversion of hci_dev_cmd() off the old hci_request API. The changes to both L2CAP files apply unmodified.
The lock this adds to l2cap_conless_channel() is also the one that commit c531e63871c0 ("Bluetooth: l2cap: always unlock channel in l2cap_conless_channel()") was backported without, so it additionally pairs the l2cap_chan_unlock() that function currently calls on a mutex it never acquired. ]
---
Notes:
This is intended to replace the queued revert of
commit 2243127db6ba ("bluetooth/l2cap: sync sock recv cb and release"), rather than to be applied on top of it.
The revert fixes the deadlock but removes the NULL guard from l2cap_sock_recv_cb(), while l2cap_sock_destruct() still sets chan->data to NULL. Under KASAN, closing receiving sockets while L2CAP data is inbound then gives a fatal NULL dereference in hci_rx_work, reproduced 3/3 on v5.10.270 with the queued revert applied. This patch keeps the guard and fixes the deadlock in one step, and uses the two applicable upstream L2CAP hunks unmodified.
Tested in QEMU with two virtual BR/EDR controllers, PROVE_LOCKING, DEBUG_MUTEXES and KASAN:
v5.10.270 as released recursive chan->lock deadlock
v5.10.270 + the queued revert fatal NULL deref, 3/3
v5.10.270 + this patch clean 3/3, 300 close cycles each
BlueZ's own l2cap-tester also deadlocks hci_rx_work on v5.10.270 and never completes. With this patch all six tester suites run to completion.
Also on a Raspberry Pi 400 (BCM2711, onboard CYW43455) with a second board as the L2CAP peer, each test from its own boot so lockdep was armed for each:
v5.10.270 as released, connectionless bad unlock balance
v5.10.270 as released, connected possible recursive locking
v5.10.270 + this patch, connectionless clean, debug_locks still 1
v5.10.270 + this patch, connected clean, debug_locks still 1
The same board with an A2DP speaker shows the user-visible effect. On v5.10.270 as released, connecting to the speaker deadlocks hci_rx_work and playback cannot start at all:
bluetoothd: a2dp-source profile connect failed: Device or resource busy
task:kworker/u9:0 state:D
Workqueue: hci0 hci_rx_work [bluetooth]
__mutex_lock
l2cap_sock_recv_cb
l2cap_recv_frame
l2cap_recv_acldata
hci_rx_work
With this patch the same speaker connects and plays the full track with no kernel warning and debug_locks still 1.
If the queued revert is kept instead, the same end state is reachable with two patches on top of it, which I can send.
net/bluetooth/l2cap_core.c | 3 +++ net/bluetooth/l2cap_sock.c | 13 +------------ 2 files changed, 4 insertions(+), 12 deletions(-)
net/bluetooth/l2cap_core.c +3 -0
@@ -8044,6 +8044,8 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm,BT_DBG ("chan %p, len %d" , chan, skb->len); +l2cap_chan_lock (chan); +if (chan->state !=BT_BOUND && chan->state !=BT_CONNECTED ) goto drop;
@@ -8061,6 +8063,7 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, } drop: +l2cap_chan_unlock (chan);l2cap_chan_put (chan); free_skb:kfree_skb (skb);
net/bluetooth/l2cap_sock.c +1 -12
@@ -1548,18 +1548,9 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)struct l2cap_pinfo *pi;int err; -/* To avoid race with sock_release, a chan lock needs to be added here -* to synchronize the sock. -*/ -l2cap_chan_hold (chan); -l2cap_chan_lock (chan); sk = chan->data; - -if (!sk) { -l2cap_chan_unlock (chan); -l2cap_chan_put (chan); +if (!sk)return -ENXIO ; - } pi =l2cap_pi (sk);lock_sock (sk);
@@ -1611,8 +1602,6 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) done:release_sock (sk); -l2cap_chan_unlock (chan); -l2cap_chan_put (chan);return err; }
base-commit: 1797d8bf8d0c2e74defad605d14e3553d43a3caf
Signature · 1 line
2.53.0
RE: [5.10.y] Bluetooth: L2CAP: Fix deadlock
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/bluetooth/l2cap_core.c:8044
error: net/bluetooth/l2cap_core.c: patch does not apply
error: patch failed: net/bluetooth/l2cap_sock.c:1548
error: net/bluetooth/l2cap_sock.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
Re: [PATCH 5.10.y] Bluetooth: L2CAP: Fix deadlock
In reply to Karl MehltretterQuoted 4 lines
[ Upstream commit
f1a8f402f13f94263cf349216c257b2985100927]This fixes the following deadlock introduced by
39a92a55be13("bluetooth/l2cap: sync sock recv cb and release")
Queued for 5.10, thanks.
89e856e124f9 ("bluetooth/l2cap: sync sock recv cb and release") is back on 5.10 as well, so the tree now has both halves rather than the revert.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerRe: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
In reply to Karl MehltretterQuoted 3 lines
Please hold this patch unless the applicable L2CAP hunks from upstream commit
f1a8f402f13f("Bluetooth: L2CAP: Fix deadlock") can also be included.
Your analysis matches what I see, and thank you for the reproducer.
There is no way to bring the upstream fix to these trees, though. f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock") touches include/net/bluetooth/hci_sync.h and net/bluetooth/hci_sync.c, and neither file exists on 5.15 or 5.10. Its own follow-up 87be7b189b2c ("Bluetooth: Fix usage of __hci_cmd_sync_status") is unlandable for the same reason. So the only options here are hand written hunks or leaving the recursive lock in place.
Separately, while looking at this: both 5.15 and 5.10 carry c531e63871c0 ("Bluetooth: l2cap: always unlock channel in l2cap_conless_channel()") without its prerequisite, so l2cap_conless_channel() calls l2cap_chan_unlock() on a mutex it never acquired.
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 5.15 879/935] bluetooth/l2cap: sync sock recv cb and release
Quoted 9 lines · Sasha Levin
Quoted 3 lines
Please hold this patch unless the applicable L2CAP hunks from upstream commit
f1a8f402f13f("Bluetooth: L2CAP: Fix deadlock") can also be included.Separately, while looking at this: both 5.15 and 5.10 carry
c531e63871c0("Bluetooth: l2cap: always unlock channel inl2cap_conless_channel()") without its prerequisite, sol2cap_conless_channel()callsl2cap_chan_unlock()on a mutex it never acquired.
Good point regarding the unbalanced locking.
I believe a backport of the applicable L2CAP hunks from f1a8f402f13f also fixes what you found in l2cap_conless_channel(). I will test and submit that for 5.15.y and 5.10.y soon.
Thanks,
Karl
cover Bluetooth: L2CAP: fix connectionless receive path
In reply to Karl Mehltretter5.15.y has two problems on the L2CAP connectionless receive path. The first comes from a backport that landed without its prerequisite, the second from a fix that never landed at all. Upstream contains both fixes.
1) c531e63871c0 ("Bluetooth: l2cap: always unlock channel in l2cap_conless_channel()") was backported as 5caf0ffaf915 without f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock"), which is what adds the matching lock. l2cap_conless_channel() therefore calls l2cap_chan_unlock() on a mutex it never acquired, and l2cap_sock_recv_cb() runs with no chan->lock at all on that path. Patch 1 applies the l2cap_core.c hunks of f1a8f402f13f, which supply the lock.
2) 89e856e124f9 ("bluetooth/l2cap: sync sock recv cb and release") never landed here, so l2cap_sock_recv_cb() has no NULL check on chan->data, while l2cap_sock_destruct() still sets it to NULL. Closing a receiving socket while L2CAP data is inbound gives lock_sock(NULL). Patch 2 restores that guard in the form the commit has after f1a8f402f13f, that is without the channel locking that caused the recursive chan->lock deadlock.
89e856e124f9 is the fix for CVE-2024-41062. It went to 6.1.101, 6.6.42, 6.9.11 and 6.10 in July 2024 and to 5.10.270 this month. 5.15.y has never carried it.
On why patch 1 is only part of f1a8f402f13f: as posted, that patch touched only net/bluetooth/l2cap_core.c and net/bluetooth/l2cap_sock.c.
https://lore.kernel.org/linux-bluetooth/[email protected]/
The hci_core.c, hci_sync.c and hci_sync.h changes in the merged commit come from a separate patch that was squashed into it while the pull request was prepared. The author noted this when the AUTOSEL backport came up in 2024 and said that for stable it would be better to unmerge them:
Of the two posted files, only the l2cap_core.c side applies here, because l2cap_sock_recv_cb() in 5.15.y has no channel locking to remove.
Tested in QEMU with two virtual BR/EDR controllers, PROVE_LOCKING, DEBUG_MUTEXES and KASAN. Three runs of each variant:
v5.15.221 as released bad unlock balance, and a fatal NULL dereference
in l2cap_sock_recv_cb() from hci_rx_work, 3/3
+ patch 1 unbalanced unlock gone, NULL deref remains 3/3
+ patch 1 and 2 clean 3/3 over 300 socket close cycles
BUG: kernel NULL pointer dereference, address: 000000000000008c
Workqueue: hci0 hci_rx_work
lock_sock_nested
l2cap_sock_recv_cb+0x36/0xf0
l2cap_recv_frameBlueZ l2cap-tester, rfcomm-tester, smp-tester, bnep-tester, sco-tester and hci-tester give identical results before and after.
Also on a Raspberry Pi 400 with a second board as the L2CAP peer, each test from its own boot so lockdep was armed for each. The released kernel reproduced the connectionless lockdep warning, and both it and the patch-1-only kernel died under teardown stress. With both patches, 300 receiver close cycles against 25,877 peer datagram floods completed with no warning and debug_locks still 1. Connected L2CAP and A2DP playback showed no regression on any of the three. The hardware crashes left no readable trace, so the attributed NULL dereference above is from QEMU.
The 5.10.y fix has a different shape and was sent separately as [email protected]. That tree still has 89e856e124f9, so both L2CAP hunks of f1a8f402f13f apply there unchanged and one patch covers it.
base-commit: 0248c33e835ecbec3a591f93fdaae53f7b90a4d6
PATCH 1/2 Bluetooth: L2CAP: Fix deadlock
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f1a8f402f13f94263cf349216c257b2985100927 ]
This fixes the following deadlock introduced by 39a92a55be13 ("bluetooth/l2cap: sync sock recv cb and release")
============================================
WARNING: possible recursive locking detected 6.10.0-rc3-g4029dba6b6f1 #6823 Not tainted
--------------------------------------------
kworker/u5:0/35 is trying to acquire lock:ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:l2cap_sock_recv_cb+0x44/0x1e0
but task is already holding lock:ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:l2cap_get_chan_by_scid+0xaf/0xd0
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&chan->lock#2/1);
lock(&chan->lock#2/1);
*** DEADLOCK ***
May be due to missing lock nesting notation
3 locks held by kworker/u5:0/35:
#0: ffff888002b8a940 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
process_one_work+0x750/0x930
#1: ffff888002c67dd0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
at: process_one_work+0x44e/0x930
#2: ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:
l2cap_get_chan_by_scid+0xaf/0xd0To fix the original problem this introduces l2cap_chan_lock at l2cap_conless_channel to ensure that l2cap_sock_recv_cb is called with chan->lock held.
[ Karl Mehltretter: backport only the l2cap_core.c changes. The HCI
changes are from an unrelated patch accidentally squashed into this commit. The l2cap_sock.c change removes locking added by 89e856e124f9, which is absent from 5.15.y, so the quoted deadlock cannot occur. The core changes are needed because c531e63871c0 was backported without the matching lock. ]
---
net/bluetooth/l2cap_core.c +3 -0
@@ -7992,6 +7992,8 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm,BT_DBG ("chan %p, len %d" , chan, skb->len); +l2cap_chan_lock (chan); +if (chan->state !=BT_BOUND && chan->state !=BT_CONNECTED ) goto drop;
@@ -8009,6 +8011,7 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, } drop: +l2cap_chan_unlock (chan);l2cap_chan_put (chan); free_skb:kfree_skb (skb);
Signature · 1 line
2.51.0
RE: [5.15.y,1/2] Bluetooth: L2CAP: Fix deadlock
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/bluetooth/l2cap_core.c:7992
error: net/bluetooth/l2cap_core.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
PATCH 2/2 bluetooth/l2cap: sync sock recv cb and release
In reply to Karl MehltretterFrom: Edward Adam Davis <[email protected]>
[ Upstream commit 89e856e124f9ae548572c56b1b70c2255705f8fe ]
The problem occurs between the system call to close the sock and hci_rx_work, where the former releases the sock and the latter accesses it without lock protection.
CPU0 CPU1
---- ----
sock_close hci_rx_work
l2cap_sock_release hci_acldata_packet
l2cap_sock_kill l2cap_recv_frame
sk_free l2cap_conless_channel l2cap_sock_recv_cb
If hci_rx_work processes the data that needs to be received before the sock is closed, then everything is normal; Otherwise, the work thread may access the released sock when receiving data.
Add a chan mutex in the rx callback of the sock to achieve synchronization between the sock release and recv cb.
Sock is dead, so set chan data to NULL, avoid others use invalid sock pointer.
[ Karl Mehltretter: applied in the form this commit has after
f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock"), that is the chan->data clearing in l2cap_sock_kill() and the guard in l2cap_sock_recv_cb(), without the channel locking in the callback. That locking is what caused the recursive chan->lock deadlock. f1a8f402f13f removes it and moves the lock to l2cap_conless_channel(), which the previous patch does here. l2cap_data_channel() already obtains the channel locked from l2cap_get_chan_by_scid(). ]
---
net/bluetooth/l2cap_sock.c +9 -1
@@ -1237,6 +1237,10 @@ static void l2cap_sock_kill(struct sock *sk)BT_DBG ("sk %p state %s" , sk,state_to_string (sk->sk_state)); +/* Sock is dead, so set chan data to NULL, avoid other task use invalid +* sock pointer. +*/ +l2cap_pi (sk)->chan->data =NULL ;/* Kill poor orphan */ l2cap_chan_put (l2cap_pi (sk)->chan);
@@ -1519,9 +1523,13 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)static int l2cap_sock_recv_cb (struct l2cap_chan *chan,struct sk_buff *skb) { -struct sock *sk = chan->data; +struct sock *sk;int err; + sk = chan->data; +if (!sk) +return -ENXIO ; +lock_sock (sk);if (l2cap_pi (sk)->rx_busy_skb) {
Signature · 1 line
2.51.0
Re: [PATCH 5.15.y 0/2] Bluetooth: L2CAP: fix connectionless receive path
In reply to Karl MehltretterQuoted 3 lines
5.15.y has two problems on the L2CAP connectionless receive path. The first comes from a backport that landed without its prerequisite, the second from a fix that never landed at all. Upstream contains both fixes.
Queued the series for 5.15, thanks. The write-up of why only the l2cap_core.c half of f1a8f402f13f ("Bluetooth: L2CAP: Fix deadlock") belongs here was useful.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 880/935 Bluetooth: 6lowpan: fix cyclic locking warning on netdev unregister
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 9707a015fe8f3ba8ec7c270f3b2b8efb38823d6b ]
6lowpan.c has theoretically conflicting lock orderings, which lockdep complains about:
a) rtnl_lock > hdev->workqueue
from 6lowpan.c:delete_netdev -> rtnl_lock -> device_del
-> put_device(parent) -> hci_release_dev -> destroy_workqueue
b) hdev->workqueue > l2cap_conn->lock > chan->lock > rtnl_lock
from hci_rx_work -> 6lowpan.c:chan_ready_cb
-> lowpan_register_netdev, ifup -> rtnl_lockActual deadlock appears not possible, as hci_rx_work is disabled and l2cap_conn flushed already on hdev unregister. Hence, do minimal thing to make lockdep happy by breaking chain a) by holding hdev refcount until after netdev put in 6lowpan.c.
Fixes the lockdep complaint:
WARNING: possible circular locking dependency detected.
kworker/0:1/11 is trying to acquire lock:ffff8880023b3940 ((wq_completion)hci0#2){+.+.}-{0:0}, at: touch_wq_lockdep_map+0x8b/0x130 but task is already holding lock:ffffffff95e4f9c0 (rtnl_mutex){+.+.}-{4:4}, at: lowpan_unregister_netdev+0xd/0x30
Workqueue: events delete_netdev
Stable-dep-of: d4bfa78fd679 ("Bluetooth: L2CAP: reject accept queue add unless BT_LISTEN")
--- net/bluetooth/6lowpan.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
net/bluetooth/6lowpan.c +23 -2
@@ -758,13 +758,33 @@ static inline struct l2cap_chan *chan_new_conn_cb(struct l2cap_chan *pchan)return chan; } +static void unregister_dev (struct lowpan_btle_dev *dev) +{ +struct hci_dev *hdev =READ_ONCE (dev->hdev); + +/* If netdev holds last reference to hci_dev (its parent device), this +* leads to theoretical cyclic locking on lowpan_unregister_netdev: +* +* rtnl_lock -> put_device(parent) -> hci_release_dev -> +* destroy_workqueue -> hci_rx_work -> l2cap_recv_acldata -> +* chan_ready_cb -> ifup -> rtnl_lock +* +* However, hci_rx_work is disabled in hci_unregister_dev, so this +* should not occur. Make lockdep happy by postponing hdev release after +* netdev put. +*/ +hci_dev_hold (hdev); +lowpan_unregister_netdev (dev->netdev); +hci_dev_put (hdev); +} +static void delete_netdev (struct work_struct *work) {struct lowpan_btle_dev *entry =container_of (work, struct lowpan_btle_dev, delete_netdev); -lowpan_unregister_netdev (entry->netdev); +unregister_dev (entry);/* The entry pointer is deleted by the netdev destructor. */ }
@@ -1232,6 +1252,7 @@ static void disconnect_devices(void)break ; new_dev->netdev = entry->netdev; + new_dev->hdev = entry->hdev;INIT_LIST_HEAD (&new_dev->list);list_add_rcu (&new_dev->list, &devices);
@@ -1243,7 +1264,7 @@ static void disconnect_devices(void)ifdown (entry->netdev);BT_DBG ("Unregistering netdev %s %p" , entry->netdev->name, entry->netdev); -lowpan_unregister_netdev (entry->netdev); +unregister_dev (entry);kfree (entry); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 881/935 Bluetooth: btmtksdio: Take exclusive ownership of the SKB before TX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 155e3003d1e614f85566b636973df7118e1b4851 ]
btmtksdio_tx_packet() prepends the MediaTek SDIO header with skb_push() and writes into that space after only checking the headroom size. On a cloned SKB that headroom belongs to a buffer shared with the other owner, which the driver has no right to write to.
Cloned SKBs do reach this path: hci_send_cmd_sync() keeps a clone of every HCI command in hdev->sent_cmd before handing the SKB to the driver, and l2cap_ertm_send() clones SKBs for retransmission.
Replace the open-coded headroom check with skb_cow_head(), which both guarantees the headroom and reallocates a private buffer when the SKB is cloned. The cost is one reallocation and copy per cloned packet, the usual price of this pattern in network drivers.
This has no observable effect on its own, as the driver only writes in front of skb->data where no other owner looks. It is a prerequisite for "Bluetooth: btmtksdio: Fix out-of-bounds DMA read in the TX path", which writes padding behind skb->tail, and carries the same Fixes: tag so that both are backported together.
--- drivers/bluetooth/btmtksdio.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/bluetooth/btmtksdio.c +6 -7
@@ -263,13 +263,12 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev,struct mtkbtsdio_hdr *sdio_hdr;int err; -/* Make sure that there are enough rooms for SDIO header */ -if (unlikely (skb_headroom (skb) <sizeof (*sdio_hdr))) { - err =pskb_expand_head (skb,sizeof (*sdio_hdr),0 , -GFP_ATOMIC ); -if (err <0 ) -return err; - } +/* Make sure that the data buffer is not shared with anyone else and +* that there is enough room for the SDIO header +*/ + err =skb_cow_head (skb,sizeof (*sdio_hdr)); +if (err <0 ) +return err;/* Prepend MediaTek SDIO Specific Header */ skb_push (skb,sizeof (*sdio_hdr));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 882/935 Bluetooth: RFCOMM: Validate MTU in rfcomm_apply_pn() to prevent infinite loop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 44c98fd082eafd49d55a8a4077ff488175b2fe24 ]
rfcomm_apply_pn() accepts the MTU value from a remote PN (Parameter Negotiation) frame without checking for zero. When the remote peer sends an MTU of zero, d->mtu is set to 0. This causes the sendmsg path to enter an infinite loop when fragmenting data, as each fragment has size == min_t(size_t, len, 0) == 0, so the remaining length never decreases. The infinite allocation of zero-length skbs exhausts all system memory.
Fix by clamping d->mtu to RFCOMM_DEFAULT_MTU when the negotiated value is zero, consistent with the initial value assigned in rfcomm_dlc_alloc().
--- net/bluetooth/rfcomm/core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/rfcomm/core.c +4 -0
@@ -1454,6 +1454,10 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn) d->mtu =__le16_to_cpu (pn->mtu); +/* MTU 0 causes an infinite loop when fragmenting in sendmsg */ +if (!d->mtu) + d->mtu =RFCOMM_DEFAULT_MTU ; +if (cr && d->mtu > s->mtu) d->mtu = s->mtu;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 883/935 gtp: add synchronize_net() in gtp_newlink() error path to prevent use-after-free
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
[ Upstream commit d989e22ae9802c52c56ad4284d0caf26696cf6ae ]
gtp_newlink()'s error path frees tid_hash and addr_hash without waiting for an RCU grace period after clearing sk_user_data. A concurrent gtp_encap_recv() in softirq may still hold the gtp_dev pointer obtained via rcu_dereference_sk_user_data() and access the freed memory.
BUG: KASAN: slab-use-after-free in gtp0_pdp_find+0x1f6/0x200 (gtp.c:152) Call Trace: <IRQ> gtp0_pdp_find+0x1f6/0x200 gtp_encap_recv+0x527/0x24b0 udp_queue_rcv_one_skb+0x75f/0xc10
Add synchronize_net() before the kfree calls in out_hashtable, which covers all error paths from both gtp_encap_enable() and gtp_create_sockets().
--- drivers/net/gtp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/gtp.c +2 -0
@@ -708,6 +708,8 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev, out_encap:gtp_encap_disable (gtp); out_hashtable: +/* Wait for RCU readers that may still reference this gtp_dev. */ +synchronize_net ();kfree (gtp->addr_hash);kfree (gtp->tid_hash);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 884/935 net: qualcomm: rmnet: restore skb->dev on deaggregated frames
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit a66734a1c5e36525ea07e9f4547fddc51e916de3 ]
rmnet_map_deaggregate() allocates each sub-frame with alloc_skb() and leaves skb->dev NULL. __rmnet_map_ingress_handler() assigns skb->dev = ep->egress_dev only on the data path, but a MAP command frame is dispatched to rmnet_map_command() before that, so rmnet_map_send_ack() runs netif_tx_lock(skb->dev) on a NULL device. An unprivileged user reaches this by unsharing a user+net namespace, creating an rmnet link over a tap device with INGRESS_DEAGGREGATION and INGRESS_MAP_COMMANDS, and writing an aggregated frame carrying a flow-control command to the tap fd.
Restore the assignment dropped by 378e25357ac7, so every skb leaving rmnet_map_deaggregate() has a valid device.
BUG: KASAN: null-ptr-deref in _raw_spin_lock (kernel/locking/spinlock.c:158) Write of size 4 at addr 00000000000004b4 by task exploit/144 Call Trace: _raw_spin_lock (kernel/locking/spinlock.c:158) netif_tx_lock (net/sched/sch_generic.c:497) rmnet_map_command (drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c:67) rmnet_rx_handler (drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:125) __netif_receive_skb_core.constprop.0 (net/core/dev.c:6103) ... __netif_receive_skb_one_core (net/core/dev.c:6214) netif_receive_skb (net/core/dev.c:6474) tun_get_user (drivers/net/tun.c:1966) tun_chr_write_iter (drivers/net/tun.c:2012) vfs_write (fs/read_write.c:687) ksys_write (fs/read_write.c:739) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception in interrupt
--- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +1 -0
@@ -396,6 +396,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,if (!skbn)return NULL ; + skbn->dev = skb->dev;skb_reserve (skbn,RMNET_MAP_DEAGGR_HEADROOM );skb_put (skbn, packet_len);memcpy (skbn->data, skb->data, packet_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 885/935 octeontx2-af: Fix TL3/TL2 link config ENA clearing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naveen Mamindlapalli <[email protected]>
[ Upstream commit 9edf8d4876e8a2471e66f54d36208eaff2858392 ]
Clear and restore the ENA bit for each TL3/TL2 link entry during SMQ flush instead of repeatedly using the same link index.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +5 -6
@@ -2200,8 +2200,8 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,int pf =rvu_get_pf (pcifunc);u8 cgx_id =0 , lmac_id =0 ;u16 tl2_tl3_link_schq; -u8 link, link_level;u64 cfg, bmap =0 ; +u8 link_level;/* enable cgx tx if disabled */ if (is_pf_cgxmapped (rvu, pf)) {
@@ -2226,7 +2226,6 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr, link_level =rvu_read64 (rvu, blkaddr,NIX_AF_PSE_CHANNEL_LEVEL ) &0x01 ?NIX_TXSCH_LVL_TL3 :NIX_TXSCH_LVL_TL2 ; tl2_tl3_link_schq = smq_flush_ctx->smq_tree_ctx[link_level].schq; - link = smq_flush_ctx->smq_tree_ctx[NIX_TXSCH_LVL_TL1 ].schq;/* SMQ set enqueue xoff */ cfg =rvu_read64 (rvu, blkaddr,NIX_AF_SMQX_CFG (smq));
@@ -2236,13 +2235,13 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,/* Clear all NIX_AF_TL3_TL2_LINK_CFG[ENA] for the TL3/TL2 queue */ for (i =0 ; i < (rvu->hw->cgx_links + rvu->hw->lbk_links); i++) { cfg =rvu_read64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link)); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i));if (!(cfg &BIT_ULL (12 )))continue ; bmap |=BIT_ULL (i); cfg &= ~BIT_ULL (12 );rvu_write64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link), cfg); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i), cfg); }/* Do SMQ flush and set enqueue xoff */
@@ -2263,10 +2262,10 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,if (!(bmap &BIT_ULL (i)))continue ; cfg =rvu_read64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link)); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i)); cfg |=BIT_ULL (12 );rvu_write64 (rvu, blkaddr, -NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, link), cfg); +NIX_AF_TL3_TL2X_LINKX_CFG (tl2_tl3_link_schq, i), cfg); }/* clear XOFF on TL2s */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 886/935 net/rds: use wq_has_sleeper() in rds_cong_map_updated()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit d4f484661961636eb90d287050959e613795f73a ]
rds_cong_map_updated() runs after a peer's congestion map has been rewritten (by rds_tcp_cong_recv() and rds_ib_cong_recv(), or the clear-all in the loopback and IB send-completion paths). It bumps rds_cong_generation and then checks waitqueue_active() on map->m_waitq and on rds_poll_waitq to decide whether anyone needs waking. atomic_inc() carries no ordering and waitqueue_active() is a plain load, so nothing orders the map and generation stores before the wait queue reads. The waiters do the mirror image: rds_cong_wait() adds itself to m_waitq and then tests the port bit, and rds_poll() registers on rds_poll_waitq and then reads the generation. That is the store-buffering pattern described above waitqueue_active() in include/linux/wait.h - the updater can observe an empty wait queue while the waiter still observes the port as congested, and no wake-up is issued.
rds_cong_wait() is an interruptible sleep with no timeout, so a sender blocked on a congested port stays blocked until the next congestion update from that peer arrives or a signal is delivered. A poll() waiter misses the map-updated notification the same way.
Use wq_has_sleeper(), which is waitqueue_active() preceded by the required full barrier, as rds_tcp_state_change() already does for the same pattern.
--- net/rds/cong.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/rds/cong.c +2 -2
@@ -256,9 +256,9 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask) map, &map->m_addr);rds_stats_inc (s_cong_update_received);atomic_inc (&rds_cong_generation); -if (waitqueue_active (&map->m_waitq)) +if (wq_has_sleeper (&map->m_waitq))wake_up (&map->m_waitq); -if (waitqueue_active (&rds_poll_waitq)) +if (wq_has_sleeper (&rds_poll_waitq))wake_up_all (&rds_poll_waitq);if (portmask && !list_empty (&rds_cong_monitor)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 887/935 cifs: fix clearing stats for fastest execution of each smb2 command
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit 48cab1fd5720508148673f59d8ed52c7c7fffca2 ]
The code to clear the 'fastest_cmd' statistics has a typo that repeatedly clears the stat for cmd 0, rather than iterating through each cmd. Fix the typo (0->i).
--- fs/cifs/cifs_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifs_debug.c +1 -1
@@ -526,7 +526,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,atomic_set (&server->smb2slowcmd[i],0 ); server->time_per_cmd[i] =0 ; server->slowest_cmd[i] =0 ; - server->fastest_cmd[0] = 0; + server->fastest_cmd[i] = 0; }#endif /* CONFIG_CIFS_STATS2 */ list_for_each (tmp2, &server->smb_ses_list) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 888/935 net_sched: act_skbmod: use RCU in tcf_skbmod_dump()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 53df77e7859042a92914d664c860f65d9689f88d ]
Also storing tcf_action into struct tcf_skbmod_params makes sure there is no discrepancy in tcf_skbmod_act().
No longer block BH in tcf_skbmod_init() when acquiring tcf_lock.
Stable-dep-of: 81d0d1e64f30 ("net/sched: act_skbmod: fix length calculations and avoid invalid header warnings")
--- include/net/tc_act/tc_skbmod.h | 1 + net/sched/act_skbmod.c | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-)
include/net/tc_act/tc_skbmod.h +1 -0
@@ -12,6 +12,7 @@struct tcf_skbmod_params {struct rcu_head rcu;u64 flags;/*up to 64 types of operations; extend if needed */ +int action;u8 eth_dst[ETH_ALEN ];u16 eth_type;u8 eth_src[ETH_ALEN ];
net/sched/act_skbmod.c +12 -14
@@ -25,19 +25,18 @@ static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res) {struct tcf_skbmod *d =to_skbmod (a); -int action, max_edit_len, err;struct tcf_skbmod_params *p; +int max_edit_len, err;u64 flags;tcf_lastuse_update (&d->tcf_tm);bstats_cpu_update (this_cpu_ptr (d->common.cpu_bstats), skb); - action =READ_ONCE (d->tcf_action); -if (unlikely (action ==TC_ACT_SHOT )) + p =rcu_dereference_bh (d->skbmod_p); +if (unlikely (p->action ==TC_ACT_SHOT )) goto drop; max_edit_len =skb_mac_header_len (skb); - p =rcu_dereference_bh (d->skbmod_p); flags = p->flags;/* tcf_skbmod_init() guarantees "flags" to be one of the following:
@@ -83,7 +82,7 @@ static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a,INET_ECN_set_ce (skb); out: -return action; +return p->action; drop:qstats_overlimit_inc (this_cpu_ptr (d->common.cpu_qstats));
@@ -191,9 +190,9 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, } p->flags = lflags; - + p->action = parm->action;if (ovr) -spin_lock_bh (&d->tcf_lock); +spin_lock (&d->tcf_lock);/* Protected by tcf_lock if overwriting existing action. */ goto_ch =tcf_action_set_ctrlact (*a, parm->action, goto_ch); p_old =rcu_dereference_protected (d->skbmod_p,1 );
@@ -207,7 +206,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,rcu_assign_pointer (d->skbmod_p, p);if (ovr) -spin_unlock_bh (&d->tcf_lock); +spin_unlock (&d->tcf_lock);if (p_old)kfree_rcu (p_old, rcu);
@@ -246,10 +245,9 @@ static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a, opt.index = d->tcf_index; opt.refcnt =refcount_read (&d->tcf_refcnt) - ref, opt.bindcnt =atomic_read (&d->tcf_bindcnt) - bind; -spin_lock_bh (&d->tcf_lock); - opt.action = d->tcf_action; - p =rcu_dereference_protected (d->skbmod_p, -lockdep_is_held (&d->tcf_lock)); +rcu_read_lock (); + p =rcu_dereference (d->skbmod_p); + opt.action = p->action; opt.flags = p->flags;if (nla_put (skb,TCA_SKBMOD_PARMS ,sizeof (opt), &opt)) goto nla_put_failure;
@@ -267,10 +265,10 @@ static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a,if (nla_put_64bit (skb,TCA_SKBMOD_TM ,sizeof (t), &t,TCA_SKBMOD_PAD )) goto nla_put_failure; -spin_unlock_bh (&d->tcf_lock); +rcu_read_unlock ();return skb->len; nla_put_failure: -spin_unlock_bh (&d->tcf_lock); +rcu_read_unlock ();nlmsg_trim (skb, b);return -1 ; }
Signature · 1 line
2.53.0
Re: [PATCH 5.15 888/935] net_sched: act_skbmod: use RCU in tcf_skbmod_dump()
Please hold this patch unless a 5.15 backport of upstream commit 3016024d7514 ("net_sched: add back BH safety to tcf_lock") can also be included.
This patch replaces spin_lock_bh() with spin_lock() in tcf_skbmod_init(). A rate estimator can take the same lock from timer softirq context, so the timer can interrupt action replacement while it holds the lock and deadlock on it.
I reproduced this on 5.15.221-rc1 in QEMU with lockdep: after the estimator timer ran, replacing an indexed skbmod action reported inconsistent softirq locking on tcfa_lock between est_timer() and tcf_skbmod_init().
With only the skbmod hunk from 3016024d7514 applied, restoring spin_lock_bh()/spin_unlock_bh(), the same test produced no lockdep warning.
Thanks,
Karl
Greg Kroah-Hartman
maintainerPATCH 889/935 net/sched: act_skbmod: fix length calculations and avoid invalid header warnings
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 81d0d1e64f30d9989c829c0953cd6e6c68d9c5fb ]
syzbot reported a warning in skb_network_header_len() triggered by tcf_skbmod_act():
!skb_transport_header_was_set(skb)
WARNING: CPU: 0 PID: 14949 at include/linux/skbuff.h:3243 skb_network_header_len include/linux/skbuff.h:3243 [inline] WARNING: CPU: 0 PID: 14949 at net/sched/act_skbmod.c:55 tcf_skbmod_act+0xfe8/0x1810 net/sched/act_skbmod.c:55
There are a few issues in tcf_skbmod_act():
1. Calling skb_network_header_len() assumes skb->transport_header is set, which is not guaranteed when tcf_skbmod_act() runs at TC ingress.
2. Unconditionally calling skb_mac_header_len() at the beginning of tcf_skbmod_act() triggers a warning on L3 devices (e.g. TUN) where the MAC header is unset, evaluating to an underflowed garbage length.
3. On TC ingress, skb->data points to the network header. Adding the MAC header length to the IP header length causes skb_ensure_writable() to request more bytes than the actual IP packet length, dropping valid short packets (e.g. 28-byte UDP/IPv4 packets).
Fix these by:
- Using skb_network_offset(skb) + sizeof(struct iphdr/ipv6hdr) for SKBMOD_F_ECN so that the required length is correctly calculated on both ingress (offset == 0) and egress (offset == mac_len).
- Setting max_edit_len to ETH_HLEN for Ethernet header modifications after validating ARPHRD_ETHER.
--- net/sched/act_skbmod.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/sched/act_skbmod.c +8 -4
@@ -36,7 +36,6 @@ static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a,if (unlikely (p->action ==TC_ACT_SHOT )) goto drop; - max_edit_len =skb_mac_header_len (skb); flags = p->flags;/* tcf_skbmod_init() guarantees "flags" to be one of the following:
@@ -49,14 +48,19 @@ static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a,if (flags ==SKBMOD_F_ECN ) {switch (skb_protocol (skb, true)) {case cpu_to_be16 (ETH_P_IP ): + max_edit_len =sizeof (struct iphdr ); +break ;case cpu_to_be16 (ETH_P_IPV6 ): - max_edit_len +=skb_network_header_len (skb); + max_edit_len =sizeof (struct ipv6hdr );break ;default : goto out; } - }else if (!skb->dev || skb->dev->type !=ARPHRD_ETHER ) { - goto out; + max_edit_len +=skb_network_offset (skb); + }else { +if (!skb->dev || skb->dev->type !=ARPHRD_ETHER ) + goto out; + max_edit_len =ETH_HLEN ; } err =skb_ensure_writable (skb, max_edit_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 890/935 net: ip6_gre: Remove the unused function ip6gre_tnl_addr_conflict()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiapeng Chong <[email protected]>
[ Upstream commit f00909e2e6fe4ac6b2420e3863a0c533fe4f15e0 ]
The function ip6gre_tnl_addr_conflict() is defined in the ip6_gre.c file, but not called elsewhere, so delete this unused function.
net/ipv6/ip6_gre.c:887:20: warning: unused function 'ip6gre_tnl_addr_conflict'.
Stable-dep-of: 709f34f7c28d ("net/sched: fq: add overflow bounds to quantum and initial quantum")
--- net/ipv6/ip6_gre.c | 20 -------------------- 1 file changed, 20 deletions(-)
net/ipv6/ip6_gre.c +0 -20
@@ -851,26 +851,6 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)return 0 ; } -/** -* ip6gre_tnl_addr_conflict - compare packet addresses to tunnel's own -* @t: the outgoing tunnel device -* @hdr: IPv6 header from the incoming packet -* -* Description: -* Avoid trivial tunneling loop by checking that tunnel exit-point -* doesn't match source of incoming packet. -* -* Return: -* 1 if conflict, -* 0 else -**/ - -static inline bool ip6gre_tnl_addr_conflict (const struct ip6_tnl *t, -const struct ipv6hdr *hdr) -{ -return ipv6_addr_equal (&t->parms.raddr, &hdr->saddr); -} -static int ip6gre_xmit_other (struct sk_buff *skb,struct net_device *dev) {struct ip6_tnl *t =netdev_priv (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 891/935 net_sched: sch_fq: struct sched_data reorg
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 54ff8ad69c6e93c0767451ae170b41c000e565dd ]
q->flows can be often modified, and q->timer_slack is read mostly.
Exchange the two fields, so that cache line countaining quantum, initial_quantum, and other critical parameters stay clean (read-mostly).
Move q->watchdog next to q->stat_throttled
Add comments explaining how the structure is split in three different parts.
pahole output before the patch:
struct fq_sched_data {
struct fq_flow_head new_flows; /* 0 0x10 */
struct fq_flow_head old_flows; /* 0x10 0x10 */
struct rb_root delayed; /* 0x20 0x8 */
u64 time_next_delayed_flow; /* 0x28 0x8 */
u64 ktime_cache; /* 0x30 0x8 */
unsigned long unthrottle_latency_ns; /* 0x38 0x8 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct fq_flow internal __attribute__((__aligned__(64))); /* 0x40 0x80 */
/* XXX last struct has 16 bytes of padding */
/* --- cacheline 3 boundary (192 bytes) --- */
u32 quantum; /* 0xc0 0x4 */
u32 initial_quantum; /* 0xc4 0x4 */
u32 flow_refill_delay; /* 0xc8 0x4 */
u32 flow_plimit; /* 0xcc 0x4 */
unsigned long flow_max_rate; /* 0xd0 0x8 */
u64 ce_threshold; /* 0xd8 0x8 */
u64 horizon; /* 0xe0 0x8 */
u32 orphan_mask; /* 0xe8 0x4 */
u32 low_rate_threshold; /* 0xec 0x4 */
struct rb_root * fq_root; /* 0xf0 0x8 */
u8 rate_enable; /* 0xf8 0x1 */
u8 fq_trees_log; /* 0xf9 0x1 */
u8 horizon_drop; /* 0xfa 0x1 */
/* XXX 1 byte hole, try to pack */<bad> u32 flows; /* 0xfc 0x4 */
/* --- cacheline 4 boundary (256 bytes) --- */ u32 inactive_flows; /* 0x100 0x4 */ u32 throttled_flows; /* 0x104 0x4 */ u64 stat_gc_flows; /* 0x108 0x8 */ u64 stat_internal_packets; /* 0x110 0x8 */ u64 stat_throttled; /* 0x118 0x8 */ u64 stat_ce_mark; /* 0x120 0x8 */ u64 stat_horizon_drops; /* 0x128 0x8 */ u64 stat_horizon_caps; /* 0x130 0x8 */ u64 stat_flows_plimit; /* 0x138 0x8 */ /* --- cacheline 5 boundary (320 bytes) --- */ u64 stat_pkts_too_long; /* 0x140 0x8 */ u64 stat_allocation_errors; /* 0x148 0x8 */
<bad> u32 timer_slack; /* 0x150 0x4 */
/* XXX 4 bytes hole, try to pack */ struct qdisc_watchdog watchdog; /* 0x158 0x48 */ /* size: 448, cachelines: 7, members: 34 */ /* sum members: 411, holes: 2, sum holes: 5 */ /* padding: 32 */ /* paddings: 1, sum paddings: 16 */ /* forced alignments: 1 */ };
pahole output after the patch:
struct fq_sched_data {
struct fq_flow_head new_flows; /* 0 0x10 */
struct fq_flow_head old_flows; /* 0x10 0x10 */
struct rb_root delayed; /* 0x20 0x8 */
u64 time_next_delayed_flow; /* 0x28 0x8 */
u64 ktime_cache; /* 0x30 0x8 */
unsigned long unthrottle_latency_ns; /* 0x38 0x8 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct fq_flow internal __attribute__((__aligned__(64))); /* 0x40 0x80 */
/* XXX last struct has 16 bytes of padding */
/* --- cacheline 3 boundary (192 bytes) --- */
u32 quantum; /* 0xc0 0x4 */
u32 initial_quantum; /* 0xc4 0x4 */
u32 flow_refill_delay; /* 0xc8 0x4 */
u32 flow_plimit; /* 0xcc 0x4 */
unsigned long flow_max_rate; /* 0xd0 0x8 */
u64 ce_threshold; /* 0xd8 0x8 */
u64 horizon; /* 0xe0 0x8 */
u32 orphan_mask; /* 0xe8 0x4 */
u32 low_rate_threshold; /* 0xec 0x4 */
struct rb_root * fq_root; /* 0xf0 0x8 */
u8 rate_enable; /* 0xf8 0x1 */
u8 fq_trees_log; /* 0xf9 0x1 */
u8 horizon_drop; /* 0xfa 0x1 */
/* XXX 1 byte hole, try to pack */<good> u32 timer_slack; /* 0xfc 0x4 */
/* --- cacheline 4 boundary (256 bytes) --- */ <good> u32 flows; /* 0x100 0x4 */ u32 inactive_flows; /* 0x104 0x4 */ u32 throttled_flows; /* 0x108 0x4 */
/* XXX 4 bytes hole, try to pack */ u64 stat_throttled; /* 0x110 0x8 */ <better> struct qdisc_watchdog watchdog; /* 0x118 0x48 */ /* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */ u64 stat_gc_flows; /* 0x160 0x8 */ u64 stat_internal_packets; /* 0x168 0x8 */ u64 stat_ce_mark; /* 0x170 0x8 */ u64 stat_horizon_drops; /* 0x178 0x8 */ /* --- cacheline 6 boundary (384 bytes) --- */ u64 stat_horizon_caps; /* 0x180 0x8 */ u64 stat_flows_plimit; /* 0x188 0x8 */ u64 stat_pkts_too_long; /* 0x190 0x8 */ u64 stat_allocation_errors; /* 0x198 0x8 */ /* Force padding: */ u64 :64; u64 :64; u64 :64; u64 :64; /* size: 448, cachelines: 7, members: 34 */ /* sum members: 411, holes: 2, sum holes: 5 */ /* padding: 32 */ /* paddings: 1, sum paddings: 16 */ /* forced alignments: 1 */ };
Stable-dep-of: 709f34f7c28d ("net/sched: fq: add overflow bounds to quantum and initial quantum")
--- net/sched/sch_fq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
net/sched/sch_fq.c +12 -4
@@ -104,6 +104,9 @@ struct fq_sched_data {unsigned long unthrottle_latency_ns;struct fq_flow internal;/* for non classified or high prio packets */ + +/* Read mostly cache line */ +u32 quantum;u32 initial_quantum;u32 flow_refill_delay;
@@ -117,22 +120,27 @@ struct fq_sched_data {u8 rate_enable;u8 fq_trees_log;u8 horizon_drop; +u32 timer_slack;/* hrtimer slack in ns */ + +/* Read/Write fields. */ +u32 flows;u32 inactive_flows;u32 throttled_flows; +u64 stat_throttled; +struct qdisc_watchdog watchdog;u64 stat_gc_flows; + +/* Seldom used fields. */ +u64 stat_internal_packets; -u64 stat_throttled;u64 stat_ce_mark;u64 stat_horizon_drops;u64 stat_horizon_caps;u64 stat_flows_plimit;u64 stat_pkts_too_long;u64 stat_allocation_errors; - -u32 timer_slack;/* hrtimer slack in ns */ -struct qdisc_watchdog watchdog; };/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 892/935 net_sched: sch_fq: change how @inactive is tracked
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit ee9af4e14d166c34ec78896bb1ba545249445df0 ]
Currently, when one fq qdisc has no more packets to send, it can still have some flows stored in its RR lists (q->new_flows & q->old_flows)
This was a design choice, but what is a bit disturbing is that the inactive_flows counter does not include the count of empty flows in RR lists.
As next patch needs to know better if there are active flows, this change makes inactive_flows exact.
Before the patch, following command on an empty qdisc could have returned:
lpaa17:~# tc -s -d qd sh dev eth1 | grep inactive flows 1322 (inactive 1316 throttled 0) flows 1330 (inactive 1325 throttled 0) flows 1193 (inactive 1190 throttled 0) flows 1208 (inactive 1202 throttled 0)
After the patch, we now have:
lpaa17:~# tc -s -d qd sh dev eth1 | grep inactive flows 1322 (inactive 1322 throttled 0) flows 1330 (inactive 1330 throttled 0) flows 1193 (inactive 1193 throttled 0) flows 1208 (inactive 1208 throttled 0)
Stable-dep-of: 709f34f7c28d ("net/sched: fq: add overflow bounds to quantum and initial quantum")
--- net/sched/sch_fq.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/sched/sch_fq.c +7 -5
@@ -125,7 +125,7 @@ struct fq_sched_data {/* Read/Write fields. */ u32 flows; -u32 inactive_flows; +u32 inactive_flows;/* Flows with no packet to send. */ u32 throttled_flows;u64 stat_throttled;
@@ -402,9 +402,12 @@ static void fq_erase_head(struct Qdisc *sch, struct fq_flow *flow,static void fq_dequeue_skb (struct Qdisc *sch,struct fq_flow *flow,struct sk_buff *skb) { +struct fq_sched_data *q =qdisc_priv (sch); +fq_erase_head (sch, flow, skb);skb_mark_not_on_list (skb); - flow->qlen--; +if (--flow->qlen ==0 ) + q->inactive_flows++;qdisc_qstats_backlog_dec (sch, skb); sch->q.qlen--; }
@@ -484,13 +487,13 @@ static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch,return qdisc_drop (skb, sch, to_free); } - f->qlen++; +if (f->qlen++ ==0 ) + q->inactive_flows--;qdisc_qstats_backlog_inc (sch, skb);if (fq_flow_is_detached (f)) {fq_flow_add_tail (&q->new_flows, f);if (time_after (jiffies, f->age + q->flow_refill_delay)) f->credit =max_t (u32, f->credit, q->quantum); - q->inactive_flows--; }/* Note: this overwrites f->age */
@@ -597,7 +600,6 @@ static struct sk_buff *fq_dequeue(struct Qdisc *sch)fq_flow_add_tail (&q->old_flows, f); }else {fq_flow_set_detached (f); - q->inactive_flows++; } goto begin; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 893/935 net_sched: export pfifo_fast prio2band[]
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 5579ee462dfe768297563a6083e21df52c3ad856 ]
pfifo_fast prio2band[] is renamed to sch_default_prio2band[] and exported because we want to share it in FQ.
Stable-dep-of: 709f34f7c28d ("net/sched: fq: add overflow bounds to quantum and initial quantum")
--- include/net/sch_generic.h | 1 + net/sched/sch_generic.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
include/net/sch_generic.h +1 -0
@@ -609,6 +609,7 @@ static inline void sch_tree_unlock(struct Qdisc *q)extern struct Qdisc noop_qdisc;extern struct Qdisc_ops noop_qdisc_ops;extern struct Qdisc_ops pfifo_fast_ops; +extern const u8 sch_default_prio2band[TC_PRIO_MAX +1 ];extern struct Qdisc_ops mq_qdisc_ops;extern struct Qdisc_ops noqueue_qdisc_ops;extern const struct Qdisc_ops *default_qdisc_ops;
net/sched/sch_generic.c +5 -4
@@ -646,9 +646,10 @@ struct Qdisc_ops noqueue_qdisc_ops __read_mostly = { .owner = THIS_MODULE, }; -static const u8 prio2band[TC_PRIO_MAX +1 ] = { -1 ,2 ,2 ,2 ,1 ,2 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 +const u8 sch_default_prio2band[TC_PRIO_MAX +1 ] = { +1 ,2 ,2 ,2 ,1 ,2 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 }; +EXPORT_SYMBOL (sch_default_prio2band);/* 3-band FIFO queue: old style, but should be a bit faster than generic prio+fifo combination.
@@ -673,7 +674,7 @@ static inline struct skb_array *band2list(struct pfifo_fast_priv *priv,static int pfifo_fast_enqueue (struct sk_buff *skb,struct Qdisc *qdisc,struct sk_buff **to_free) { -int band = prio2band[skb->priority &TC_PRIO_MAX ]; +int band = sch_default_prio2band[skb->priority &TC_PRIO_MAX ];struct pfifo_fast_priv *priv =qdisc_priv (qdisc);struct skb_array *q =band2list (priv, band);unsigned int pkt_len =qdisc_pkt_len (skb);
@@ -782,7 +783,7 @@ static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb) {struct tc_prio_qopt opt = { .bands =PFIFO_FAST_BANDS }; -memcpy (&opt.priomap, prio2band,TC_PRIO_MAX +1 ); +memcpy (&opt.priomap, sch_default_prio2band,TC_PRIO_MAX +1 );if (nla_put (skb,TCA_OPTIONS ,sizeof (opt), &opt)) goto nla_put_failure;return skb->len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 894/935 net/sched: fq_codel: clamp default quantum and mtu
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit d9ebd8f9aa8b2773235889cb903fafd61f2d8585 ]
fq_codel_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) without clamping. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000, which overflows the signed flow->deficit to INT_MIN in fq_codel_dequeue(), causing an infinite loop and soft lockup. Emulate fq_codel_change() and constrain to [256, FQ_CODEL_QUANTUM_MAX].
The same unclamped psched_mtu() is assigned to q->cparams.mtu a bit below, and fq_codel_change() never updates it. codel_should_drop() tests "*backlog <= params->mtu"; with mtu == 0x80000000 (~2 GiB) and the default 32 MiB memory_limit, the test is always true, so CoDel is silently and completely disabled (no drops, no ECN). Declare a single clamped mtu and assign both q->quantum and q->cparams.mtu from it, which also removes the double psched_mtu() call.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_fq_codel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +4 -2
@@ -491,6 +491,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) {struct fq_codel_sched_data *q =qdisc_priv (sch); +u32 mtu;int i;int err;
@@ -498,13 +499,14 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->flows_cnt =1024 ; q->memory_limit =32 <<20 ;/* 32 MBytes */ q->drop_batch_size =64 ; - q->quantum =psched_mtu (qdisc_dev (sch)); + mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,FQ_CODEL_QUANTUM_MAX ); + q->quantum = mtu;INIT_LIST_HEAD (&q->new_flows);INIT_LIST_HEAD (&q->old_flows);codel_params_init (&q->cparams);codel_stats_init (&q->cstats); q->cparams.ecn = true; - q->cparams.mtu =psched_mtu (qdisc_dev (sch)); + q->cparams.mtu = mtu;if (opt) { err =fq_codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 895/935 net/sched: sch_codel: clamp default mtu to avoid disabling CoDel
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 6439461f1618ae176c048673ad28bdb6c68efbfc ]
codel_init() sets q->params.mtu = psched_mtu(qdisc_dev(sch)) without clamping. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000. In codel_should_drop() the test "*backlog <= params->mtu" then compares the backlog against ~2 GiB; with the default sch->limit of DEFAULT_CODEL_LIMIT (1000) packets the backlog can never reach it, so the test is always true and CoDel is silently and completely disabled i.e no drops, no ECN marking, codel degrades to a tail-drop FIFO. codel_change() never updates params.mtu, so the init path is the only place to clamp it. Constrain to [256, 1 << 20], matching the fq_codel bound; 256 is a sane floor that only makes CoDel slightly more willing to act on very small queues, which is the safe direction.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_codel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_codel.c +1 -1
@@ -231,7 +231,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,codel_params_init (&q->params);codel_vars_init (&q->vars);codel_stats_init (&q->stats); - q->params.mtu =psched_mtu (qdisc_dev (sch)); + q->params.mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,1 <<20 );if (opt) {int err =codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 896/935 net/sched: fq_pie: clamp default quantum to avoid signed overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit c86cd7ed0b0e44779a3d1683f03e4353baf4bdc9 ]
fq_pie_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) without clamping. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000, which overflows the signed flow->deficit to INT_MIN in fq_pie_qdisc_dequeue(), causing an infinite loop and soft lockup. Emulate fq_pie_policy which is already bounded to [1, 1 << 20]; clamp the default to [256, 1 << 20]. 256 matches fq_codel's floor and is a sane minimum for a DRR quantum.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_fq_pie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_fq_pie.c +2 -1
@@ -417,7 +417,8 @@ static int fq_pie_init(struct Qdisc *sch, struct nlattr *opt,pie_params_init (&q->p_params); sch->limit =10 *1024 ; q->p_params.limit = sch->limit; - q->quantum =psched_mtu (qdisc_dev (sch)); + q->quantum =clamp_t (u32,psched_mtu (qdisc_dev (sch)), +256 ,1 <<20 ); q->sch = sch; q->ecn_prob =10 ; q->flows_cnt =1024 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 897/935 net/sched: hhf: clamp quantum before hhf_change() to avoid overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 2164b512b97bb053e8ce4d6e95576f11bed6a005 ]
hhf_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) with no overflow check. A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes weight * quantum overflow the signed deficit in hhf_dequeue(), spinning forever.
Clamp q->quantum before hhf_change() so both the opt and !opt paths see a sane quantum. Without this, bare "tc qdisc add ... hhf" succeeds with a clamped quantum but "tc qdisc add ... hhf limit 1000" (any option present) fails with -EINVAL because hhf_change() re-validates the unclamped default (sch_hhf.c:559). 256 matches fq_codel's floor and is a sane minimum for a DRR quantum.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_hhf.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sched/sch_hhf.c +4 -0
@@ -620,6 +620,10 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, q->hhf_evict_timeout =HZ ;/* 1 sec */ q->hhf_non_hh_weight =2 ; +if ((int )q->quantum <=0 || + (u64 )q->quantum * q->hhf_non_hh_weight >INT_MAX ) + q->quantum =256 ; +if (opt) {int err =hhf_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 898/935 net/sched: sfq: clamp quantum to avoid signed overflow soft lockup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 816e90057ab1879562a5b7cc688e35bb9027ae97 ]
sfq_init() sets q->quantum = psched_mtu(qdisc_dev(sch)) (unsigned). A device with a huge MTU (e.g. dummy with max_mtu == 0 accepting MTU 2147483634) makes psched_mtu() return 0x80000000, so slot->allot = INT_MIN and INT_MIN + INT_MIN toggles between INT_MIN and 0 forever, spinning sfq_dequeue() under the qdisc lock.
Clamp the quantum to [256, 1 << 20] so the refill loop terminates. The lower bound also covers q->quantum == 0 (psched_mtu() returning 0), which spins sfq_dequeue() identically. sfq_change() already rejects a negative quantum, so only the init path was exposed.
Conditions to recreate the bug: a device whose MTU (plus hard_header_len) wraps psched_mtu() into the sign bit (e.g. a dummy device with max_mtu == 0 accepting MTU 2147483634). Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_sfq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_sfq.c +2 -1
@@ -793,7 +793,8 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt, q->tail =NULL ; q->divisor =SFQ_DEFAULT_HASH_DIVISOR ; q->maxflows =SFQ_DEFAULT_FLOWS ; - q->quantum =psched_mtu (qdisc_dev (sch)); + q->quantum =clamp_t (u32,psched_mtu (qdisc_dev (sch)), +256 ,1 <<20 ); q->perturb_period =0 ;get_random_bytes (&q->perturbation,sizeof (q->perturbation));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 899/935 net/sched: sch_teql: restore skb->dev on the slave failure path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit dc4b95b8fee95113587e93ca116356032d271371 ]
teql_master_xmit() sets skb->dev = slave before calling the slave's ndo_start_xmit(), but never restores it when that transmit fails. The skb then walks on to the next slave still pointing at the previous one.
If a later slave has no resolved neighbour, teql_resolve() hands the skb to neigh_event_send(), which queues it on that neighbour's arp_queue with the stale skb->dev. skb->dev holds no reference, so deleting the previous slave frees the net_device while the skb is still queued. Whatever runs next on that skb - arp_error_report() on timeout, or neigh_direct_output() -> dev_queue_xmit() once the neighbour resolves - causes a UAF like the one below:
BUG: KASAN: slab-use-after-free in __icmp_send (net/ipv4/icmp.c:914 (discriminator 2)) Read of size 4 at addr ffff888106e100b0 by task flood_packet/527 CPU: 0 UID: 0 PID: 527 Comm: flood_packet Not tainted 7.2.0-rc6-g594d90519502 #1 PREEMPT(lazy) Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <IRQ> dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) print_report (mm/kasan/report.c:378 mm/kasan/report.c:482) ? __pfx__raw_spin_lock_irqsave (./include/asm-generic/qrwlock.h:122 (discriminator 4)) ? __icmp_send (net/ipv4/icmp.c:914 (discriminator 2)) kasan_report (mm/kasan/report.c:595) ? __icmp_send (net/ipv4/icmp.c:914 (discriminator 2)) __icmp_send (net/ipv4/icmp.c:914 (discriminator 2))
[...]ipv4_link_failure (net/ipv4/route.c:1251 net/ipv4/route.c:1258)
? __pfx_ipv4_link_failure (./include/linux/skbuff.h:4327)
? _raw_write_lock (./include/linux/instrumented.h:55 ./include/linux/atomic/atomic-instrumented.h:1301 ./include/asm-generic/qrwlock.h:98 ./include/linux/rwlock_api_smp.h:230 kernel/locking/spinlock.c:304) ? __pfx__raw_write_lock (kernel/locking/spinlock.c:175)arp_error_report (./include/net/dst.h:438 net/ipv4/arp.c:296)neigh_invalidate (net/core/neighbour.c:1077)neigh_timer_handler (net/core/neighbour.c:1169)
[...]
Allocated by task 505: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) __kasan_kmalloc (mm/kasan/common.c:398 mm/kasan/common.c:415) __kvmalloc_node_noprof (./include/linux/kasan.h:263 mm/slub.c:5334 mm/slub.c:6905) alloc_netdev_mqs (net/core/dev.c:12055 (discriminator 2))
rtnl_create_link (net/core/rtnetlink.c:3721)rtnl_newlink (net/core/rtnetlink.c:3903 net/core/rtnetlink.c:4044 net/core/rtnetlink.c:4159) rtnetlink_rcv_msg (net/core/rtnetlink.c:7076)
[...]
Freed by task 536: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) kasan_save_free_info (mm/kasan/generic.c:584) __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285) kfree (./include/linux/kasan.h:235 mm/slub.c:2677 mm/slub.c:6377 mm/slub.c:6692)
device_release (drivers/base/core.c:2636)kobject_put (lib/kobject.c:689 lib/kobject.c:720 ./include/linux/kref.h:65 lib/kobject.c:737) netdev_run_todo (net/core/dev.c:11756)rtnl_dellink (net/core/rtnetlink.c:157 ./include/linux/rtnetlink.h:135 net/core/rtnetlink.c:3651) rtnetlink_rcv_msg (net/core/rtnetlink.c:7076)
[...]
Fix this by restoring skb->dev to the master at the end of each slave's iteration.
--- net/sched/sch_teql.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_teql.c +1 -0
@@ -338,6 +338,7 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) nores =1 ;break ; } + skb->dev = dev;__skb_pull (skb,skb_network_offset (skb)); }while ((q =NEXT_SLAVE (q)) != start);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 900/935 tpm: st33zp24: Return zero on status read failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 8b92687708f5ef980de01c2042dbd76d11f78547 ]
st33zp24_status() ignores the result of the transport read and returns data even when no byte was received. The I2C transport, for example, skips i2c_master_recv() when the register-select write is short or fails, leaving data uninitialized. The resulting stack value can be interpreted as TPM_STS flags and let status checks complete spuriously.
The status callback cannot propagate a transport error. Return zero unless recv() reports exactly one byte. With no status bits set, callers retry or take their existing timeout or error path instead of acting on an invalid status value.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/char/tpm/st33zp24/st33zp24.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/tpm/st33zp24/st33zp24.c +3 -1
@@ -98,7 +98,9 @@ static u8 st33zp24_status(struct tpm_chip *chip)struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data; - tpm_dev->ops->recv (tpm_dev->phy_id,TPM_STS , &data,1 ); +if (tpm_dev->ops->recv (tpm_dev->phy_id,TPM_STS , &data,1 ) !=1 ) +return 0 ; +return data; }/* st33zp24_status() */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 901/935 tpm: st33zp24: Validate locality read result
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 264216889d39df509b9c8045df53529480b0b718 ]
check_locality() treats every nonzero transport return as success. SPI errors remain negative, while the I2C path can convert a negative write error through its byte-sized status variable. Either result is nonzero even though the TPM_ACCESS byte can remain unwritten, so indeterminate ACTIVE_LOCALITY and VALID bits can falsely report an active locality.
Require recv() to return exactly the requested byte before examining TPM_ACCESS. Transport errors and short reads now report an inactive locality, while successful reads retain the existing behavior.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/char/tpm/st33zp24/st33zp24.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +2 -2
@@ -113,10 +113,10 @@ static bool check_locality(struct tpm_chip *chip) {struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data; -u8 status; +int status; status = tpm_dev->ops->recv (tpm_dev->phy_id,TPM_ACCESS , &data,1 ); -if (status && (data & +if (status ==1 && (data & (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID )) == (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID ))return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 902/935 apparmor: Replace sprintf/strcpy with scnprintf/strscpy in aa_policy_init
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit b31d3f7385fbb49681d44e7104cfa033cba4b1e8 ]
strcpy() is deprecated and sprintf() does not perform bounds checking either. Although an overflow is unlikely, it's better to proactively avoid it by using the safer strscpy() and scnprintf(), respectively.
Additionally, unify memory allocation for 'hname' to simplify and improve aa_policy_init().
Stable-dep-of: 3daad923a868 ("apparmor: policy_int make sure list heads are initialized before fail path")
--- security/apparmor/lib.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
security/apparmor/lib.c +7 -9
@@ -489,19 +489,17 @@ bool aa_policy_init(struct aa_policy *policy, const char *prefix, const char *name, gfp_t gfp) { char *hname; +size_t hname_sz; + hname_sz = (prefix ?strlen (prefix) +2 :0 ) +strlen (name) +1 ;/* freed by policy_free */ -if (prefix) { - hname =aa_str_alloc (strlen (prefix) +strlen (name) +3 , gfp); -if (hname) -sprintf (hname,"%s//%s" , prefix, name); - }else { - hname =aa_str_alloc (strlen (name) +1 , gfp); -if (hname) -strcpy (hname, name); - } + hname =aa_str_alloc (hname_sz, gfp);if (!hname)return false; +if (prefix) +scnprintf (hname, hname_sz,"%s//%s" , prefix, name); +else +strscpy (hname, name, hname_sz); policy->hname = hname;/* base.name is a substring of fqname */ policy->name =basename (policy->hname);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 903/935 apparmor: policy_int make sure list heads are initialized before fail path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 3daad923a8685adb66087e0d819559b7eb6ba975 ]
If profile create fails before policy_init is complete the list heads are not properly initialized causing profile_free() sanity checks to trigger the following splat.
AppArmor WARN aa_policy_destroy: (((!list_empty(&policy->profiles) && (&policy->profiles)->prev != ((void *) 0x122 + (0xdead000000000000UL))))):
WARNING: security/apparmor/lib.c:509 at aa_policy_destroy+0x164/0x1b0 security/apparmor/lib.c:509, CPU#0: syz.0.17/5541 Modules linked in: CPU: 0 UID: 0 PID: 5541 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:aa_policy_destroy+0x16b/0x1b0 security/apparmor/lib.c:509 Code: 85 ed 7e 4d e8 96 bc 37 fd 5b 41 5c 41 5e 41 5f 5d e9 19 27 4e 07 cc e8 83 bc 37 fd 48 8d 3d 0c f0 d3 0b 48 c7 c6 a4 eb 38 8e <67> 48 0f b9 3a e9 04 ff ff ff e8 66 bc 37 fd 48 8d 3d ff ef d3 0b RSP: 0018:ffffc9000345eaa0 EFLAGS: 00010293 RAX: ffffffff848f530d RBX: ffff88803f734800 RCX: ffff88801af2a580 RDX: 0000000000000000 RSI: ffffffff8e38eba4 RDI: ffffffff90634320 RBP: 0000000000000000 R08: 0000000000000cc0 R09: 00000000ffffffff R10: dffffc0000000000 R11: fffffbfff1d95913 R12: dead000000000122 R13: ffff88803f734800 R14: ffff88803f734828 R15: dffffc0000000000 FS: 00007f5f6a1836c0(0000) GS:ffff88808c519000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055d02407b048 CR3: 0000000012aa9000 CR4: 0000000000352ef0 Call Trace: <TASK> aa_free_profile+0x9d/0x9f0 security/apparmor/policy.c:334 aa_alloc_profile+0x1e4/0x3e0 security/apparmor/policy.c:416 unpack_profile security/apparmor/policy_unpack.c:1153 [inline] aa_unpack+0x17db/0x7430 security/apparmor/policy_unpack.c:1748 aa_replace_profiles+0x226/0x2a20 security/apparmor/policy.c:1183 policy_update+0x234/0x4a0 security/apparmor/apparmorfs.c:505 profile_load+0x1cb/0x320 security/apparmor/apparmorfs.c:522 vfs_write+0x296/0xba0 fs/read_write.c:685 ksys_write+0x150/0x270 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f5f6939e0d9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f5f6a183028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f5f69625fa0 RCX: 00007f5f6939e0d9 RDX: 0000000000000041 RSI: 0000200000000400 RDI: 0000000000000003 RBP: 00007f5f6a183090 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 00007f5f69626038 R14: 00007f5f69625fa0 R15: 00007ffe23725c18
--- security/apparmor/lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/lib.c +2 -2
@@ -491,6 +491,8 @@ bool aa_policy_init(struct aa_policy *policy, const char *prefix,char *hname;size_t hname_sz; +INIT_LIST_HEAD (&policy->list); +INIT_LIST_HEAD (&policy->profiles); hname_sz = (prefix ?strlen (prefix) +2 :0 ) +strlen (name) +1 ;/* freed by policy_free */ hname =aa_str_alloc (hname_sz, gfp);
@@ -503,8 +505,6 @@ bool aa_policy_init(struct aa_policy *policy, const char *prefix, policy->hname = hname;/* base.name is a substring of fqname */ policy->name =basename (policy->hname); -INIT_LIST_HEAD (&policy->list); -INIT_LIST_HEAD (&policy->profiles);return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 904/935 ASoC: dapm: Fix off-by-one check on the second enum channel
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 14511c9b54ceeeef487409d73947c89ee8563590 ]
The snd_soc_dapm_put_enum_double() rejects item[0] once it reaches e->items, but it lets item[1] be equal to it. Both go on to snd_soc_enum_item_to_val(), which indexes e->values with no bound of its own, so an enum with a value table reads one element past the end.
The indexing arrived with the MUX consolidation, which relaxed the item[1] check in the same hunk. The value MUX handler it deleted used
Quoted 1 line
= there, and the
snd_soc_put_enum_double()insoc-ops.cstill does.
Only adav80x pairs a value table with two shifts, and its second channel looks accidental, but the control does report two values. Writing three into it reads off the end of adav80x_mux_values. The core catches that only under CONFIG_SND_CTL_INPUT_VALIDATION, which defaults off.
--- sound/soc/soc-dapm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-dapm.c +1 -1
@@ -3517,7 +3517,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, val =snd_soc_enum_item_to_val (e, item[0 ]) << e->shift_l; mask = e->mask << e->shift_l;if (e->shift_l != e->shift_r) { -if (item[1 ] > e->items) +if (item[1 ] >= e->items)return -EINVAL ; val |=snd_soc_enum_item_to_val (e, item[1 ]) << e->shift_r; mask |= e->mask << e->shift_r;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 905/935 libceph: validate banner payload length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit f374967fcdf04001c9b66df1c19106fa83cd91f7 ]
When parsing the Ceph messenger v2 protocol banner, the payload_len field is decoded from the banner prefix. If a client sends a banner with a payload_len of 0, the kernel sets up a 0-length socket read. This violates an invariant in the state machine, triggering a warning in populate_in_iter():
------------[ cut here ]------------ !iov_iter_count(&con->v2.in_iter) WARNING: net/ceph/messenger_v2.c:3129 at populate_in_iter net/ceph/messenger_v2.c:3129 [inline], CPU#1: kworker/1:3/5070 WARNING: net/ceph/messenger_v2.c:3129 at ceph_con_v2_try_read+0x6634/0x6810 net/ceph/messenger_v2.c:3159, CPU#1: kworker/1:3/5070 ... Call Trace: <TASK> ceph_con_workfn+0x1f5/0x14a0 net/ceph/messenger.c:1575 process_one_work kernel/workqueue.c:3322 [inline] process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3486 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
According to the msgr2 protocol specification, the banner payload is expected to contain at least two 64-bit integers (server_feat and server_req_feat). Therefore, payload_len must be at least 16 bytes.
Fix this by adding a check in process_banner_prefix() to reject a payload_len smaller than 16 bytes. This prevents the 0-length read and correctly aborts the connection with a protocol error.
--- net/ceph/messenger_v2.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ceph/messenger_v2.c +5 -0
@@ -1835,6 +1835,11 @@ static int process_banner_prefix(struct ceph_connection *con) payload_len =ceph_decode_16 (&p);dout ("%s con %p payload_len %d\n" , __func__, con, payload_len); +if (payload_len <sizeof (u64) +sizeof (u64)) { + con->error_msg ="protocol error, bad banner payload len" ; +return -EINVAL ; + } +return prepare_read_banner_payload (con, payload_len); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 906/935 net: ethernet: sun4i-emac: Fix IRQ error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 991c2be78257cba5bf53cf935fe70f8836964288 ]
irq_of_parse_and_map() returns 0 when parsing or mapping an IRQ fails. The current code checks for -ENXIO and therefore does not detect the failure.
Check for a zero return value and convert it to -ENXIO.
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/allwinner/sun4i-emac.c +2 -2
@@ -818,9 +818,9 @@ static int emac_probe(struct platform_device *pdev)/* fill in parameters for net-dev structure */ ndev->base_addr = (unsigned long )db->membase; ndev->irq =irq_of_parse_and_map (np,0 ); -if (ndev->irq == -ENXIO ) { +if (!ndev->irq) {netdev_err (ndev,"No irq resource\n" ); - ret = ndev->irq; + ret = -ENXIO ; goto out_iounmap; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 907/935 net: stmmac: selftests: Pass the IP proto mask in the TC selftest
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 9a56a27e6002e29a6707dc4238d469ec84c3a68e ]
The stmmac TC filtering rules have recently gained sanity checks to make sure the passed keys and their respective masks are aligned with the HW filtering abilities.
The stmmac selftests failed to pass the mask in the match data for L4 filtering tests, and are now failing consistently with -EINVAL :
$ ethtool -t eth1 [...] 23. L4 DA TCP Filtering -22 24. L4 SA TCP Filtering -22 25. L4 DA UDP Filtering -22 26. L4 SA UDP Filtering -22
Let's pass the ip_proto mask in the l4 filtering tests match data. Found on imx8mp, which now have passing L4 tests :
$ ethtool -t eth1 [...] 23. L4 DA TCP Filtering 0 24. L4 SA TCP Filtering 0 25. L4 DA UDP Filtering 0 26. L4 SA UDP Filtering 0
While at it, initialize the masks and keys to avoid re-using whatever was on the stack.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +4 -2
@@ -1452,11 +1452,11 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src,struct {struct flow_dissector_key_basic bkey;struct flow_dissector_key_ports key; - }__aligned(BITS_PER_LONG / 8) keys; + }__aligned(BITS_PER_LONG / 8) keys = { };struct {struct flow_dissector_key_basic bmask;struct flow_dissector_key_ports mask; - }__aligned(BITS_PER_LONG / 8) masks; + }__aligned(BITS_PER_LONG / 8) masks = { };unsigned long dummy_cookie =0xdeadbeef ;struct stmmac_packet_attrs attr = { };struct flow_dissector *dissector;
@@ -1509,6 +1509,8 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src, keys.bkey.ip_proto = udp ?IPPROTO_UDP :IPPROTO_TCP ; keys.key.src =htons (src); keys.key.dst =htons (dst); +/* Match the full IP proto field */ + masks.bmask.ip_proto =0xff ; masks.mask.src = src_mask; masks.mask.dst = dst_mask;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 908/935 virtio-net: Ensure that TCP packets dont overflow gso_segs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Mikityanska <[email protected]>
[ Upstream commit c27c449d455aafd9018a3cbab150f1c42c87923f ]
The user can specify any gso_size in a packet crafted with an AF_PACKET PACKET_VNET_HDR socket, even smaller than TCP_MIN_GSO_SIZE = 8. At the same time, GSO_MAX_SIZE = 8 * GSO_MAX_SEGS = 8 * 65535. When the user crafts a packet with gso_size < 8, there is a risk for partial GSO to overflow the 16-bit gso_segs field when dividing the SKB length by gso_size.
Adjust gso_size of TCP packets to be at least TCP_MIN_GSO_SIZE = 8. Keep gso_size of UDP GSO packets, as gso_size=1 is valid and explicitly tested at tools/testing/selftests/net/tun.c:649.
--- include/linux/virtio_net.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/virtio_net.h +4 -0
@@ -4,6 +4,7 @@#include <linux/if_vlan.h> #include <linux/udp.h> +#include <net/tcp.h> #include <uapi/linux/tcp.h> #include <uapi/linux/virtio_net.h>
@@ -164,6 +165,9 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,if (skb->ip_summed ==CHECKSUM_PARTIAL && skb->csum_offset != offsetof(struct tcphdr , check))return -EINVAL ; + +BUILD_BUG_ON (TCP_MIN_GSO_SIZE *GSO_MAX_SEGS <GSO_MAX_SIZE ); + gso_size =max (gso_size,TCP_MIN_GSO_SIZE );break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 909/935 netfilter: nf_tables: move hardware offload step after building the chain blob
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b1881d362e1924b66f6016c3efd28807032b41bf ]
Allocate the chain blob before the ruleset offload to reduce chances of entering an inconsistent state where the offloaded ruleset in the nic and the software ruleset differ.
--- net/netfilter/nf_tables_api.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/netfilter/nf_tables_api.c +10 -4
@@ -9505,10 +9505,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)if (nf_tables_validate (net) <0 )return -EAGAIN ; - err =nft_flow_rule_offload_commit (net); -if (err <0 ) -return err; -/* 1. Allocate space for next generation rules_gen_X[] */ list_for_each_entry_safe (trans, next, &nft_net->commit_list, list) {int ret;
@@ -9532,6 +9528,16 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) } } +/* must be last, so audit and chain blob set up does not leave hardware +* in consistent state. +*/ + err =nft_flow_rule_offload_commit (net); +if (err <0 ) { +nf_tables_commit_chain_prepare_cancel (net); +nf_tables_commit_audit_free (&adl); +return err; + } +/* step 2. Make rules_gen_X visible to packet path */ list_for_each_entry (table, &nft_net->tables, list) {list_for_each_entry (chain, &table->chains, list)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 910/935 netfilter: xt_cgroup: Make it independent from net_cls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Koutný <[email protected]>
[ Upstream commit 3ba0032afea888d0edebf5ece3c6b36417189b63 ]
The xt_group matching supports the default hierarchy since commit c38c4597e4bf3 ("netfilter: implement xt_cgroup cgroup2 path match"). The cgroup v1 matching (based on clsid) and cgroup v2 matching (based on path) are rather independent. Downgrade the Kconfig dependency to mere CONFIG_SOCK_GROUP_DATA so that xt_group can be built even without CONFIG_NET_CLS_CGROUP for path matching.
Also add a message for users when they attempt to specify any clsid.
Stable-dep-of: 793d9eda4821 ("netfilter: x_tables: replace pr_{info,err}() by pr_info_ratelimited()")
--- net/netfilter/Kconfig | 2 +- net/netfilter/xt_cgroup.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
net/netfilter/Kconfig +1 -1
@@ -1174,7 +1174,7 @@ config NETFILTER_XT_MATCH_CGROUP tristate '"control group" match support' depends on NETFILTER_ADVANCED depends on CGROUPS - select CGROUP_NET_CLASSID + select SOCK_CGROUP_DATA help Socket/process control group matching allows you to match locally generated packets based on which net_cls control group processes
net/netfilter/xt_cgroup.c +17 -0
@@ -23,6 +23,8 @@ MODULE_DESCRIPTION("Xtables: process control group matching");MODULE_ALIAS ("ipt_cgroup" );MODULE_ALIAS ("ip6t_cgroup" ); +#define NET_CLS_CLASSID_INVALID_MSG "xt_cgroup: classid invalid without net_cls cgroups\n" +static int cgroup_mt_check_v0 (const struct xt_mtchk_param *par) {struct xt_cgroup_info_v0 *info = par->matchinfo;
@@ -30,6 +32,11 @@ static int cgroup_mt_check_v0(const struct xt_mtchk_param *par)if (info->invert & ~1 )return -EINVAL ; +if (!IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { +pr_info (NET_CLS_CLASSID_INVALID_MSG ); +return -EINVAL ; + } +return 0 ; }
@@ -51,6 +58,11 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par)return -EINVAL ; } +if (info->has_classid && !IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { +pr_info (NET_CLS_CLASSID_INVALID_MSG ); +return -EINVAL ; + } + info->priv =NULL ;if (info->has_path) {if (strnlen (info->path,sizeof (info->path)) >=sizeof (info->path))
@@ -86,6 +98,11 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par)return -EINVAL ; } +if (info->has_classid && !IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { +pr_info (NET_CLS_CLASSID_INVALID_MSG ); +return -EINVAL ; + } + info->priv =NULL ;if (info->has_path) {if (strnlen (info->path,sizeof (info->path)) >=sizeof (info->path))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 911/935 netfilter: xt_HL: add pr_fmt and checkentry validation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marino Dzalto <[email protected]>
[ Upstream commit 24bd5c2679caf8a228d90cafa221da4b47fd6642 ]
Add pr_fmt to prefix log messages with the module name for easier debugging in dmesg.
Add checkentry functions for IPv4 (ttl_mt_check) and IPv6 (hl_mt6_check) to validate the match mode at rule registration time, rejecting invalid modes with -EINVAL.
The evaluation function returns false in case the mode is unknown, so this is a cleanup, not a bug fix.
Stable-dep-of: 793d9eda4821 ("netfilter: x_tables: replace pr_{info,err}() by pr_info_ratelimited()")
--- net/netfilter/xt_hl.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/netfilter/xt_hl.c +27 -0
@@ -6,6 +6,7 @@* Hop Limit matching module * (C) 2001-2002 Maciej Soltysiak <[email protected]> */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/ip.h> #include <linux/ipv6.h>
@@ -22,6 +23,18 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("ipt_ttl" );MODULE_ALIAS ("ip6t_hl" ); +static int ttl_mt_check (const struct xt_mtchk_param *par) +{ +const struct ipt_ttl_info *info = par->matchinfo; + +if (info->mode >IPT_TTL_GT ) { +pr_err ("Unknown TTL match mode: %d\n" , info->mode); +return -EINVAL ; + } + +return 0 ; +} +static bool ttl_mt (const struct sk_buff *skb,struct xt_action_param *par) {const struct ipt_ttl_info *info = par->matchinfo;
@@ -41,6 +54,18 @@ static bool ttl_mt(const struct sk_buff *skb, struct xt_action_param *par)return false; } +static int hl_mt6_check (const struct xt_mtchk_param *par) +{ +const struct ip6t_hl_info *info = par->matchinfo; + +if (info->mode >IP6T_HL_GT ) { +pr_err ("Unknown Hop Limit match mode: %d\n" , info->mode); +return -EINVAL ; + } + +return 0 ; +} +static bool hl_mt6 (const struct sk_buff *skb,struct xt_action_param *par) {const struct ip6t_hl_info *info = par->matchinfo;
@@ -65,6 +90,7 @@ static struct xt_match hl_mt_reg[] __read_mostly = { .name = "ttl", .revision = 0, .family = NFPROTO_IPV4, + .checkentry = ttl_mt_check, .match = ttl_mt, .matchsize = sizeof(struct ipt_ttl_info), .me = THIS_MODULE,
@@ -73,6 +99,7 @@ static struct xt_match hl_mt_reg[] __read_mostly = { .name = "hl", .revision = 0, .family = NFPROTO_IPV6, + .checkentry = hl_mt6_check, .match = hl_mt6, .matchsize = sizeof(struct ip6t_hl_info), .me = THIS_MODULE,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 912/935 netfilter: x_tables: replace pr_{info,err}() by pr_info_ratelimited()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 793d9eda4821f75b5f7cc9e6a870b72a58b44c2b ]
Several xtables extension still use pr_err() or pr_info() without ratelimit.
For xt_cgroup, while at this, remove redundant "xt_cgroup:" prefix since pr_fmt is already set on.
--- net/netfilter/xt_cgroup.c | 12 ++++++------ net/netfilter/xt_hl.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
net/netfilter/xt_cgroup.c +6 -6
@@ -23,7 +23,7 @@ MODULE_DESCRIPTION("Xtables: process control group matching");MODULE_ALIAS ("ipt_cgroup" );MODULE_ALIAS ("ip6t_cgroup" ); -#define NET_CLS_CLASSID_INVALID_MSG "xt_cgroup: classid invalid without net_cls cgroups\n" +#define NET_CLS_CLASSID_INVALID_MSG "classid invalid without net_cls cgroups\n"static int cgroup_mt_check_v0 (const struct xt_mtchk_param *par) {
@@ -33,7 +33,7 @@ static int cgroup_mt_check_v0(const struct xt_mtchk_param *par)return -EINVAL ;if (!IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { -pr_info (NET_CLS_CLASSID_INVALID_MSG ); +pr_info_ratelimited (NET_CLS_CLASSID_INVALID_MSG );return -EINVAL ; }
@@ -49,7 +49,7 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par)return -EINVAL ;if (!info->has_path && !info->has_classid) { -pr_info ("xt_cgroup: no path or classid specified\n" ); +pr_info_ratelimited ("no path or classid specified\n" );return -EINVAL ; }
@@ -59,7 +59,7 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par) }if (info->has_classid && !IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { -pr_info (NET_CLS_CLASSID_INVALID_MSG ); +pr_info_ratelimited (NET_CLS_CLASSID_INVALID_MSG );return -EINVAL ; }
@@ -89,7 +89,7 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par)return -EINVAL ;if (!info->has_path && !info->has_classid) { -pr_info ("xt_cgroup: no path or classid specified\n" ); +pr_info_ratelimited ("no path or classid specified\n" );return -EINVAL ; }
@@ -99,7 +99,7 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par) }if (info->has_classid && !IS_ENABLED (CONFIG_CGROUP_NET_CLASSID )) { -pr_info (NET_CLS_CLASSID_INVALID_MSG ); +pr_info_ratelimited (NET_CLS_CLASSID_INVALID_MSG );return -EINVAL ; }
net/netfilter/xt_hl.c +2 -2
@@ -28,7 +28,7 @@ static int ttl_mt_check(const struct xt_mtchk_param *par)const struct ipt_ttl_info *info = par->matchinfo;if (info->mode >IPT_TTL_GT ) { -pr_err ("Unknown TTL match mode: %d\n" , info->mode); +pr_info_ratelimited ("Unknown TTL match mode: %d\n" , info->mode);return -EINVAL ; }
@@ -59,7 +59,7 @@ static int hl_mt6_check(const struct xt_mtchk_param *par)const struct ip6t_hl_info *info = par->matchinfo;if (info->mode >IP6T_HL_GT ) { -pr_err ("Unknown Hop Limit match mode: %d\n" , info->mode); +pr_info_ratelimited ("Unknown Hop Limit match mode: %d\n" , info->mode);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 913/935 selftests: arm64: add hugetlb mte tests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
[ Upstream commit 27879e8cb6b0fdb5cdcd76685f290729309711c6 ]
The tests cover mmap, mprotect hugetlb with MTE prot and COW.
Stable-dep-of: 8d2237e9d690 ("selftests/arm64: Print missing MTE TAP headers")
--- .../arm64/mte/check_hugetlb_options.c | 285 ++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 tools/testing/selftests/arm64/mte/check_hugetlb_options.c
tools/testing/selftests/arm64/mte/check_hugetlb_options.c new file +285 -0
@@ -0,0 +1,285 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2024 Ampere Computing LLC + +#define _GNU_SOURCE + +#include <errno.h> +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ucontext.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/wait.h> + +#include "kselftest.h" +#include "mte_common_util.h" +#include "mte_def.h" + +#define TAG_CHECK_ON 0 +#define TAG_CHECK_OFF 1 + +static unsigned long default_huge_page_size (void ) +{ +unsigned long hps =0 ; +char *line =NULL ; +size_t linelen =0 ; +FILE *f =fopen ("/proc/meminfo" ,"r" ); + +if (!f) +return 0 ; +while (getline (&line, &linelen, f) >0 ) { +if (sscanf (line,"Hugepagesize: %lu kB" , &hps) ==1 ) { + hps <<=10 ; +break ; + } + } + +free (line); +fclose (f); +return hps; +} + +static bool is_hugetlb_allocated (void ) +{ +unsigned long hps =0 ; +char *line =NULL ; +size_t linelen =0 ; +FILE *f =fopen ("/proc/meminfo" ,"r" ); + +if (!f) +return false; +while (getline (&line, &linelen, f) >0 ) { +if (sscanf (line,"Hugetlb: %lu kB" , &hps) ==1 ) { + hps <<=10 ; +break ; + } + } + +free (line); +fclose (f); + +if (hps >0 ) +return true; + +return false; +} + +static void write_sysfs (char *str,unsigned long val) +{ +FILE *f; + + f =fopen (str,"w" ); +if (!f) { +ksft_print_msg ("ERR: missing %s\n" , str); +return ; + } +fprintf (f,"%lu" , val); +fclose (f); +} + +static void allocate_hugetlb () +{ +write_sysfs ("/proc/sys/vm/nr_hugepages" ,2 ); +} + +static void free_hugetlb () +{ +write_sysfs ("/proc/sys/vm/nr_hugepages" ,0 ); +} + +static int check_child_tag_inheritance (char *ptr,int size,int mode) +{ +int i, parent_tag, child_tag, fault, child_status; +pid_t child; + + parent_tag =MT_FETCH_TAG ((uintptr_t )ptr); + fault =0 ; + + child =fork (); +if (child ==-1 ) { +ksft_print_msg ("FAIL: child process creation\n" ); +return KSFT_FAIL ; + }else if (child ==0 ) { +mte_initialize_current_context (mode, (uintptr_t )ptr, size); +/* Do copy on write */ +memset (ptr,'1' , size); +mte_wait_after_trig (); +if (cur_mte_cxt.fault_valid == true) { + fault =1 ; + goto check_child_tag_inheritance_err; + } +for (i =0 ; i < size; i +=MT_GRANULE_SIZE ) { + child_tag =MT_FETCH_TAG ((uintptr_t )(mte_get_tag_address (ptr + i))); +if (parent_tag != child_tag) { +ksft_print_msg ("FAIL: child mte tag (%d) mismatch\n" , i); + fault =1 ; + goto check_child_tag_inheritance_err; + } + } +check_child_tag_inheritance_err: +_exit (fault); + } +/* Wait for child process to terminate */ +wait (&child_status); +if (WIFEXITED (child_status)) + fault =WEXITSTATUS (child_status); +else + fault =1 ; +return (fault) ?KSFT_FAIL :KSFT_PASS ; +} + +static int check_mte_memory (char *ptr,int size,int mode,int tag_check) +{ +mte_initialize_current_context (mode, (uintptr_t )ptr, size); +memset (ptr,'1' , size); +mte_wait_after_trig (); +if (cur_mte_cxt.fault_valid == true) +return KSFT_FAIL ; + +return KSFT_PASS ; +} + +static int check_hugetlb_memory_mapping (int mem_type,int mode,int mapping,int tag_check) +{ +char *ptr, *map_ptr; +int result; +unsigned long map_size; + + map_size =default_huge_page_size (); + +mte_switch_mode (mode,MTE_ALLOW_NON_ZERO_TAG ); + map_ptr = (char *)mte_allocate_memory (map_size, mem_type, mapping, false); +if (check_allocated_memory (map_ptr, map_size, mem_type, false) !=KSFT_PASS ) +return KSFT_FAIL ; + +mte_initialize_current_context (mode, (uintptr_t )map_ptr, map_size); +/* Only mte enabled memory will allow tag insertion */ + ptr =mte_insert_tags ((void *)map_ptr, map_size); +if (!ptr || cur_mte_cxt.fault_valid == true) { +ksft_print_msg ("FAIL: Insert tags on anonymous mmap memory\n" ); +munmap ((void *)map_ptr, map_size); +return KSFT_FAIL ; + } + result =check_mte_memory (ptr, map_size, mode, tag_check); +mte_clear_tags ((void *)ptr, map_size); +mte_free_memory ((void *)map_ptr, map_size, mem_type, false); +if (result ==KSFT_FAIL ) +return KSFT_FAIL ; + +return KSFT_PASS ; +} + +static int check_clear_prot_mte_flag (int mem_type,int mode,int mapping) +{ +char *map_ptr; +int prot_flag, result; +unsigned long map_size; + + prot_flag =PROT_READ |PROT_WRITE ; +mte_switch_mode (mode,MTE_ALLOW_NON_ZERO_TAG ); + map_size =default_huge_page_size (); + map_ptr = (char *)mte_allocate_memory_tag_range (map_size, mem_type, mapping, +0 ,0 ); +if (check_allocated_memory_range (map_ptr, map_size, mem_type, +0 ,0 ) !=KSFT_PASS ) +return KSFT_FAIL ; +/* Try to clear PROT_MTE property and verify it by tag checking */ +if (mprotect (map_ptr, map_size, prot_flag)) { +mte_free_memory_tag_range ((void *)map_ptr, map_size, mem_type, +0 ,0 ); +ksft_print_msg ("FAIL: mprotect not ignoring clear PROT_MTE property\n" ); +return KSFT_FAIL ; + } + result =check_mte_memory (map_ptr, map_size, mode,TAG_CHECK_ON ); +mte_free_memory_tag_range ((void *)map_ptr, map_size, mem_type,0 ,0 ); +if (result !=KSFT_PASS ) +return KSFT_FAIL ; + +return KSFT_PASS ; +} + +static int check_child_hugetlb_memory_mapping (int mem_type,int mode,int mapping) +{ +char *ptr; +int result; +unsigned long map_size; + + map_size =default_huge_page_size (); + +mte_switch_mode (mode,MTE_ALLOW_NON_ZERO_TAG ); + ptr = (char *)mte_allocate_memory_tag_range (map_size, mem_type, mapping, +0 ,0 ); +if (check_allocated_memory_range (ptr, map_size, mem_type, +0 ,0 ) !=KSFT_PASS ) +return KSFT_FAIL ; + result =check_child_tag_inheritance (ptr, map_size, mode); +mte_free_memory_tag_range ((void *)ptr, map_size, mem_type,0 ,0 ); +if (result ==KSFT_FAIL ) +return result; + +return KSFT_PASS ; +} + +int main (int argc,char *argv[]) +{ +int err; + + err =mte_default_setup (); +if (err) +return err; + +/* Register signal handlers */ +mte_register_signal (SIGBUS , mte_default_handler); +mte_register_signal (SIGSEGV , mte_default_handler); + +allocate_hugetlb (); + +if (!is_hugetlb_allocated ()) { +ksft_print_msg ("ERR: Unable allocate hugetlb pages\n" ); +return KSFT_FAIL ; + } + +/* Set test plan */ +ksft_set_plan (12 ); + +mte_enable_pstate_tco (); + +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_OFF ), +"Check hugetlb memory with private mapping, sync error mode, mmap memory and tag check off\n" ); + +mte_disable_pstate_tco (); +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_NONE_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_OFF ), +"Check hugetlb memory with private mapping, no error mode, mmap memory and tag check off\n" ); + +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, sync error mode, mmap memory and tag check on\n" ); +evaluate_test (check_hugetlb_memory_mapping (USE_MPROTECT ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, sync error mode, mmap/mprotect memory and tag check on\n" ); +evaluate_test (check_hugetlb_memory_mapping (USE_MMAP ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, async error mode, mmap memory and tag check on\n" ); +evaluate_test (check_hugetlb_memory_mapping (USE_MPROTECT ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ,TAG_CHECK_ON ), +"Check hugetlb memory with private mapping, async error mode, mmap/mprotect memory and tag check on\n" ); + +evaluate_test (check_clear_prot_mte_flag (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check clear PROT_MTE flags with private mapping, sync error mode and mmap memory\n" ); +evaluate_test (check_clear_prot_mte_flag (USE_MPROTECT ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check clear PROT_MTE flags with private mapping and sync error mode and mmap/mprotect memory\n" ); + +evaluate_test (check_child_hugetlb_memory_mapping (USE_MMAP ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap memory\n" ); +evaluate_test (check_child_hugetlb_memory_mapping (USE_MMAP ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap memory\n" ); +evaluate_test (check_child_hugetlb_memory_mapping (USE_MPROTECT ,MTE_SYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n" ); +evaluate_test (check_child_hugetlb_memory_mapping (USE_MPROTECT ,MTE_ASYNC_ERR ,MAP_PRIVATE |MAP_HUGETLB ), +"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n" ); + +mte_restore_setup (); +free_hugetlb (); +ksft_print_cnts (); +return ksft_get_fail_cnt () ==0 ?KSFT_PASS :KSFT_FAIL ; +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 914/935 selftests/arm64: Print missing MTE TAP headers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 8d2237e9d6902e234bb89aabb9cd6a9e91357223 ]
Most MTE tests set a TAP plan and emit results without first printing the TAP version header. Direct execution therefore starts with a plan such as "1..20" instead of "TAP version 13".
The problem is particularly visible in the GCR_EL1 context-switch test. It prints its plan before forking 1,024 child processes. When stdout is fully buffered, the plan remains in the stdio buffer. Each child inherits the pending "1..1" line and flushes its copy from exit(), producing repeated plan lines.
ksft_print_header() prints the TAP header and enables line buffering. Call it in every MTE test that is missing it. In the GCR_EL1 test, call it before the plan so the plan is flushed before the children are forked. In the remaining tests, call it before setup and prerequisite checks so early failures and whole-test skips also retain the header.
--- tools/testing/selftests/arm64/mte/check_buffer_fill.c | 2 ++ tools/testing/selftests/arm64/mte/check_child_memory.c | 2 ++ tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c | 1 + tools/testing/selftests/arm64/mte/check_hugetlb_options.c | 2 ++ tools/testing/selftests/arm64/mte/check_ksm_options.c | 2 ++ tools/testing/selftests/arm64/mte/check_mmap_options.c | 2 ++ tools/testing/selftests/arm64/mte/check_tags_inclusion.c | 2 ++ tools/testing/selftests/arm64/mte/check_user_mem.c | 2 ++ 8 files changed, 15 insertions(+)
tools/testing/selftests/arm64/mte/check_buffer_fill.c +2 -0
@@ -406,6 +406,8 @@ int main(int argc, char *argv[])size_t page_size =getpagesize ();int item =sizeof (sizes)/sizeof (int ); +ksft_print_header (); + sizes[item -3 ] = page_size -1 ; sizes[item -2 ] = page_size; sizes[item -1 ] = page_size +1 ;
tools/testing/selftests/arm64/mte/check_child_memory.c +2 -0
@@ -146,6 +146,8 @@ int main(int argc, char *argv[])int err;int item =sizeof (sizes)/sizeof (int ); +ksft_print_header (); + page_size =getpagesize ();if (!page_size) {ksft_print_msg ("ERR: Unable to get page size\n" );
tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c +1 -0
@@ -142,6 +142,7 @@ int main(int argc, char *argv[])if (err)return err; +ksft_print_header ();ksft_set_plan (1 ); evaluate_test(mte_gcr_fork_test(),
tools/testing/selftests/arm64/mte/check_hugetlb_options.c +2 -0
@@ -228,6 +228,8 @@ int main(int argc, char *argv[]) {int err; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_ksm_options.c +2 -0
@@ -132,6 +132,8 @@ int main(int argc, char *argv[]) {int err; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_mmap_options.c +2 -0
@@ -189,6 +189,8 @@ int main(int argc, char *argv[])int err;int item =sizeof (sizes)/sizeof (int ); +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_tags_inclusion.c +2 -0
@@ -163,6 +163,8 @@ int main(int argc, char *argv[]) {int err; +ksft_print_header (); + err =mte_default_setup ();if (err)return err;
tools/testing/selftests/arm64/mte/check_user_mem.c +2 -0
@@ -85,6 +85,8 @@ int main(int argc, char *argv[]) {int err; +ksft_print_header (); + page_sz =getpagesize ();if (!page_sz) {ksft_print_msg ("ERR: Unable to get page size\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 915/935 selftests/arm64: Treat KSM merge_across_nodes as optional
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 1a0dba077f34a2f8faa98308d30d4b546d073145 ]
The MTE KSM test requires write access to KSM sysfs but does not check that it is running as root. It also unconditionally saves, enables and restores the merge_across_nodes attribute. The kernel only creates this attribute when CONFIG_NUMA=y, so a non-NUMA kernel prints the following message three times even though every KSM subtest passes:
# ERR: missing /sys/kernel/mm/ksm/merge_across_nodes
Skip the test when it is not running as root. Check that the optional attribute is readable and writable, treating ENOENT as its expected absence on non-NUMA kernels and skipping the test for other access failures. Only save, enable and restore the attribute when it is available.
Check MTE availability before the privilege and sysfs checks so systems without MTE retain the existing feature-unavailable skip result.
This preserves the existing behavior on NUMA kernels without requiring NUMA or reducing KSM coverage on single-node systems.
--- .../selftests/arm64/mte/check_ksm_options.c | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-)
tools/testing/selftests/arm64/mte/check_ksm_options.c +26 -3
@@ -6,6 +6,7 @@#include <errno.h> #include <fcntl.h> #include <signal.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
@@ -22,6 +23,20 @@static size_t page_sz;static unsigned long ksm_sysfs[5 ]; +static bool has_merge_across_nodes; + +static bool merge_across_nodes_available (void ) +{ +const char *path =PATH_KSM "merge_across_nodes" ; + +if (!access (path,R_OK |W_OK )) +return true; +if (errno ==ENOENT ) +return false; + +ksft_exit_skip ("Unable to read and write %s: %s\n" , path, +strerror (errno)); +}static unsigned long read_sysfs (char *str) {
@@ -56,8 +71,10 @@ static void write_sysfs(char *str, unsigned long val)static void mte_ksm_setup (void ) { - ksm_sysfs[0 ] =read_sysfs (PATH_KSM "merge_across_nodes" ); -write_sysfs (PATH_KSM "merge_across_nodes" ,1 ); +if (has_merge_across_nodes) { + ksm_sysfs[0 ] =read_sysfs (PATH_KSM "merge_across_nodes" ); +write_sysfs (PATH_KSM "merge_across_nodes" ,1 ); + } ksm_sysfs[1 ] =read_sysfs (PATH_KSM "sleep_millisecs" );write_sysfs (PATH_KSM "sleep_millisecs" ,0 ); ksm_sysfs[2 ] =read_sysfs (PATH_KSM "run" );
@@ -70,7 +87,8 @@ static void mte_ksm_setup(void)static void mte_ksm_restore (void ) { -write_sysfs (PATH_KSM "merge_across_nodes" , ksm_sysfs[0 ]); +if (has_merge_across_nodes) +write_sysfs (PATH_KSM "merge_across_nodes" , ksm_sysfs[0 ]);write_sysfs (PATH_KSM "sleep_millisecs" , ksm_sysfs[1 ]);write_sysfs (PATH_KSM "run" , ksm_sysfs[2 ]);write_sysfs (PATH_KSM "max_page_sharing" , ksm_sysfs[3 ]);
@@ -137,6 +155,11 @@ int main(int argc, char *argv[]) err =mte_default_setup ();if (err)return err; + +if (geteuid () !=0 ) +ksft_exit_skip ("Please run the test as root\n" ); + + has_merge_across_nodes =merge_across_nodes_available (); page_sz =getpagesize ();if (!page_sz) {ksft_print_msg ("ERR: Unable to get page size\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 916/935 net: stmmac: selftests: Check multiple MMC counters
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit d29b399150b07796dfa81d8778d4804c08c2a41d ]
The MMC counters report MAC statistics. Multiple counters can be enabled when the IP is integrated, however there's no way to know exactly which ones. Un-implemented counters seem to report 0.
It was found that on StarFive JH7110 and Amlogic SM1, the counter that's used by the selftest (mmc_tx_framecount_g) isn't implemented, triggering an MMC selftest failure.
Both the above SoCs seem to implement mmc_rx_framecount_gb, let's use this counter as well for MMC counter validation.
Note that this doesn't guarantee that we won't encounter the same issue again if another IP implements yet another set of counters that don't include that new one.
If the game of whack-a-mole with implemented counters becomes too hard to maintain, we may simply consider removing the MMC selftest entirely.
--- .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +10 -4
@@ -415,11 +415,17 @@ static int stmmac_test_mmc(struct stmmac_priv *priv)stmmac_mmc_read (priv, priv->mmcaddr, &final);/* -* The number of MMC counters available depends on HW configuration -* so we just use this one to validate the feature. I hope there is -* not a version without this counter. +* The number of MMC counters available depends on HW configuration, +* and there doesn't seem to be a way to enumerate the implemented +* counters. +* +* Let's check a hand-picked set of counters, knowing that : +* - Starfive JH7110 doesn't implement mmc_tx_framecount_g +* - Amlogic SM1 doesn't implement any mmc_tx_* +* */ -if (final.mmc_tx_framecount_g <= initial.mmc_tx_framecount_g) +if (final.mmc_tx_framecount_g <= initial.mmc_tx_framecount_g && + final.mmc_rx_framecount_gb <= initial.mmc_rx_framecount_gb)return -EINVAL ;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 917/935 net: stmmac: dwmac1000: Account for the primary MAC address for UC filtering
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 9698b6da3714fd2ef47846cb63098d2b2d252e25 ]
The same filter slots are used to store the main MAC address as well as the address for the unicast filter. Let's account for that when deciding whether or not to use promisc when programming the UC list in hardware.
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -1
@@ -185,7 +185,7 @@ static void dwmac1000_set_filter(struct mac_device_info *hw,dwmac1000_set_mchash (ioaddr, mc_filter, mcbitslog2);/* Handle multiple unicast addresses (perfect filtering) */ -if (netdev_uc_count (dev) > perfect_addr_number) +if (netdev_uc_count (dev) +1 > perfect_addr_number)/* Switch to promiscuous mode if more than unicast * addresses are requested than supported by hardware. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 918/935 net: stmmac: dwmac4: Account for the primary MAC address for UC filtering
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 82187f42c014d22520b9c3c4e2cfb519223fb29b ]
The same filter slots are used to store the main MAC address as well as the address for the unicast filter. Let's account for that when deciding whether or not to use promisc when programming the UC list in hardware.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +1 -1
@@ -678,7 +678,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw, value |=GMAC_PACKET_FILTER_HPF ;/* Handle multiple unicast addresses */ -if (netdev_uc_count (dev) > hw->unicast_filter_entries) { +if (netdev_uc_count (dev) +1 > hw->unicast_filter_entries) {/* Switch to promiscuous mode if more than 128 addrs * are required */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 919/935 net: stmmac: dwxgmac: Account for the primary MAC address for UC filtering
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 2739d6f9a2b8729b0d85cbe0dc93e1d68670b6f2 ]
The same filter slots are used to store the main MAC address as well as the address for the unicast filter. Let's account for that when deciding whether or not to use promisc when programming the UC list in hardware.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +1 -1
@@ -499,7 +499,7 @@ static void dwxgmac2_set_filter(struct mac_device_info *hw,dwxgmac2_set_mchash (ioaddr, mc_filter, mcbitslog2);/* Handle multiple unicast addresses */ -if (netdev_uc_count (dev) > hw->unicast_filter_entries) { +if (netdev_uc_count (dev) +1 > hw->unicast_filter_entries) { value |=XGMAC_FILTER_PR ; }else {struct netdev_hw_addr *ha;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 920/935 net: stmmac: selftests: Account for the UC filter list for filtering tests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit cd8c3b2752c684141eab2282e294cae2971a9759 ]
On dwmac, one of the Unicast filter entries is used to store the local HW addr. This means that we have to use promisc mode for any kind of unicast filtering if we only have one slot in our unicast filter.
The number of slots available depends on how the IP is integrated, and we can't autodiscover how many of these slots we have available, so the DT property snps,perfect-filter-entries can be used to specify how many are available.
Most IP variants default to 1 if this isn't specified, which is the case for the amlogic variants (in this case, S905X3).
The stmmac selftests for UC filtering look if we have enough slots in the filter to store the dev->uc list, but doesn't account for the device's own MAC address. The dev->uc list's size we get with netdev_uc_count() also doesn't account for the HW addr.
As the selftest only requires one available slot, in the case of single-slot platforms, that means we erroneously consider we have enough room for the test, when we actually don't, and the filtering test fails.
--- .../stmicro/stmmac/stmmac_selftests.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +18 -3
@@ -499,6 +499,21 @@ static int stmmac_filter_check(struct stmmac_priv *priv)return -EOPNOTSUPP ; } +static int stmmac_uc_filter_check (struct stmmac_priv *priv) +{ +/* For tests involving the UC filter, we need at least one empty +* slot in the UC filter. The UC filters contains netdev_uc_count() + 1 +* entries: The dev->uc list + one entry for the HW address. +* +* Having an empty slot therefore means netdev_uc_count() + 2 entries +* can fit in the filter +*/ +if (netdev_uc_count (priv->dev) +2 > priv->hw->unicast_filter_entries) +return -EOPNOTSUPP ; + +return 0 ; +} +static bool stmmac_hash_check (struct stmmac_priv *priv,unsigned char *addr) {int mc_offset =32 - priv->hw->mcast_bits_log2;
@@ -590,7 +605,7 @@ static int stmmac_test_pfilt(struct stmmac_priv *priv)if (stmmac_filter_check (priv))return -EOPNOTSUPP ; -if (netdev_uc_count (priv->dev) >= priv->hw->unicast_filter_entries) +if (stmmac_uc_filter_check (priv))return -EOPNOTSUPP ;while (--tries) {
@@ -634,7 +649,7 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv)if (stmmac_filter_check (priv))return -EOPNOTSUPP ; -if (netdev_uc_count (priv->dev) >= priv->hw->unicast_filter_entries) +if (stmmac_uc_filter_check (priv))return -EOPNOTSUPP ;if (netdev_mc_count (priv->dev) >= priv->hw->multicast_filter_bins)return -EOPNOTSUPP ;
@@ -680,7 +695,7 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv)if (stmmac_filter_check (priv))return -EOPNOTSUPP ; -if (netdev_uc_count (priv->dev) >= priv->hw->unicast_filter_entries) +if (stmmac_uc_filter_check (priv))return -EOPNOTSUPP ;if (netdev_mc_count (priv->dev) >= priv->hw->multicast_filter_bins)return -EOPNOTSUPP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 921/935 net/sched: bound qdisc_pkt_len to prevent qdisc soft lockup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 8f735d64382dcf162f4276d6699d03ad2f859c0b ]
qdisc_get_stab() accepts a user-supplied size table, and __qdisc_calculate_pkt_len() amplifies qdisc_pkt_len() through the overhead, the size-table data (u16), and size_log (up to STAB_SIZE_LOG_MAX). A crafted stab can therefore set qdisc_pkt_len() to ~1 GiB for an ordinary skb. Per-flow deficit schedulers such as DRR and ETS replenish one quantum per loop iteration; with a tiny quantum (1) they spin billions of times under the qdisc lock, producing a soft lockup / RCU stall as illustrated by [email protected].
Cap the final qdisc_pkt_len() to QDISC_PKT_LEN_MAX so the size-table amplification cannot drive deficit schedulers into an unbounded loop. A legitimate size table (e.g. qfq's overhead 999999999, which is handled by dropping) is still accepted.
Introduce cap QDISC_PKT_LEN_MAX (1 << 20) = 1 MiB which is well above any legitimate single-skb wire length: the largest current skb->len is GSO_MAX_SIZE (524280), and an ATM-style size table (53/48 cell tax) amplifies that to ~578 KB, both comfortably below 1 MiB. At the same time, 1 MiB bounds the deficit refill loop to ~1M iterations per packet with quantum=1, which completes in a few milliseconds well under the demonstrated softlockup threshold (~10^9 iterations).
Conditions to recreate the bug:
- CONFIG_NET_SCHED=y, CONFIG_NET_SCH_DRR=y (or CONFIG_NET_SCH_ETS=y).
- Attach a DRR (or ETS) root qdisc with a crafted TCA_STAB that amplifies qdisc_pkt_len to ~1 GiB (e.g. size_log=15, data=[32768]).
- Add a class with a tiny quantum of 1 and send one small packet; the deficit loop spins billions of times under the qdisc lock and trips the softlockup detector (panic with kernel.softlockup_panic=1).
- Reachable as root or from an unprivileged user in a fresh user+net namespace (unshare -Urn) with namespace-local CAP_NET_ADMIN.
--- include/net/pkt_sched.h | 1 + net/sched/sch_api.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/net/pkt_sched.h +1 -0
@@ -12,6 +12,7 @@#define DEFAULT_TX_QUEUE_LEN 1000#define STAB_SIZE_LOG_MAX 30 +#define QDISC_PKT_LEN_MAX (1 << 20)/* 1 MiB */ struct qdisc_walker {int stop;
net/sched/sch_api.c +5 -2
@@ -604,8 +604,11 @@ void __qdisc_calculate_pkt_len(struct sk_buff *skb, pkt_len <<= stab->szopts.size_log; out: -if (unlikely (pkt_len <1 )) - pkt_len =1 ; +/* A size table can inflate qdisc_pkt_len() beyond any real packet +* (via overhead, the data table, or size_log); cap it so deficit +* schedulers such as DRR/ETS terminate their refill loops. +*/ + pkt_len =clamp_t (int, pkt_len,1 ,QDISC_PKT_LEN_MAX );qdisc_skb_cb (skb)->pkt_len = pkt_len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 922/935 net: fec: only stop PTP if it was initialized
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit dd890ae29299636fb037276fc1b5238698d08b03 ]
fec_ptp_init() is only called when fep->bufdesc_ex is available. However, fec_probe() unconditionally calls fec_ptp_stop() on the failed_init path, and fec_drv_remove() unconditionally calls fec_ptp_stop() during device removal.
Check fep->bufdesc_ex before calling fec_ptp_stop() in both paths to avoid stopping PTP when it was not initialized.
--- drivers/net/ethernet/freescale/fec_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +4 -2
@@ -4088,7 +4088,8 @@ fec_probe(struct platform_device *pdev) failed_irq:fec_enet_deinit (ndev); failed_init: -fec_ptp_stop (pdev); +if (fep->bufdesc_ex) +fec_ptp_stop (pdev); failed_reset:pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);
@@ -4129,7 +4130,8 @@ fec_drv_remove(struct platform_device *pdev) ERR_PTR(ret));cancel_work_sync (&fep->tx_timeout_work); -fec_ptp_stop (pdev); +if (fep->bufdesc_ex) +fec_ptp_stop (pdev);unregister_netdev (ndev);fec_enet_mii_remove (fep);if (fep->reg_phy)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 923/935 usb: atm: usbatm: fix invalid ci_range initialization
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit a60fd8c6dbaa76da4163cf225ed2b9e982540f39 ]
syzbot reported a shift-out-of-bounds in __vcc_connect():
UBSAN: shift-out-of-bounds in net/atm/common.c:382:32 shift exponent -1 is negative CPU: 0 UID: 0 PID: 5987 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 08/05/2026 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 ubsan_epilogue+0xa/0x30 lib/ubsan.c:233 __ubsan_handle_shift_out_of_bounds+0x36d/0x400 lib/ubsan.c:494 __vcc_connect+0x14b4/0x19c0 net/atm/common.c:382 vcc_connect+0x328/0x8f0 net/atm/common.c:498 pvc_bind+0x272/0x380 net/atm/pvc.c:52 __sys_bind+0x2e3/0x410 net/socket.c:1976 __x64_sys_bind+0x7a/0x90 net/socket.c:1979 ...
ATM device ci_range fields (vpi_bits and vci_bits) represent the number of bits supported for VPI and VCI addressing on the device. net/atm/common.c directly uses these fields as bit shift counts:
vpi >> dev->ci_range.vpi_bits
vci >> dev->ci_range.vci_bits
1 << vcc->dev->ci_range.vpi_bits
1 << vcc->dev->ci_range.vci_bits
usbatm_atm_init() sets ci_range.vpi_bits and ci_range.vci_bits to ATM_CI_MAX (-1), which is defined in <uapi/linux/atmdev.h> as a sentinel value for userspace ATM_SETCIRANGE requests, not a valid bit count. Shifting by -1 is undefined behavior and triggers UBSAN warnings.
ATM UNI cell headers allow up to 8 bits for VPI (0..255) and 16 bits for VCI (0..65535). Initialize vpi_bits to 8 and vci_bits to 16, as done by solos-pci.
--- drivers/usb/atm/usbatm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/atm/usbatm.c +2 -2
@@ -917,8 +917,8 @@ static int usbatm_atm_init(struct usbatm_data *instance) instance->atm_dev = atm_dev; - atm_dev->ci_range.vpi_bits =ATM_CI_MAX ; - atm_dev->ci_range.vci_bits =ATM_CI_MAX ; + atm_dev->ci_range.vpi_bits =8 ; + atm_dev->ci_range.vci_bits =16 ; atm_dev->signal =ATM_PHY_SIG_UNKNOWN ;/* temp init ATM device, set to 128kbit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 924/935 tcp: fix corruption of urgent data on multi-segment retransmit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit ce2b807f42ed5e55567b8864ab72963f90779270 ]
On the normal xmit path, while in urgent mode we refuse to build a multi-segment TSO packet, so every segment gets its own urg_ptr:
/* tcp_write_xmit() */ limit = mss_now; if (tso_segs > 1 && !tcp_urg_mode(tp)) limit = tcp_mss_split_point(...);
The retransmit path has no such guard. __tcp_retransmit_skb() builds a segs > 1 skb and hands it to the GSO layer, which only advances th->seq per segment and copies urg_ptr verbatim:
/* __tcp_retransmit_skb() */ len = cur_mss * segs; /* segs > 1, no urg_mode check */ ... /* tcp_gso_segment(): bumps seq only, urg_ptr is copied */
urg_ptr is an offset from the segment's own seq, so a copied value points at a different place on each segment. The receiver rebuilds the absolute urgent seq as seg.seq + urg_ptr, so it walks a moving urgent point instead of the one OOB byte:
seg1 seq 1 urg_ptr 5001 -> urgent @ 5001 (ok) seg2 seq 1001 urg_ptr 5001 -> urgent @ 6001 (wrong, +MSS) seg3 seq 2001 urg_ptr 5001 -> urgent @ 7001 (wrong, +2*MSS)
The real OOB byte is never pointed at, so the receiver stops splicing it out and delivers it as normal in-band data, corrupting the stream.
Guard the retransmit length like the xmit path: keep segs = 1 while in urgent mode.
--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
@@ -3216,7 +3216,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) avail_wnd = cur_mss; } - len = cur_mss * segs; + len = cur_mss * (tcp_urg_mode (tp) ?1 : segs);if (len > avail_wnd) { len =rounddown (avail_wnd, cur_mss);if (!len)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 925/935 net/sched: sch_htb: limit htb_classify inner-class filter hops
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 729c4896ab829169f95915d65edd530325910b37 ]
htb_classify() follows each filter-selected inner class by switching to cl->filter_list, but never bounds the number of hops. A filter on an inner class can point back to itself or to another inner class that points back, creating an infinite loop in the packet classification path with the qdisc lock held and BH disabled — a soft lockup / panic from a single packet.
Bound the traversal with a hop counter and drop the packet with a rate-limited warning once the bound is exceeded. The counter is incremented at the point the inner filter chain is picked up, after the TC_ACT_* switch has consumed the classifier verdict, so a terminal TC_ACT_QUEUED/STOLEN/TRAP on the last permitted chain still sets *qerr to __NET_XMIT_STOLEN and the packet is not charged as a drop by this qdisc or its parent.
The bound is TC_HTB_MAXDEPTH, taken from HTB's own parameters rather than from the qdisc hierarchy depth limit. Class levels run from 0 to TC_HTB_MAXDEPTH - 1, so a traversal that strictly descends in level can take at most TC_HTB_MAXDEPTH hops. That descent is what a sane configuration does, but it is assumed here rather than enforced:htb_find() resolves a classid against every class in the qdisc, so a filter may equally select a sibling or an ancestor. The normal root -> inner -> leaf path takes a single hop, so the bound does not affect legitimate classification.
htb_classify() can now return NULL irrespective of CONFIG_NET_CLS_ACT, whereas previously every NULL return sat inside that ifdef. The NULL handler in htb_enqueue() therefore cannot stay conditional either, so drop the ifdef around it. This matches hfsc_enqueue(), which has always handled a NULL class unconditionally. Without it, a kernel built without actions would dereference a NULL class instead of dropping.
Conditions to recreate the bug:
- CONFIG_NET_SCHED, CONFIG_NET_SCH_HTB, CONFIG_NET_CLS_U32, CONFIG_LOCKUP_DETECTOR.
- Create an HTB qdisc on a device (e.g. lo), add an inner class 1:1 with a leaf child 1:10, install a root u32 filter selecting 1:1, and an inner-class u32 filter on 1:1 also selecting 1:1.
- Send one packet (ping). On the unfixed kernel the classify loop spins with the qdisc lock held; with softlockup_panic=1 it panics.
- Reachable from unprivileged user via unshare -Urn (CAP_NET_ADMIN).
--- net/sched/sch_htb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/sched/sch_htb.c +5 -2
@@ -220,6 +220,7 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,struct htb_class *cl;struct tcf_result res;struct tcf_proto *tcf; +unsigned int hops =0 ;int result;/* allow to select class by setting skb->priority to valid classid;
@@ -262,6 +263,10 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,if (!cl->level)return cl;/* we hit leaf; return it */ +if (++hops >TC_HTB_MAXDEPTH ) { +pr_warn_ratelimited ("htb: classify loop detected, dropping packet\n" ); +return NULL ; + }/* we have got inner class; apply inner filter chain */ tcf =rcu_dereference_bh (cl->filter_list); }
@@ -629,13 +634,11 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch, }else {return qdisc_drop (skb, sch, to_free); } -#ifdef CONFIG_NET_CLS_ACT }else if (!cl) {if (ret & __NET_XMIT_BYPASS)qdisc_qstats_drop (sch);__qdisc_drop (skb, to_free);return ret; -#endif }else if ((ret =qdisc_enqueue (skb, cl->leaf.q, to_free)) !=NET_XMIT_SUCCESS ) {if (net_xmit_drop_count (ret)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 926/935 nvme: target: rdma: fix ndev refcount leak on queue connect
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit badc53620fe813b3a9f727ef9526f98567c2c898 ]
nvmet_rdma_queue_connect() calls nvmet_rdma_find_get_device() which acquires a reference on the returned ndev via kref_get(). On the path where the host queue backlog is exceeded and the function returns NVME_SC_CONNECT_CTRL_BUSY, reference of ndev is not released, leaking the kref.
Fix this by adding a goto to the existing put_device label before the early return.
--- drivers/nvme/target/rdma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/rdma.c +4 -2
@@ -1625,8 +1625,10 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id, pending++; }mutex_unlock (&nvmet_rdma_queue_mutex); -if (pending >NVMET_RDMA_BACKLOG ) -return NVME_SC_CONNECT_CTRL_BUSY ; +if (pending >NVMET_RDMA_BACKLOG ) { + ret =NVME_SC_CONNECT_CTRL_BUSY ; + goto put_device; + } } ret =nvmet_rdma_cm_accept (cm_id, queue, &event->param.conn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 927/935 clk: qcom: Drop mmcx gdsc supply for dispcc and videocc
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit b1ec8b53c9ae5fae33d60e9638d39ca5346b941b ]
Both dispcc and videocc use mmcx power domain now. Lets drop the supply mmcx from every gdsc.
--- drivers/clk/qcom/dispcc-sm8250.c | 1 - drivers/clk/qcom/videocc-sm8250.c | 4 ---- 2 files changed, 5 deletions(-)
drivers/clk/qcom/dispcc-sm8250.c +0 -1
@@ -1136,7 +1136,6 @@ static struct gdsc mdss_gdsc = { }, .pwrsts = PWRSTS_OFF_ON, .flags = HW_CTRL, - .supply = "mmcx", };static struct clk_regmap *disp_cc_sm8250_clocks[] = {
drivers/clk/qcom/videocc-sm8250.c +0 -4
@@ -276,7 +276,6 @@ static struct gdsc mvs0c_gdsc = { }, .flags = 0, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct gdsc mvs1c_gdsc = {
@@ -286,7 +285,6 @@ static struct gdsc mvs1c_gdsc = { }, .flags = 0, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct gdsc mvs0_gdsc = {
@@ -296,7 +294,6 @@ static struct gdsc mvs0_gdsc = { }, .flags = HW_CTRL, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct gdsc mvs1_gdsc = {
@@ -306,7 +303,6 @@ static struct gdsc mvs1_gdsc = { }, .flags = HW_CTRL, .pwrsts = PWRSTS_OFF_ON, - .supply = "mmcx", };static struct clk_regmap *video_cc_sm8250_clocks[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 928/935 RDMA/nldev: Check stat attribute before accessing it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit d821f7c13ca03318ad1bdc64ce64afb43080a07a ]
The access to non-existent netlink attribute causes to the following kernel panic. Fix it by checking existence before trying to read it.
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 0 PID: 6744 Comm: syz-executor.0 Not tainted 5.15.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:nla_get_u32 include/net/netlink.h:1554 [inline] RIP: 0010:nldev_stat_set_mode_doit drivers/infiniband/core/nldev.c:1909 [inline] RIP: 0010:nldev_stat_set_doit+0x578/0x10d0 drivers/infiniband/core/nldev.c:2040 Code: fa 4c 8b a4 24 f8 02 00 00 48 b8 00 00 00 00 00 fc ff df c7 84 24 80 00 00 00 00 00 00 00 49 8d 7c 24 04 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 02 RSP: 0018:ffffc90004acf2e8 EFLAGS: 00010247 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffc90002b94000 RDX: 0000000000000000 RSI: ffffffff8684c5ff RDI: 0000000000000004 RBP: ffff88807cda4000 R08: 0000000000000000 R09: ffff888023fb8027 R10: ffffffff8684c5d7 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000001 R14: ffff888041024280 R15: ffff888031ade780 FS: 00007eff9dddd700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b2ef24000 CR3: 0000000036902000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> rdma_nl_rcv_msg+0x36d/0x690 drivers/infiniband/core/netlink.c:195 rdma_nl_rcv_skb drivers/infiniband/core/netlink.c:239 [inline] rdma_nl_rcv+0x2ee/0x430 drivers/infiniband/core/netlink.c:259 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x86d/0xda0 net/netlink/af_netlink.c:1916 sock_sendmsg_nosec net/socket.c:704 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:724 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- drivers/infiniband/core/nldev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/nldev.c +2 -1
@@ -1900,7 +1900,8 @@ static int nldev_stat_set_mode_doit(struct sk_buff *msg,int ret;/* Currently only counter for QP is supported */ -if (nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_RES ]) !=RDMA_NLDEV_ATTR_RES_QP ) +if (!tb[RDMA_NLDEV_ATTR_STAT_RES ] || +nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_RES ]) !=RDMA_NLDEV_ATTR_RES_QP )return -EINVAL ; mode =nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_MODE ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 929/935 HID: fix an error code in hid_check_device_match()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 89e756e3cc8d9c1ebc0f2b2f6912227073d93118 ]
The hid_check_device_match() returns true if we find a match and false if we don't. But here it returns -ENODEV which becomes true instead of false.
--- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-core.c +1 -1
@@ -2322,7 +2322,7 @@ static bool hid_check_device_match(struct hid_device *hdev, { *id =hid_match_device (hdev, hdrv);if (!*id) -return -ENODEV ; +return false;if (hdrv->match)return hdrv->match (hdev, hid_ignore_special_drivers);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 930/935 ALSA: control: Fix unannotated kfree() cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 14d811467f6592aa0e685730e66b5f9123287468 ]
The recent conversion to the automatic kfree() forgot to mark a variable with __free(kfree), leading to memory leaks. Fix it.
Message-ID: <[email protected]>
--- sound/core/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/control.c +2 -2
@@ -1115,12 +1115,12 @@ static int snd_ctl_elem_read(struct snd_card *card,static int snd_ctl_elem_read_user (struct snd_card *card,struct snd_ctl_elem_value __user *_control) { -struct snd_ctl_elem_value *control; + struct snd_ctl_elem_value *control __free(kfree) = NULL;int result; control =memdup_user (_control,sizeof (*control));if (IS_ERR (control)) -return PTR_ERR (control); +return PTR_ERR (no_free_ptr (control)); result =snd_ctl_elem_read (card, control);if (result <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 931/935 Bluetooth: L2CAP: Fix send LE flow credits in ACL link
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Chen <[email protected]>
[ Upstream commit f39f905e55f529b036321220af1ba4f4085564a5 ]
When the L2CAP channel mode is L2CAP_MODE_ERTM/L2CAP_MODE_STREAMING, l2cap_publish_rx_avail will be called and le flow credits will be sent in l2cap_chan_rx_avail, even though the link type is ACL.
The logs in question as follows:
Quoted 1 line
ACL Data RX: Handle 129 flags
0x02dlen 12
L2CAP: Unknown (0x16) ident 4 len 4
40 00 ed 05
< ACL Data TX: Handle 129 flags 0x00 dlen 10
L2CAP: Command Reject (0x01) ident 4 len 2
Reason: Command not understood (0x0000)Bluetooth: Unknown BR/EDR signaling command 0x16
Bluetooth: Wrong link type (-22)
--- net/bluetooth/l2cap_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/l2cap_core.c +4 -0
@@ -7771,6 +7771,10 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan)struct l2cap_le_credits pkt;u16 return_credits =l2cap_le_rx_credits (chan); +if (chan->mode !=L2CAP_MODE_LE_FLOWCTL && + chan->mode !=L2CAP_MODE_EXT_FLOWCTL ) +return ; +if (chan->rx_credits >= return_credits)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 932/935 kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
[ Upstream commit 306219d59b72cfca4005229b2c6ad43a16479e3b ]
While the kselftest was added at the same time with the kernel support for MTE on hugetlb mappings, the tests may be run on older kernels. Skip the tests if PROT_MTE is not supported on MAP_HUGETLB mappings.
--- .../selftests/arm64/mte/check_hugetlb_options.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/testing/selftests/arm64/mte/check_hugetlb_options.c +11 -0
@@ -227,6 +227,8 @@ static int check_child_hugetlb_memory_mapping(int mem_type, int mode, int mappinint main (int argc,char *argv[]) {int err; +void *map_ptr; +unsigned long map_size;ksft_print_header ();
@@ -245,6 +247,15 @@ int main(int argc, char *argv[])return KSFT_FAIL ; } +/* Check if MTE supports hugetlb mappings */ + map_size =default_huge_page_size (); + map_ptr =mmap (NULL , map_size,PROT_READ |PROT_MTE , +MAP_PRIVATE |MAP_ANONYMOUS |MAP_HUGETLB ,-1 ,0 ); +if (map_ptr ==MAP_FAILED ) +ksft_exit_skip ("PROT_MTE not supported with MAP_HUGETLB mappings\n" ); +else +munmap (map_ptr, map_size); +/* Set test plan */ ksft_set_plan (12 );
Signature · 1 line
2.53.0