From: Sasha Levin Date: Mon, 26 Jun 2023 04:23:19 +0000 (-0400) Subject: Fixes for 5.15 X-Git-Tag: v4.14.320~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34d5c55ebd12660bf13e51aa7ee71626a2cd9237;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.15 Signed-off-by: Sasha Levin --- diff --git a/queue-5.15/arm-dts-fix-erroneous-ads-touchscreen-polarities.patch b/queue-5.15/arm-dts-fix-erroneous-ads-touchscreen-polarities.patch new file mode 100644 index 00000000000..fae487bb6a8 --- /dev/null +++ b/queue-5.15/arm-dts-fix-erroneous-ads-touchscreen-polarities.patch @@ -0,0 +1,177 @@ +From 3575b103a84bbb275c1875e8e8573e56020bbb93 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 May 2023 12:51:56 +0200 +Subject: ARM: dts: Fix erroneous ADS touchscreen polarities + +From: Linus Walleij + +[ Upstream commit 4a672d500bfd6bb87092c33d5a2572c3d0a1cf83 ] + +Several device tree files get the polarity of the pendown-gpios +wrong: this signal is active low. Fix up all incorrect flags, so +that operating systems can rely on the flag being correctly set. + +Signed-off-by: Linus Walleij +Link: https://lore.kernel.org/r/20230510105156.1134320-1-linus.walleij@linaro.org +Signed-off-by: Arnd Bergmann +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/am57xx-cl-som-am57x.dts | 2 +- + arch/arm/boot/dts/at91sam9261ek.dts | 2 +- + arch/arm/boot/dts/imx7d-pico-hobbit.dts | 2 +- + arch/arm/boot/dts/imx7d-sdb.dts | 2 +- + arch/arm/boot/dts/omap3-cm-t3x.dtsi | 2 +- + arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi | 2 +- + arch/arm/boot/dts/omap3-lilly-a83x.dtsi | 2 +- + arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi | 2 +- + arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi | 2 +- + arch/arm/boot/dts/omap3-pandora-common.dtsi | 2 +- + arch/arm/boot/dts/omap5-cm-t54.dts | 2 +- + 11 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/arch/arm/boot/dts/am57xx-cl-som-am57x.dts b/arch/arm/boot/dts/am57xx-cl-som-am57x.dts +index 2e94f32d9dfca..5de82729eb7ed 100644 +--- a/arch/arm/boot/dts/am57xx-cl-som-am57x.dts ++++ b/arch/arm/boot/dts/am57xx-cl-som-am57x.dts +@@ -527,7 +527,7 @@ + + interrupt-parent = <&gpio1>; + interrupts = <31 0>; +- pendown-gpio = <&gpio1 31 0>; ++ pendown-gpio = <&gpio1 31 GPIO_ACTIVE_LOW>; + + + ti,x-min = /bits/ 16 <0x0>; +diff --git a/arch/arm/boot/dts/at91sam9261ek.dts b/arch/arm/boot/dts/at91sam9261ek.dts +index beed819609e8d..8f3b483bb64dd 100644 +--- a/arch/arm/boot/dts/at91sam9261ek.dts ++++ b/arch/arm/boot/dts/at91sam9261ek.dts +@@ -156,7 +156,7 @@ + compatible = "ti,ads7843"; + interrupts-extended = <&pioC 2 IRQ_TYPE_EDGE_BOTH>; + spi-max-frequency = <3000000>; +- pendown-gpio = <&pioC 2 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&pioC 2 GPIO_ACTIVE_LOW>; + + ti,x-min = /bits/ 16 <150>; + ti,x-max = /bits/ 16 <3830>; +diff --git a/arch/arm/boot/dts/imx7d-pico-hobbit.dts b/arch/arm/boot/dts/imx7d-pico-hobbit.dts +index d917dc4f2f227..6ad39dca70096 100644 +--- a/arch/arm/boot/dts/imx7d-pico-hobbit.dts ++++ b/arch/arm/boot/dts/imx7d-pico-hobbit.dts +@@ -64,7 +64,7 @@ + interrupt-parent = <&gpio2>; + interrupts = <7 0>; + spi-max-frequency = <1000000>; +- pendown-gpio = <&gpio2 7 0>; ++ pendown-gpio = <&gpio2 7 GPIO_ACTIVE_LOW>; + vcc-supply = <®_3p3v>; + ti,x-min = /bits/ 16 <0>; + ti,x-max = /bits/ 16 <4095>; +diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts +index 4e1a6cde90fe3..4e62ed2df11dd 100644 +--- a/arch/arm/boot/dts/imx7d-sdb.dts ++++ b/arch/arm/boot/dts/imx7d-sdb.dts +@@ -205,7 +205,7 @@ + pinctrl-0 = <&pinctrl_tsc2046_pendown>; + interrupt-parent = <&gpio2>; + interrupts = <29 0>; +- pendown-gpio = <&gpio2 29 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio2 29 GPIO_ACTIVE_LOW>; + touchscreen-max-pressure = <255>; + wakeup-source; + }; +diff --git a/arch/arm/boot/dts/omap3-cm-t3x.dtsi b/arch/arm/boot/dts/omap3-cm-t3x.dtsi +index e61b8a2bfb7de..51baedf1603bd 100644 +--- a/arch/arm/boot/dts/omap3-cm-t3x.dtsi ++++ b/arch/arm/boot/dts/omap3-cm-t3x.dtsi +@@ -227,7 +227,7 @@ + + interrupt-parent = <&gpio2>; + interrupts = <25 0>; /* gpio_57 */ +- pendown-gpio = <&gpio2 25 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio2 25 GPIO_ACTIVE_LOW>; + + ti,x-min = /bits/ 16 <0x0>; + ti,x-max = /bits/ 16 <0x0fff>; +diff --git a/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi b/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi +index 3decc2d78a6ca..a7f99ae0c1fe9 100644 +--- a/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi ++++ b/arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi +@@ -54,7 +54,7 @@ + + interrupt-parent = <&gpio1>; + interrupts = <27 0>; /* gpio_27 */ +- pendown-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio1 27 GPIO_ACTIVE_LOW>; + + ti,x-min = /bits/ 16 <0x0>; + ti,x-max = /bits/ 16 <0x0fff>; +diff --git a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi +index 73d477898ec2a..06e7cf96c6639 100644 +--- a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi ++++ b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi +@@ -311,7 +311,7 @@ + interrupt-parent = <&gpio1>; + interrupts = <8 0>; /* boot6 / gpio_8 */ + spi-max-frequency = <1000000>; +- pendown-gpio = <&gpio1 8 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio1 8 GPIO_ACTIVE_LOW>; + vcc-supply = <®_vcc3>; + pinctrl-names = "default"; + pinctrl-0 = <&tsc2048_pins>; +diff --git a/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi b/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi +index 1d6e88f99eb31..c3570acc35fad 100644 +--- a/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi ++++ b/arch/arm/boot/dts/omap3-overo-common-lcd35.dtsi +@@ -149,7 +149,7 @@ + + interrupt-parent = <&gpio4>; + interrupts = <18 0>; /* gpio_114 */ +- pendown-gpio = <&gpio4 18 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio4 18 GPIO_ACTIVE_LOW>; + + ti,x-min = /bits/ 16 <0x0>; + ti,x-max = /bits/ 16 <0x0fff>; +diff --git a/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi b/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi +index 7e30f9d45790e..d95a0e130058c 100644 +--- a/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi ++++ b/arch/arm/boot/dts/omap3-overo-common-lcd43.dtsi +@@ -160,7 +160,7 @@ + + interrupt-parent = <&gpio4>; + interrupts = <18 0>; /* gpio_114 */ +- pendown-gpio = <&gpio4 18 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio4 18 GPIO_ACTIVE_LOW>; + + ti,x-min = /bits/ 16 <0x0>; + ti,x-max = /bits/ 16 <0x0fff>; +diff --git a/arch/arm/boot/dts/omap3-pandora-common.dtsi b/arch/arm/boot/dts/omap3-pandora-common.dtsi +index 37608af6c07f5..ca6d777ebf843 100644 +--- a/arch/arm/boot/dts/omap3-pandora-common.dtsi ++++ b/arch/arm/boot/dts/omap3-pandora-common.dtsi +@@ -651,7 +651,7 @@ + pinctrl-0 = <&penirq_pins>; + interrupt-parent = <&gpio3>; + interrupts = <30 IRQ_TYPE_NONE>; /* GPIO_94 */ +- pendown-gpio = <&gpio3 30 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio3 30 GPIO_ACTIVE_LOW>; + vcc-supply = <&vaux4>; + + ti,x-min = /bits/ 16 <0>; +diff --git a/arch/arm/boot/dts/omap5-cm-t54.dts b/arch/arm/boot/dts/omap5-cm-t54.dts +index ca759b7b8a580..e62ea8b6d53fd 100644 +--- a/arch/arm/boot/dts/omap5-cm-t54.dts ++++ b/arch/arm/boot/dts/omap5-cm-t54.dts +@@ -354,7 +354,7 @@ + + interrupt-parent = <&gpio1>; + interrupts = <15 0>; /* gpio1_wk15 */ +- pendown-gpio = <&gpio1 15 GPIO_ACTIVE_HIGH>; ++ pendown-gpio = <&gpio1 15 GPIO_ACTIVE_LOW>; + + + ti,x-min = /bits/ 16 <0x0>; +-- +2.39.2 + diff --git a/queue-5.15/arm64-add-missing-set-way-cmo-encodings.patch b/queue-5.15/arm64-add-missing-set-way-cmo-encodings.patch new file mode 100644 index 00000000000..5f903fab4f6 --- /dev/null +++ b/queue-5.15/arm64-add-missing-set-way-cmo-encodings.patch @@ -0,0 +1,43 @@ +From 8c470bf1d5f8f3ec44d7158d9d94859feef3725f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 May 2023 21:46:00 +0100 +Subject: arm64: Add missing Set/Way CMO encodings + +From: Marc Zyngier + +[ Upstream commit 8d0f019e4c4f2ee2de81efd9bf1c27e9fb3c0460 ] + +Add the missing Set/Way CMOs that apply to tagged memory. + +Signed-off-by: Marc Zyngier +Reviewed-by: Cornelia Huck +Reviewed-by: Steven Price +Reviewed-by: Oliver Upton +Link: https://lore.kernel.org/r/20230515204601.1270428-2-maz@kernel.org +Signed-off-by: Sasha Levin +--- + arch/arm64/include/asm/sysreg.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h +index f79f3720e4cbe..543eb08fa8e5f 100644 +--- a/arch/arm64/include/asm/sysreg.h ++++ b/arch/arm64/include/asm/sysreg.h +@@ -109,8 +109,14 @@ + #define SB_BARRIER_INSN __SYS_BARRIER_INSN(0, 7, 31) + + #define SYS_DC_ISW sys_insn(1, 0, 7, 6, 2) ++#define SYS_DC_IGSW sys_insn(1, 0, 7, 6, 4) ++#define SYS_DC_IGDSW sys_insn(1, 0, 7, 6, 6) + #define SYS_DC_CSW sys_insn(1, 0, 7, 10, 2) ++#define SYS_DC_CGSW sys_insn(1, 0, 7, 10, 4) ++#define SYS_DC_CGDSW sys_insn(1, 0, 7, 10, 6) + #define SYS_DC_CISW sys_insn(1, 0, 7, 14, 2) ++#define SYS_DC_CIGSW sys_insn(1, 0, 7, 14, 4) ++#define SYS_DC_CIGDSW sys_insn(1, 0, 7, 14, 6) + + /* + * System registers, organised loosely by encoding but grouped together +-- +2.39.2 + diff --git a/queue-5.15/asoc-nau8824-add-quirk-to-active-high-jack-detect.patch b/queue-5.15/asoc-nau8824-add-quirk-to-active-high-jack-detect.patch new file mode 100644 index 00000000000..66f3b0bf379 --- /dev/null +++ b/queue-5.15/asoc-nau8824-add-quirk-to-active-high-jack-detect.patch @@ -0,0 +1,59 @@ +From e7a8e6c46b550758a759273aecb3403253bf47f7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 29 May 2023 15:19:11 -0300 +Subject: ASoC: nau8824: Add quirk to active-high jack-detect + +From: Edson Juliano Drosdeck + +[ Upstream commit e384dba03e3294ce7ea69e4da558e9bf8f0e8946 ] + +Add entries for Positivo laptops: CW14Q01P, K1424G, N14ZP74G to the +DMI table, so that active-high jack-detect will work properly on +these laptops. + +Signed-off-by: Edson Juliano Drosdeck +Link: https://lore.kernel.org/r/20230529181911.632851-1-edson.drosdeck@gmail.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/nau8824.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c +index 27589900f4fbf..f7ff130a9485d 100644 +--- a/sound/soc/codecs/nau8824.c ++++ b/sound/soc/codecs/nau8824.c +@@ -1866,6 +1866,30 @@ static const struct dmi_system_id nau8824_quirk_table[] = { + }, + .driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH), + }, ++ { ++ /* Positivo CW14Q01P */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Positivo Tecnologia SA"), ++ DMI_MATCH(DMI_BOARD_NAME, "CW14Q01P"), ++ }, ++ .driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH), ++ }, ++ { ++ /* Positivo K1424G */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Positivo Tecnologia SA"), ++ DMI_MATCH(DMI_BOARD_NAME, "K1424G"), ++ }, ++ .driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH), ++ }, ++ { ++ /* Positivo N14ZP74G */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Positivo Tecnologia SA"), ++ DMI_MATCH(DMI_BOARD_NAME, "N14ZP74G"), ++ }, ++ .driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH), ++ }, + {} + }; + +-- +2.39.2 + diff --git a/queue-5.15/asoc-simple-card-add-missing-of_node_put-in-case-of-.patch b/queue-5.15/asoc-simple-card-add-missing-of_node_put-in-case-of-.patch new file mode 100644 index 00000000000..cbfef85bfc8 --- /dev/null +++ b/queue-5.15/asoc-simple-card-add-missing-of_node_put-in-case-of-.patch @@ -0,0 +1,36 @@ +From 0fb8efe326747052ac31eda8325628a7ef5d97ef Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 23 May 2023 17:12:22 +0200 +Subject: ASoC: simple-card: Add missing of_node_put() in case of error + +From: Herve Codina + +[ Upstream commit 8938f75a5e35c597a647c28984a0304da7a33d63 ] + +In the error path, a of_node_put() for platform is missing. +Just add it. + +Signed-off-by: Herve Codina +Acked-by: Kuninori Morimoto +Link: https://lore.kernel.org/r/20230523151223.109551-9-herve.codina@bootlin.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/generic/simple-card.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c +index bc3e24c6a28a8..283aa21879aa5 100644 +--- a/sound/soc/generic/simple-card.c ++++ b/sound/soc/generic/simple-card.c +@@ -417,6 +417,7 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv, + + if (ret < 0) { + of_node_put(codec); ++ of_node_put(plat); + of_node_put(np); + goto error; + } +-- +2.39.2 + diff --git a/queue-5.15/be2net-extend-xmit-workaround-to-be3-chip.patch b/queue-5.15/be2net-extend-xmit-workaround-to-be3-chip.patch new file mode 100644 index 00000000000..b7c2b85949a --- /dev/null +++ b/queue-5.15/be2net-extend-xmit-workaround-to-be3-chip.patch @@ -0,0 +1,48 @@ +From dcf3adf491afc354a04f80264eb21ce4f288ae0b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 17:45:49 +0100 +Subject: be2net: Extend xmit workaround to BE3 chip + +From: Ross Lagerwall + +[ Upstream commit 7580e0a78eb29e7bb1a772eba4088250bbb70d41 ] + +We have seen a bug where the NIC incorrectly changes the length in the +IP header of a padded packet to include the padding bytes. The driver +already has a workaround for this so do the workaround for this NIC too. +This resolves the issue. + +The NIC in question identifies itself as follows: + +[ 8.828494] be2net 0000:02:00.0: FW version is 10.7.110.31 +[ 8.834759] be2net 0000:02:00.0: Emulex OneConnect(be3): PF FLEX10 port 1 + +02:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01) + +Fixes: ca34fe38f06d ("be2net: fix wrong usage of adapter->generation") +Signed-off-by: Ross Lagerwall +Link: https://lore.kernel.org/r/20230616164549.2863037-1-ross.lagerwall@citrix.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/emulex/benet/be_main.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c +index 361c1c87c1830..e874b907bfbdf 100644 +--- a/drivers/net/ethernet/emulex/benet/be_main.c ++++ b/drivers/net/ethernet/emulex/benet/be_main.c +@@ -1136,8 +1136,8 @@ static struct sk_buff *be_lancer_xmit_workarounds(struct be_adapter *adapter, + eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ? + VLAN_ETH_HLEN : ETH_HLEN; + if (skb->len <= 60 && +- (lancer_chip(adapter) || skb_vlan_tag_present(skb)) && +- is_ipv4_pkt(skb)) { ++ (lancer_chip(adapter) || BE3_chip(adapter) || ++ skb_vlan_tag_present(skb)) && is_ipv4_pkt(skb)) { + ip = (struct iphdr *)ip_hdr(skb); + pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len)); + } +-- +2.39.2 + diff --git a/queue-5.15/bpf-btf-accept-function-names-that-contain-dots.patch b/queue-5.15/bpf-btf-accept-function-names-that-contain-dots.patch new file mode 100644 index 00000000000..6efe1b259e0 --- /dev/null +++ b/queue-5.15/bpf-btf-accept-function-names-that-contain-dots.patch @@ -0,0 +1,120 @@ +From 558573277ee5aafd355e7be02bf44e81389e4c73 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 15 Jun 2023 16:56:07 +0200 +Subject: bpf/btf: Accept function names that contain dots + +From: Florent Revest + +[ Upstream commit 9724160b3942b0a967b91a59f81da5593f28b8ba ] + +When building a kernel with LLVM=1, LLVM_IAS=0 and CONFIG_KASAN=y, LLVM +leaves DWARF tags for the "asan.module_ctor" & co symbols. In turn, +pahole creates BTF_KIND_FUNC entries for these and this makes the BTF +metadata validation fail because they contain a dot. + +In a dramatic turn of event, this BTF verification failure can cause +the netfilter_bpf initialization to fail, causing netfilter_core to +free the netfilter_helper hashmap and netfilter_ftp to trigger a +use-after-free. The risk of u-a-f in netfilter will be addressed +separately but the existence of "asan.module_ctor" debug info under some +build conditions sounds like a good enough reason to accept functions +that contain dots in BTF. + +Although using only LLVM=1 is the recommended way to compile clang-based +kernels, users can certainly do LLVM=1, LLVM_IAS=0 as well and we still +try to support that combination according to Nick. To clarify: + + - > v5.10 kernel, LLVM=1 (LLVM_IAS=0 is not the default) is recommended, + but user can still have LLVM=1, LLVM_IAS=0 to trigger the issue + + - <= 5.10 kernel, LLVM=1 (LLVM_IAS=0 is the default) is recommended in + which case GNU as will be used + +Fixes: 1dc92851849c ("bpf: kernel side support for BTF Var and DataSec") +Signed-off-by: Florent Revest +Signed-off-by: Daniel Borkmann +Acked-by: Andrii Nakryiko +Cc: Yonghong Song +Cc: Nick Desaulniers +Link: https://lore.kernel.org/bpf/20230615145607.3469985-1-revest@chromium.org +Signed-off-by: Sasha Levin +--- + kernel/bpf/btf.c | 20 ++++++++------------ + 1 file changed, 8 insertions(+), 12 deletions(-) + +diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c +index 6c7126de5c17f..5d4bea53ac1f8 100644 +--- a/kernel/bpf/btf.c ++++ b/kernel/bpf/btf.c +@@ -633,13 +633,12 @@ static bool btf_name_offset_valid(const struct btf *btf, u32 offset) + return offset < btf->hdr.str_len; + } + +-static bool __btf_name_char_ok(char c, bool first, bool dot_ok) ++static bool __btf_name_char_ok(char c, bool first) + { + if ((first ? !isalpha(c) : + !isalnum(c)) && + c != '_' && +- ((c == '.' && !dot_ok) || +- c != '.')) ++ c != '.') + return false; + return true; + } +@@ -656,20 +655,20 @@ static const char *btf_str_by_offset(const struct btf *btf, u32 offset) + return NULL; + } + +-static bool __btf_name_valid(const struct btf *btf, u32 offset, bool dot_ok) ++static bool __btf_name_valid(const struct btf *btf, u32 offset) + { + /* offset must be valid */ + const char *src = btf_str_by_offset(btf, offset); + const char *src_limit; + +- if (!__btf_name_char_ok(*src, true, dot_ok)) ++ if (!__btf_name_char_ok(*src, true)) + return false; + + /* set a limit on identifier length */ + src_limit = src + KSYM_NAME_LEN; + src++; + while (*src && src < src_limit) { +- if (!__btf_name_char_ok(*src, false, dot_ok)) ++ if (!__btf_name_char_ok(*src, false)) + return false; + src++; + } +@@ -677,17 +676,14 @@ static bool __btf_name_valid(const struct btf *btf, u32 offset, bool dot_ok) + return !*src; + } + +-/* Only C-style identifier is permitted. This can be relaxed if +- * necessary. +- */ + static bool btf_name_valid_identifier(const struct btf *btf, u32 offset) + { +- return __btf_name_valid(btf, offset, false); ++ return __btf_name_valid(btf, offset); + } + + static bool btf_name_valid_section(const struct btf *btf, u32 offset) + { +- return __btf_name_valid(btf, offset, true); ++ return __btf_name_valid(btf, offset); + } + + static const char *__btf_name_by_offset(const struct btf *btf, u32 offset) +@@ -3536,7 +3532,7 @@ static s32 btf_var_check_meta(struct btf_verifier_env *env, + } + + if (!t->name_off || +- !__btf_name_valid(env->btf, t->name_off, true)) { ++ !__btf_name_valid(env->btf, t->name_off)) { + btf_verifier_log_type(env, t, "Invalid name"); + return -EINVAL; + } +-- +2.39.2 + diff --git a/queue-5.15/bpf-fix-verifier-id-tracking-of-scalars-on-spill.patch b/queue-5.15/bpf-fix-verifier-id-tracking-of-scalars-on-spill.patch new file mode 100644 index 00000000000..08929695c2c --- /dev/null +++ b/queue-5.15/bpf-fix-verifier-id-tracking-of-scalars-on-spill.patch @@ -0,0 +1,71 @@ +From 2153335b51d9aa6a715c1d7cb115cee9da0d7404 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 7 Jun 2023 15:39:50 +0300 +Subject: bpf: Fix verifier id tracking of scalars on spill + +From: Maxim Mikityanskiy + +[ Upstream commit 713274f1f2c896d37017efee333fd44149710119 ] + +The following scenario describes a bug in the verifier where it +incorrectly concludes about equivalent scalar IDs which could lead to +verifier bypass in privileged mode: + +1. Prepare a 32-bit rogue number. +2. Put the rogue number into the upper half of a 64-bit register, and + roll a random (unknown to the verifier) bit in the lower half. The + rest of the bits should be zero (although variations are possible). +3. Assign an ID to the register by MOVing it to another arbitrary + register. +4. Perform a 32-bit spill of the register, then perform a 32-bit fill to + another register. Due to a bug in the verifier, the ID will be + preserved, although the new register will contain only the lower 32 + bits, i.e. all zeros except one random bit. + +At this point there are two registers with different values but the same +ID, which means the integrity of the verifier state has been corrupted. + +5. Compare the new 32-bit register with 0. In the branch where it's + equal to 0, the verifier will believe that the original 64-bit + register is also 0, because it has the same ID, but its actual value + still contains the rogue number in the upper half. + Some optimizations of the verifier prevent the actual bypass, so + extra care is needed: the comparison must be between two registers, + and both branches must be reachable (this is why one random bit is + needed). Both branches are still suitable for the bypass. +6. Right shift the original register by 32 bits to pop the rogue number. +7. Use the rogue number as an offset with any pointer. The verifier will + believe that the offset is 0, while in reality it's the given number. + +The fix is similar to the 32-bit BPF_MOV handling in check_alu_op for +SCALAR_VALUE. If the spill is narrowing the actual register value, don't +keep the ID, make sure it's reset to 0. + +Fixes: 354e8f1970f8 ("bpf: Support <8-byte scalar spill and refill") +Signed-off-by: Maxim Mikityanskiy +Signed-off-by: Daniel Borkmann +Tested-by: Andrii Nakryiko # Checked veristat delta +Acked-by: Yonghong Song +Link: https://lore.kernel.org/bpf/20230607123951.558971-2-maxtram95@gmail.com +Signed-off-by: Sasha Levin +--- + kernel/bpf/verifier.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index 9d7a6bf5f7c1f..4f2271f27a1db 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -2725,6 +2725,9 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env, + return err; + } + save_register_state(state, spi, reg, size); ++ /* Break the relation on a narrowing spill. */ ++ if (fls64(reg->umax_value) > BITS_PER_BYTE * size) ++ state->stack[spi].spilled_ptr.id = 0; + } else if (!reg && !(off % BPF_REG_SIZE) && is_bpf_st_mem(insn) && + insn->imm != 0 && env->bpf_capable) { + struct bpf_reg_state fake_reg = {}; +-- +2.39.2 + diff --git a/queue-5.15/bpf-track-immediate-values-written-to-stack-by-bpf_s.patch b/queue-5.15/bpf-track-immediate-values-written-to-stack-by-bpf_s.patch new file mode 100644 index 00000000000..9a30ea9faad --- /dev/null +++ b/queue-5.15/bpf-track-immediate-values-written-to-stack-by-bpf_s.patch @@ -0,0 +1,484 @@ +From b2108cf1f37c044ee03876e0f1a446006353ae81 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 15 Feb 2023 01:20:27 +0200 +Subject: bpf: track immediate values written to stack by BPF_ST instruction + +From: Eduard Zingerman + +[ Upstream commit ecdf985d7615356b78241fdb159c091830ed0380 ] + +For aligned stack writes using BPF_ST instruction track stored values +in a same way BPF_STX is handled, e.g. make sure that the following +commands produce similar verifier knowledge: + + fp[-8] = 42; r1 = 42; + fp[-8] = r1; + +This covers two cases: + - non-null values written to stack are stored as spill of fake + registers; + - null values written to stack are stored as STACK_ZERO marks. + +Previously both cases above used STACK_MISC marks instead. + +Some verifier test cases relied on the old logic to obtain STACK_MISC +marks for some stack values. These test cases are updated in the same +commit to avoid failures during bisect. + +Signed-off-by: Eduard Zingerman +Link: https://lore.kernel.org/r/20230214232030.1502829-2-eddyz87@gmail.com +Signed-off-by: Alexei Starovoitov +Stable-dep-of: 713274f1f2c8 ("bpf: Fix verifier id tracking of scalars on spill") +Signed-off-by: Sasha Levin +--- + kernel/bpf/verifier.c | 18 ++- + .../bpf/verifier/bounds_mix_sign_unsign.c | 110 ++++++++++-------- + 2 files changed, 80 insertions(+), 48 deletions(-) + +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index 27fd331aefe57..9d7a6bf5f7c1f 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -2659,6 +2659,11 @@ static void save_register_state(struct bpf_func_state *state, + scrub_spilled_slot(&state->stack[spi].slot_type[i - 1]); + } + ++static bool is_bpf_st_mem(struct bpf_insn *insn) ++{ ++ return BPF_CLASS(insn->code) == BPF_ST && BPF_MODE(insn->code) == BPF_MEM; ++} ++ + /* check_stack_{read,write}_fixed_off functions track spill/fill of registers, + * stack boundary and alignment are checked in check_mem_access() + */ +@@ -2670,8 +2675,9 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env, + { + struct bpf_func_state *cur; /* state of the current function */ + int i, slot = -off - 1, spi = slot / BPF_REG_SIZE, err; +- u32 dst_reg = env->prog->insnsi[insn_idx].dst_reg; ++ struct bpf_insn *insn = &env->prog->insnsi[insn_idx]; + struct bpf_reg_state *reg = NULL; ++ u32 dst_reg = insn->dst_reg; + + err = grow_stack_state(state, round_up(slot + 1, BPF_REG_SIZE)); + if (err) +@@ -2719,6 +2725,13 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env, + return err; + } + save_register_state(state, spi, reg, size); ++ } else if (!reg && !(off % BPF_REG_SIZE) && is_bpf_st_mem(insn) && ++ insn->imm != 0 && env->bpf_capable) { ++ struct bpf_reg_state fake_reg = {}; ++ ++ __mark_reg_known(&fake_reg, (u32)insn->imm); ++ fake_reg.type = SCALAR_VALUE; ++ save_register_state(state, spi, &fake_reg, size); + } else if (reg && is_spillable_regtype(reg->type)) { + /* register containing pointer is being spilled into stack */ + if (size != BPF_REG_SIZE) { +@@ -2753,7 +2766,8 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env, + state->stack[spi].spilled_ptr.live |= REG_LIVE_WRITTEN; + + /* when we zero initialize stack slots mark them as such */ +- if (reg && register_is_null(reg)) { ++ if ((reg && register_is_null(reg)) || ++ (!reg && is_bpf_st_mem(insn) && insn->imm == 0)) { + /* backtracking doesn't work for STACK_ZERO yet. */ + err = mark_chain_precision(env, value_regno); + if (err) +diff --git a/tools/testing/selftests/bpf/verifier/bounds_mix_sign_unsign.c b/tools/testing/selftests/bpf/verifier/bounds_mix_sign_unsign.c +index c2aa6f26738b4..bf82b923c5fe5 100644 +--- a/tools/testing/selftests/bpf/verifier/bounds_mix_sign_unsign.c ++++ b/tools/testing/selftests/bpf/verifier/bounds_mix_sign_unsign.c +@@ -1,13 +1,14 @@ + { + "bounds checks mixing signed and unsigned, positive bounds", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, 2), + BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 3), +@@ -17,20 +18,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), +@@ -40,20 +42,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 2", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5), +@@ -65,20 +68,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 3", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 4), +@@ -89,20 +93,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 4", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, 1), + BPF_ALU64_REG(BPF_AND, BPF_REG_1, BPF_REG_2), +@@ -112,19 +117,20 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .result = ACCEPT, + }, + { + "bounds checks mixing signed and unsigned, variant 5", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5), +@@ -135,17 +141,20 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 6", + .insns = { ++ BPF_MOV64_REG(BPF_REG_9, BPF_REG_1), ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), ++ BPF_MOV64_REG(BPF_REG_1, BPF_REG_9), + BPF_MOV64_IMM(BPF_REG_2, 0), + BPF_MOV64_REG(BPF_REG_3, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -512), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), + BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_6, -1), + BPF_JMP_REG(BPF_JGT, BPF_REG_4, BPF_REG_6, 5), +@@ -163,13 +172,14 @@ + { + "bounds checks mixing signed and unsigned, variant 7", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024), + BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), +@@ -179,19 +189,20 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .result = ACCEPT, + }, + { + "bounds checks mixing signed and unsigned, variant 8", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), +@@ -203,20 +214,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 9", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 10), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_LD_IMM64(BPF_REG_2, -9223372036854775808ULL), + BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), +@@ -228,19 +240,20 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .result = ACCEPT, + }, + { + "bounds checks mixing signed and unsigned, variant 10", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, 0), + BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), +@@ -252,20 +265,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 11", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), +@@ -278,20 +292,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 12", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -6), + BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), +@@ -303,20 +318,21 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 13", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, 2), + BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), +@@ -331,7 +347,7 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, +@@ -340,13 +356,14 @@ + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_9, BPF_REG_1, + offsetof(struct __sk_buff, mark)), ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -1), + BPF_MOV64_IMM(BPF_REG_8, 2), +@@ -360,20 +377,21 @@ + BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, -3), + BPF_JMP_IMM(BPF_JA, 0, 0, -7), + }, +- .fixup_map_hash_8b = { 4 }, ++ .fixup_map_hash_8b = { 6 }, + .errstr = "unbounded min value", + .result = REJECT, + }, + { + "bounds checks mixing signed and unsigned, variant 15", + .insns = { ++ BPF_EMIT_CALL(BPF_FUNC_ktime_get_ns), ++ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -16), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), +- BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4), +- BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), ++ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3), + BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), + BPF_MOV64_IMM(BPF_REG_2, -6), + BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), +@@ -387,7 +405,7 @@ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, +- .fixup_map_hash_8b = { 3 }, ++ .fixup_map_hash_8b = { 5 }, + .errstr = "unbounded min value", + .result = REJECT, + }, +-- +2.39.2 + diff --git a/queue-5.15/drm-exynos-fix-race-condition-uaf-in-exynos_g2d_exec.patch b/queue-5.15/drm-exynos-fix-race-condition-uaf-in-exynos_g2d_exec.patch new file mode 100644 index 00000000000..897e5ff444a --- /dev/null +++ b/queue-5.15/drm-exynos-fix-race-condition-uaf-in-exynos_g2d_exec.patch @@ -0,0 +1,37 @@ +From 9f1036062f65c0a5efa4eac09642d7e4fa54a84a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 May 2023 21:01:31 +0800 +Subject: drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl + +From: Min Li + +[ Upstream commit 48bfd02569f5db49cc033f259e66d57aa6efc9a3 ] + +If it is async, runqueue_node is freed in g2d_runqueue_worker on another +worker thread. So in extreme cases, if g2d_runqueue_worker runs first, and +then executes the following if statement, there will be use-after-free. + +Signed-off-by: Min Li +Reviewed-by: Andi Shyti +Signed-off-by: Inki Dae +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/exynos/exynos_drm_g2d.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c +index 471fd6c8135f2..27613abeed961 100644 +--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c ++++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c +@@ -1335,7 +1335,7 @@ int exynos_g2d_exec_ioctl(struct drm_device *drm_dev, void *data, + /* Let the runqueue know that there is work to do. */ + queue_work(g2d->g2d_workq, &g2d->runqueue_work); + +- if (runqueue_node->async) ++ if (req->async) + goto out; + + wait_for_completion(&runqueue_node->complete); +-- +2.39.2 + diff --git a/queue-5.15/drm-exynos-vidi-fix-a-wrong-error-return.patch b/queue-5.15/drm-exynos-vidi-fix-a-wrong-error-return.patch new file mode 100644 index 00000000000..6fc5fb1fe07 --- /dev/null +++ b/queue-5.15/drm-exynos-vidi-fix-a-wrong-error-return.patch @@ -0,0 +1,38 @@ +From 2ea8de5b55c8c721de657403b8685b833d071fec Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 19 May 2023 08:55:05 +0900 +Subject: drm/exynos: vidi: fix a wrong error return + +From: Inki Dae + +[ Upstream commit 4a059559809fd1ddbf16f847c4d2237309c08edf ] + +Fix a wrong error return by dropping an error return. + +When vidi driver is remvoed, if ctx->raw_edid isn't same as fake_edid_info +then only what we have to is to free ctx->raw_edid so that driver removing +can work correctly - it's not an error case. + +Signed-off-by: Inki Dae +Reviewed-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c +index e5662bdcbbde3..e96436e11a36c 100644 +--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c ++++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c +@@ -468,8 +468,6 @@ static int vidi_remove(struct platform_device *pdev) + if (ctx->raw_edid != (struct edid *)fake_edid_info) { + kfree(ctx->raw_edid); + ctx->raw_edid = NULL; +- +- return -EINVAL; + } + + component_del(&pdev->dev, &vidi_component_ops); +-- +2.39.2 + diff --git a/queue-5.15/drm-radeon-fix-race-condition-uaf-in-radeon_gem_set_.patch b/queue-5.15/drm-radeon-fix-race-condition-uaf-in-radeon_gem_set_.patch new file mode 100644 index 00000000000..57c8fd3aa97 --- /dev/null +++ b/queue-5.15/drm-radeon-fix-race-condition-uaf-in-radeon_gem_set_.patch @@ -0,0 +1,54 @@ +From 35d65ab81b7d2e5e70fa7f1e6d44331dfccd3da9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Jun 2023 15:43:45 +0800 +Subject: drm/radeon: fix race condition UAF in radeon_gem_set_domain_ioctl +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Min Li + +[ Upstream commit 982b173a6c6d9472730c3116051977e05d17c8c5 ] + +Userspace can race to free the gobj(robj converted from), robj should not +be accessed again after drm_gem_object_put, otherwith it will result in +use-after-free. + +Reviewed-by: Christian König +Signed-off-by: Min Li +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/radeon/radeon_gem.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c +index a36a4f2c76b09..57218263ef3b1 100644 +--- a/drivers/gpu/drm/radeon/radeon_gem.c ++++ b/drivers/gpu/drm/radeon/radeon_gem.c +@@ -456,7 +456,6 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, + struct radeon_device *rdev = dev->dev_private; + struct drm_radeon_gem_set_domain *args = data; + struct drm_gem_object *gobj; +- struct radeon_bo *robj; + int r; + + /* for now if someone requests domain CPU - +@@ -469,13 +468,12 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, + up_read(&rdev->exclusive_lock); + return -ENOENT; + } +- robj = gem_to_radeon_bo(gobj); + + r = radeon_gem_set_domain(gobj, args->read_domains, args->write_domain); + + drm_gem_object_put(gobj); + up_read(&rdev->exclusive_lock); +- r = radeon_gem_handle_lockup(robj->rdev, r); ++ r = radeon_gem_handle_lockup(rdev, r); + return r; + } + +-- +2.39.2 + diff --git a/queue-5.15/gpio-allow-per-parent-interrupt-data.patch b/queue-5.15/gpio-allow-per-parent-interrupt-data.patch new file mode 100644 index 00000000000..44e9fe363b8 --- /dev/null +++ b/queue-5.15/gpio-allow-per-parent-interrupt-data.patch @@ -0,0 +1,99 @@ +From 1c36d1b70503fc3e139b5edcbab6a41b665b3897 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Oct 2021 18:58:11 +0100 +Subject: gpio: Allow per-parent interrupt data + +From: Marc Zyngier + +[ Upstream commit cfe6807d82e97e81c3209dca9448f091e1448a57 ] + +The core gpiolib code is able to deal with multiple interrupt parents +for a single gpio irqchip. It however only allows a single piece +of data to be conveyed to all flow handlers (either the gpio_chip +or some other, driver-specific data). + +This means that drivers have to go through some interesting dance +to find the correct context, something that isn't great in interrupt +context (see aebdc8abc9db86e2bd33070fc2f961012fff74b4 for a prime +example). + +Instead, offer an optional way for a pinctrl/gpio driver to provide +an array of pointers which gets used to provide the correct context +to the flow handler. + +Signed-off-by: Marc Zyngier +Signed-off-by: Joey Gouly +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20211026175815.52703-2-joey.gouly@arm.com +Signed-off-by: Linus Walleij +Stable-dep-of: 8c00914e5438 ("gpiolib: Fix GPIO chip IRQ initialization restriction") +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib.c | 9 +++++++-- + include/linux/gpio/driver.h | 19 +++++++++++++++++-- + 2 files changed, 24 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c +index 8c041a8dd9d8f..099fe2e39bd63 100644 +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -1578,9 +1578,14 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, + } + + if (gc->irq.parent_handler) { +- void *data = gc->irq.parent_handler_data ?: gc; +- + for (i = 0; i < gc->irq.num_parents; i++) { ++ void *data; ++ ++ if (gc->irq.per_parent_data) ++ data = gc->irq.parent_handler_data_array[i]; ++ else ++ data = gc->irq.parent_handler_data ?: gc; ++ + /* + * The parent IRQ chip is already using the chip_data + * for this IRQ chip, so our callbacks simply use the +diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h +index 11c26ae7b4fa4..65df2ce96f0b1 100644 +--- a/include/linux/gpio/driver.h ++++ b/include/linux/gpio/driver.h +@@ -168,11 +168,18 @@ struct gpio_irq_chip { + + /** + * @parent_handler_data: ++ * @parent_handler_data_array: + * + * Data associated, and passed to, the handler for the parent +- * interrupt. ++ * interrupt. Can either be a single pointer if @per_parent_data ++ * is false, or an array of @num_parents pointers otherwise. If ++ * @per_parent_data is true, @parent_handler_data_array cannot be ++ * NULL. + */ +- void *parent_handler_data; ++ union { ++ void *parent_handler_data; ++ void **parent_handler_data_array; ++ }; + + /** + * @num_parents: +@@ -203,6 +210,14 @@ struct gpio_irq_chip { + */ + bool threaded; + ++ /** ++ * @per_parent_data: ++ * ++ * True if parent_handler_data_array describes a @num_parents ++ * sized array to be used as parent data. ++ */ ++ bool per_parent_data; ++ + /** + * @init_hw: optional routine to initialize hardware before + * an IRQ chip will be added. This is quite useful when +-- +2.39.2 + diff --git a/queue-5.15/gpio-sifive-add-missing-check-for-platform_get_irq.patch b/queue-5.15/gpio-sifive-add-missing-check-for-platform_get_irq.patch new file mode 100644 index 00000000000..6c56313a58d --- /dev/null +++ b/queue-5.15/gpio-sifive-add-missing-check-for-platform_get_irq.patch @@ -0,0 +1,46 @@ +From 768b196670b5c3fc1c816f42065fa6fdf75979d3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 6 Jun 2023 11:11:59 +0800 +Subject: gpio: sifive: add missing check for platform_get_irq + +From: Jiasheng Jiang + +[ Upstream commit c1bcb976d8feb107ff2c12caaf12ac5e70f44d5f ] + +Add the missing check for platform_get_irq() and return error code +if it fails. + +The returned error code will be dealed with in +builtin_platform_driver(sifive_gpio_driver) and the driver will not +be registered. + +Fixes: f52d6d8b43e5 ("gpio: sifive: To get gpio irq offset from device tree data") +Signed-off-by: Jiasheng Jiang +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpio-sifive.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c +index f41123de69c59..5ffab0fc1b765 100644 +--- a/drivers/gpio/gpio-sifive.c ++++ b/drivers/gpio/gpio-sifive.c +@@ -215,8 +215,12 @@ static int sifive_gpio_probe(struct platform_device *pdev) + return -ENODEV; + } + +- for (i = 0; i < ngpio; i++) +- chip->irq_number[i] = platform_get_irq(pdev, i); ++ for (i = 0; i < ngpio; i++) { ++ ret = platform_get_irq(pdev, i); ++ if (ret < 0) ++ return ret; ++ chip->irq_number[i] = ret; ++ } + + ret = bgpio_init(&chip->gc, dev, 4, + chip->base + SIFIVE_GPIO_INPUT_VAL, +-- +2.39.2 + diff --git a/queue-5.15/gpiolib-fix-gpio-chip-irq-initialization-restriction.patch b/queue-5.15/gpiolib-fix-gpio-chip-irq-initialization-restriction.patch new file mode 100644 index 00000000000..7fd4da3e3d3 --- /dev/null +++ b/queue-5.15/gpiolib-fix-gpio-chip-irq-initialization-restriction.patch @@ -0,0 +1,46 @@ +From fc586b3e562cef9073f9fdc1aaf0106fa287fa82 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 7 Jun 2023 16:18:03 +0800 +Subject: gpiolib: Fix GPIO chip IRQ initialization restriction + +From: Jiawen Wu + +[ Upstream commit 8c00914e5438e3636f26b4f814b3297ae2a1b9ee ] + +In case of gpio-regmap, IRQ chip is added by regmap-irq and associated with +GPIO chip by gpiochip_irqchip_add_domain(). The initialization flag was not +added in gpiochip_irqchip_add_domain(), causing gpiochip_to_irq() to return +-EPROBE_DEFER. + +Fixes: 5467801f1fcb ("gpio: Restrict usage of GPIO chip irq members before initialization") +Signed-off-by: Jiawen Wu +Reviewed-by: Andy Shevchenko +Reviewed-by: Linus Walleij +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c +index 099fe2e39bd63..f9fdd117c654c 100644 +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -1683,6 +1683,14 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc, + gc->to_irq = gpiochip_to_irq; + gc->irq.domain = domain; + ++ /* ++ * Using barrier() here to prevent compiler from reordering ++ * gc->irq.initialized before adding irqdomain. ++ */ ++ barrier(); ++ ++ gc->irq.initialized = true; ++ + return 0; + } + EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain); +-- +2.39.2 + diff --git a/queue-5.15/hid-wacom-add-error-check-to-wacom_parse_and_registe.patch b/queue-5.15/hid-wacom-add-error-check-to-wacom_parse_and_registe.patch new file mode 100644 index 00000000000..c14281c9144 --- /dev/null +++ b/queue-5.15/hid-wacom-add-error-check-to-wacom_parse_and_registe.patch @@ -0,0 +1,44 @@ +From 33a935afd5f58fdb4acc539cbed3523b9ab205d1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Apr 2023 14:47:45 +0300 +Subject: HID: wacom: Add error check to wacom_parse_and_register() + +From: Denis Arefev + +[ Upstream commit 16a9c24f24fbe4564284eb575b18cc20586b9270 ] + + Added a variable check and + transition in case of an error + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Signed-off-by: Denis Arefev +Reviewed-by: Ping Cheng +Signed-off-by: Jiri Kosina +Signed-off-by: Sasha Levin +--- + drivers/hid/wacom_sys.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c +index d29773a799b4f..33e763e746a0b 100644 +--- a/drivers/hid/wacom_sys.c ++++ b/drivers/hid/wacom_sys.c +@@ -2425,8 +2425,13 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) + goto fail_quirks; + } + +- if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) ++ if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) { + error = hid_hw_open(hdev); ++ if (error) { ++ hid_err(hdev, "hw open failed\n"); ++ goto fail_quirks; ++ } ++ } + + wacom_set_shared_values(wacom_wac); + devres_close_group(&hdev->dev, wacom); +-- +2.39.2 + diff --git a/queue-5.15/ieee802154-hwsim-fix-possible-memory-leaks.patch b/queue-5.15/ieee802154-hwsim-fix-possible-memory-leaks.patch new file mode 100644 index 00000000000..2a2f9512aa7 --- /dev/null +++ b/queue-5.15/ieee802154-hwsim-fix-possible-memory-leaks.patch @@ -0,0 +1,50 @@ +From 0526409683e49b60c38d5eb9a906bcb5f9b390b2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 9 Apr 2023 10:20:48 +0800 +Subject: ieee802154: hwsim: Fix possible memory leaks + +From: Chen Aotian + +[ Upstream commit a61675294735570daca3779bd1dbb3715f7232bd ] + +After replacing e->info, it is necessary to free the old einfo. + +Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") +Reviewed-by: Miquel Raynal +Reviewed-by: Alexander Aring +Signed-off-by: Chen Aotian +Link: https://lore.kernel.org/r/20230409022048.61223-1-chenaotian2@163.com +Signed-off-by: Stefan Schmidt +Signed-off-by: Sasha Levin +--- + drivers/net/ieee802154/mac802154_hwsim.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c +index 36f1c5aa98fc6..1ab1ba41c4305 100644 +--- a/drivers/net/ieee802154/mac802154_hwsim.c ++++ b/drivers/net/ieee802154/mac802154_hwsim.c +@@ -522,7 +522,7 @@ static int hwsim_del_edge_nl(struct sk_buff *msg, struct genl_info *info) + static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info) + { + struct nlattr *edge_attrs[MAC802154_HWSIM_EDGE_ATTR_MAX + 1]; +- struct hwsim_edge_info *einfo; ++ struct hwsim_edge_info *einfo, *einfo_old; + struct hwsim_phy *phy_v0; + struct hwsim_edge *e; + u32 v0, v1; +@@ -560,8 +560,10 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info) + list_for_each_entry_rcu(e, &phy_v0->edges, list) { + if (e->endpoint->idx == v1) { + einfo->lqi = lqi; +- rcu_assign_pointer(e->info, einfo); ++ einfo_old = rcu_replace_pointer(e->info, einfo, ++ lockdep_is_held(&hwsim_phys_lock)); + rcu_read_unlock(); ++ kfree_rcu(einfo_old, rcu); + mutex_unlock(&hwsim_phys_lock); + return 0; + } +-- +2.39.2 + diff --git a/queue-5.15/input-soc_button_array-add-invalid-acpi_index-dmi-qu.patch b/queue-5.15/input-soc_button_array-add-invalid-acpi_index-dmi-qu.patch new file mode 100644 index 00000000000..3dbd8dec4d5 --- /dev/null +++ b/queue-5.15/input-soc_button_array-add-invalid-acpi_index-dmi-qu.patch @@ -0,0 +1,91 @@ +From 54fcb36a18124ca5981ce2c7228b504f8a6732a1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 May 2023 11:57:04 -0700 +Subject: Input: soc_button_array - add invalid acpi_index DMI quirk handling + +From: Hans de Goede + +[ Upstream commit 20a99a291d564a559cc2fd013b4824a3bb3f1db7 ] + +Some devices have a wrong entry in their button array which points to +a GPIO which is required in another driver, so soc_button_array must +not claim it. + +A specific example of this is the Lenovo Yoga Book X90F / X90L, +where the PNP0C40 home button entry points to a GPIO which is not +a home button and which is required by the lenovo-yogabook driver. + +Add a DMI quirk table which can specify an ACPI GPIO resource index which +should be skipped; and add an entry for the Lenovo Yoga Book X90F / X90L +to this new DMI quirk table. + +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20230414072116.4497-1-hdegoede@redhat.com +Signed-off-by: Dmitry Torokhov +Signed-off-by: Sasha Levin +--- + drivers/input/misc/soc_button_array.c | 30 +++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c +index 31c02c2019c1c..67a134c8448d2 100644 +--- a/drivers/input/misc/soc_button_array.c ++++ b/drivers/input/misc/soc_button_array.c +@@ -108,6 +108,27 @@ static const struct dmi_system_id dmi_use_low_level_irq[] = { + {} /* Terminating entry */ + }; + ++/* ++ * Some devices have a wrong entry which points to a GPIO which is ++ * required in another driver, so this driver must not claim it. ++ */ ++static const struct dmi_system_id dmi_invalid_acpi_index[] = { ++ { ++ /* ++ * Lenovo Yoga Book X90F / X90L, the PNP0C40 home button entry ++ * points to a GPIO which is not a home button and which is ++ * required by the lenovo-yogabook driver. ++ */ ++ .matches = { ++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), ++ }, ++ .driver_data = (void *)1l, ++ }, ++ {} /* Terminating entry */ ++}; ++ + /* + * Get the Nth GPIO number from the ACPI object. + */ +@@ -137,6 +158,8 @@ soc_button_device_create(struct platform_device *pdev, + struct platform_device *pd; + struct gpio_keys_button *gpio_keys; + struct gpio_keys_platform_data *gpio_keys_pdata; ++ const struct dmi_system_id *dmi_id; ++ int invalid_acpi_index = -1; + int error, gpio, irq; + int n_buttons = 0; + +@@ -154,10 +177,17 @@ soc_button_device_create(struct platform_device *pdev, + gpio_keys = (void *)(gpio_keys_pdata + 1); + n_buttons = 0; + ++ dmi_id = dmi_first_match(dmi_invalid_acpi_index); ++ if (dmi_id) ++ invalid_acpi_index = (long)dmi_id->driver_data; ++ + for (info = button_info; info->name; info++) { + if (info->autorepeat != autorepeat) + continue; + ++ if (info->acpi_index == invalid_acpi_index) ++ continue; ++ + error = soc_button_lookup_gpio(&pdev->dev, info->acpi_index, &gpio, &irq); + if (error || irq < 0) { + /* +-- +2.39.2 + diff --git a/queue-5.15/ipvs-align-inner_mac_header-for-encapsulation.patch b/queue-5.15/ipvs-align-inner_mac_header-for-encapsulation.patch new file mode 100644 index 00000000000..185b6a2df8f --- /dev/null +++ b/queue-5.15/ipvs-align-inner_mac_header-for-encapsulation.patch @@ -0,0 +1,82 @@ +From db23476b2e0fc091a4f274715e014ddf5204354e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 9 Jun 2023 22:58:42 +0200 +Subject: ipvs: align inner_mac_header for encapsulation + +From: Terin Stock + +[ Upstream commit d7fce52fdf96663ddc2eb21afecff3775588612a ] + +When using encapsulation the original packet's headers are copied to the +inner headers. This preserves the space for an inner mac header, which +is not used by the inner payloads for the encapsulation types supported +by IPVS. If a packet is using GUE or GRE encapsulation and needs to be +segmented, flow can be passed to __skb_udp_tunnel_segment() which +calculates a negative tunnel header length. A negative tunnel header +length causes pskb_may_pull() to fail, dropping the packet. + +This can be observed by attaching probes to ip_vs_in_hook(), +__dev_queue_xmit(), and __skb_udp_tunnel_segment(): + + perf probe --add '__dev_queue_xmit skb->inner_mac_header \ + skb->inner_network_header skb->mac_header skb->network_header' + perf probe --add '__skb_udp_tunnel_segment:7 tnl_hlen' + perf probe -m ip_vs --add 'ip_vs_in_hook skb->inner_mac_header \ + skb->inner_network_header skb->mac_header skb->network_header' + +These probes the headers and tunnel header length for packets which +traverse the IPVS encapsulation path. A TCP packet can be forced into +the segmentation path by being smaller than a calculated clamped MSS, +but larger than the advertised MSS. + + probe:ip_vs_in_hook: inner_mac_header=0x0 inner_network_header=0x0 mac_header=0x44 network_header=0x52 + probe:ip_vs_in_hook: inner_mac_header=0x44 inner_network_header=0x52 mac_header=0x44 network_header=0x32 + probe:dev_queue_xmit: inner_mac_header=0x44 inner_network_header=0x52 mac_header=0x44 network_header=0x32 + probe:__skb_udp_tunnel_segment_L7: tnl_hlen=-2 + +When using veth-based encapsulation, the interfaces are set to be +mac-less, which does not preserve space for an inner mac header. This +prevents this issue from occurring. + +In our real-world testing of sending a 32KB file we observed operation +time increasing from ~75ms for veth-based encapsulation to over 1.5s +using IPVS encapsulation due to retries from dropped packets. + +This changeset modifies the packet on the encapsulation path in +ip_vs_tunnel_xmit() and ip_vs_tunnel_xmit_v6() to remove the inner mac +header offset. This fixes UDP segmentation for both encapsulation types, +and corrects the inner headers for any IPIP flows that may use it. + +Fixes: 84c0d5e96f3a ("ipvs: allow tunneling with gue encapsulation") +Signed-off-by: Terin Stock +Acked-by: Julian Anastasov +Acked-by: Simon Horman +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/ipvs/ip_vs_xmit.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c +index d2e5a8f644b80..cd2130e98836b 100644 +--- a/net/netfilter/ipvs/ip_vs_xmit.c ++++ b/net/netfilter/ipvs/ip_vs_xmit.c +@@ -1225,6 +1225,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, + skb->transport_header = skb->network_header; + + skb_set_inner_ipproto(skb, next_protocol); ++ skb_set_inner_mac_header(skb, skb_inner_network_offset(skb)); + + if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GUE) { + bool check = false; +@@ -1373,6 +1374,7 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, + skb->transport_header = skb->network_header; + + skb_set_inner_ipproto(skb, next_protocol); ++ skb_set_inner_mac_header(skb, skb_inner_network_offset(skb)); + + if (tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GUE) { + bool check = false; +-- +2.39.2 + diff --git a/queue-5.15/media-cec-core-don-t-set-last_initiator-if-tx-in-pro.patch b/queue-5.15/media-cec-core-don-t-set-last_initiator-if-tx-in-pro.patch new file mode 100644 index 00000000000..aef73d3c87d --- /dev/null +++ b/queue-5.15/media-cec-core-don-t-set-last_initiator-if-tx-in-pro.patch @@ -0,0 +1,41 @@ +From e3089b7299e43b0dab77b1dcd03744da9c898a35 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Apr 2023 16:07:28 +0100 +Subject: media: cec: core: don't set last_initiator if tx in progress + +From: Hans Verkuil + +[ Upstream commit 73af6c7511038249cad3d5f3b44bf8d78ac0f499 ] + +When a message was received the last_initiator is set to 0xff. +This will force the signal free time for the next transmit +to that for a new initiator. However, if a new transmit is +already in progress, then don't set last_initiator, since +that's the initiator of the current transmit. Overwriting +this would cause the signal free time of a following transmit +to be that of the new initiator instead of a next transmit. + +Signed-off-by: Hans Verkuil +Signed-off-by: Mauro Carvalho Chehab +Signed-off-by: Sasha Levin +--- + drivers/media/cec/core/cec-adap.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c +index 67776a0d31e8c..99ede1417d727 100644 +--- a/drivers/media/cec/core/cec-adap.c ++++ b/drivers/media/cec/core/cec-adap.c +@@ -1086,7 +1086,8 @@ void cec_received_msg_ts(struct cec_adapter *adap, + mutex_lock(&adap->lock); + dprintk(2, "%s: %*ph\n", __func__, msg->len, msg->msg); + +- adap->last_initiator = 0xff; ++ if (!adap->transmit_in_progress) ++ adap->last_initiator = 0xff; + + /* Check if this message was for us (directed or broadcast). */ + if (!cec_msg_is_broadcast(msg)) +-- +2.39.2 + diff --git a/queue-5.15/memfd-check-for-non-null-file_seals-in-memfd_create-.patch b/queue-5.15/memfd-check-for-non-null-file_seals-in-memfd_create-.patch new file mode 100644 index 00000000000..0e639a5ac4b --- /dev/null +++ b/queue-5.15/memfd-check-for-non-null-file_seals-in-memfd_create-.patch @@ -0,0 +1,42 @@ +From 1ca0db34e8a081f5e10f55d4866410143ce976e5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 7 Jun 2023 15:24:27 +0200 +Subject: memfd: check for non-NULL file_seals in memfd_create() syscall + +From: Roberto Sassu + +[ Upstream commit 935d44acf621aa0688fef8312dec3e5940f38f4e ] + +Ensure that file_seals is non-NULL before using it in the memfd_create() +syscall. One situation in which memfd_file_seals_ptr() could return a +NULL pointer when CONFIG_SHMEM=n, oopsing the kernel. + +Link: https://lkml.kernel.org/r/20230607132427.2867435-1-roberto.sassu@huaweicloud.com +Fixes: 47b9012ecdc7 ("shmem: add sealing support to hugetlb-backed memfd") +Signed-off-by: Roberto Sassu +Cc: Marc-Andr Lureau +Cc: Mike Kravetz +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + mm/memfd.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/mm/memfd.c b/mm/memfd.c +index 475d095dd7f53..a73af8be9c285 100644 +--- a/mm/memfd.c ++++ b/mm/memfd.c +@@ -330,7 +330,8 @@ SYSCALL_DEFINE2(memfd_create, + + if (flags & MFD_ALLOW_SEALING) { + file_seals = memfd_file_seals_ptr(file); +- *file_seals &= ~F_SEAL_SEAL; ++ if (file_seals) ++ *file_seals &= ~F_SEAL_SEAL; + } + + fd_install(fd, file); +-- +2.39.2 + diff --git a/queue-5.15/mmc-meson-gx-fix-deferred-probing.patch b/queue-5.15/mmc-meson-gx-fix-deferred-probing.patch new file mode 100644 index 00000000000..f094a70bdee --- /dev/null +++ b/queue-5.15/mmc-meson-gx-fix-deferred-probing.patch @@ -0,0 +1,45 @@ +From 83c04755733ff8e8e9f832b8ff3f360d2419f424 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:12 +0300 +Subject: mmc: meson-gx: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit b8ada54fa1b83f3b6480d4cced71354301750153 ] + +The driver overrides the error codes and IRQ0 returned by platform_get_irq() +to -EINVAL, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the error +codes upstream. Since commit ce753ad1549c ("platform: finally disallow IRQ0 +in platform_get_irq() and its ilk") IRQ0 is no longer returned by those APIs, +so we now can safely ignore it... + +Fixes: cbcaac6d7dd2 ("mmc: meson-gx-mmc: Fix platform_get_irq's error checking") +Cc: stable@vger.kernel.org # v5.19+ +Signed-off-by: Sergey Shtylyov +Reviewed-by: Neil Armstrong +Link: https://lore.kernel.org/r/20230617203622.6812-3-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/meson-gx-mmc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c +index 39640906d3334..287705729064c 100644 +--- a/drivers/mmc/host/meson-gx-mmc.c ++++ b/drivers/mmc/host/meson-gx-mmc.c +@@ -1179,8 +1179,8 @@ static int meson_mmc_probe(struct platform_device *pdev) + } + + host->irq = platform_get_irq(pdev, 0); +- if (host->irq <= 0) { +- ret = -EINVAL; ++ if (host->irq < 0) { ++ ret = host->irq; + goto free_host; + } + +-- +2.39.2 + diff --git a/queue-5.15/mmc-mtk-sd-fix-deferred-probing.patch b/queue-5.15/mmc-mtk-sd-fix-deferred-probing.patch new file mode 100644 index 00000000000..0ad411a80bf --- /dev/null +++ b/queue-5.15/mmc-mtk-sd-fix-deferred-probing.patch @@ -0,0 +1,39 @@ +From 5bb79a3db4cae0ae4e483bc1ab2c289247161cdb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:13 +0300 +Subject: mmc: mtk-sd: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit 0c4dc0f054891a2cbde0426b0c0fdf232d89f47f ] + +The driver overrides the error codes returned by platform_get_irq() to +-EINVAL, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: 208489032bdd ("mmc: mediatek: Add Mediatek MMC driver") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-4-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/mtk-sd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c +index 9871c19d2b4e4..6d0fc247bddb3 100644 +--- a/drivers/mmc/host/mtk-sd.c ++++ b/drivers/mmc/host/mtk-sd.c +@@ -2525,7 +2525,7 @@ static int msdc_drv_probe(struct platform_device *pdev) + + host->irq = platform_get_irq(pdev, 0); + if (host->irq < 0) { +- ret = -EINVAL; ++ ret = host->irq; + goto host_free; + } + +-- +2.39.2 + diff --git a/queue-5.15/mmc-mvsdio-fix-deferred-probing.patch b/queue-5.15/mmc-mvsdio-fix-deferred-probing.patch new file mode 100644 index 00000000000..eb693572b72 --- /dev/null +++ b/queue-5.15/mmc-mvsdio-fix-deferred-probing.patch @@ -0,0 +1,39 @@ +From aa140208137c2969384ece8c66e50b3c92788a04 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:14 +0300 +Subject: mmc: mvsdio: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit 8d84064da0d4672e74f984e8710f27881137472c ] + +The driver overrides the error codes returned by platform_get_irq() to +-ENXIO, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-5-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/mvsdio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c +index 629efbe639c4f..b4f6a0a2fcb51 100644 +--- a/drivers/mmc/host/mvsdio.c ++++ b/drivers/mmc/host/mvsdio.c +@@ -704,7 +704,7 @@ static int mvsd_probe(struct platform_device *pdev) + } + irq = platform_get_irq(pdev, 0); + if (irq < 0) +- return -ENXIO; ++ return irq; + + mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev); + if (!mmc) { +-- +2.39.2 + diff --git a/queue-5.15/mmc-omap-fix-deferred-probing.patch b/queue-5.15/mmc-omap-fix-deferred-probing.patch new file mode 100644 index 00000000000..9c3d7b6634b --- /dev/null +++ b/queue-5.15/mmc-omap-fix-deferred-probing.patch @@ -0,0 +1,39 @@ +From 6bf74abacb64fc0c7f1a389ebcf22e5b5c6ab1d2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:15 +0300 +Subject: mmc: omap: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit aedf4ba1ad00aaa94c1b66c73ecaae95e2564b95 ] + +The driver overrides the error codes returned by platform_get_irq() to +-ENXIO, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-6-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/omap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c +index 5e5af34090f1b..ecf2a68d0e846 100644 +--- a/drivers/mmc/host/omap.c ++++ b/drivers/mmc/host/omap.c +@@ -1343,7 +1343,7 @@ static int mmc_omap_probe(struct platform_device *pdev) + + irq = platform_get_irq(pdev, 0); + if (irq < 0) +- return -ENXIO; ++ return irq; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + host->virt_base = devm_ioremap_resource(&pdev->dev, res); +-- +2.39.2 + diff --git a/queue-5.15/mmc-omap_hsmmc-fix-deferred-probing.patch b/queue-5.15/mmc-omap_hsmmc-fix-deferred-probing.patch new file mode 100644 index 00000000000..a2732c2bb76 --- /dev/null +++ b/queue-5.15/mmc-omap_hsmmc-fix-deferred-probing.patch @@ -0,0 +1,44 @@ +From 92ca628521a221afa910e071151155727b5722b4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:16 +0300 +Subject: mmc: omap_hsmmc: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit fb51b74a57859b707c3e8055ed0c25a7ca4f6a29 ] + +The driver overrides the error codes returned by platform_get_irq() to +-ENXIO, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-7-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/omap_hsmmc.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c +index eb0bd46b7e81e..500c906413a7f 100644 +--- a/drivers/mmc/host/omap_hsmmc.c ++++ b/drivers/mmc/host/omap_hsmmc.c +@@ -1832,9 +1832,11 @@ static int omap_hsmmc_probe(struct platform_device *pdev) + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); +- irq = platform_get_irq(pdev, 0); +- if (res == NULL || irq < 0) ++ if (!res) + return -ENXIO; ++ irq = platform_get_irq(pdev, 0); ++ if (irq < 0) ++ return irq; + + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) +-- +2.39.2 + diff --git a/queue-5.15/mmc-owl-fix-deferred-probing.patch b/queue-5.15/mmc-owl-fix-deferred-probing.patch new file mode 100644 index 00000000000..79b737649fc --- /dev/null +++ b/queue-5.15/mmc-owl-fix-deferred-probing.patch @@ -0,0 +1,39 @@ +From ad92c2be83716e1c85ea2db9394829da5ff10148 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:17 +0300 +Subject: mmc: owl: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit 3c482e1e830d79b9be8afb900a965135c01f7893 ] + +The driver overrides the error codes returned by platform_get_irq() to +-EINVAL, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: ff65ffe46d28 ("mmc: Add Actions Semi Owl SoCs SD/MMC driver") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-8-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/owl-mmc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/owl-mmc.c b/drivers/mmc/host/owl-mmc.c +index 3dc143b039397..679b8b0b310e5 100644 +--- a/drivers/mmc/host/owl-mmc.c ++++ b/drivers/mmc/host/owl-mmc.c +@@ -638,7 +638,7 @@ static int owl_mmc_probe(struct platform_device *pdev) + + owl_host->irq = platform_get_irq(pdev, 0); + if (owl_host->irq < 0) { +- ret = -EINVAL; ++ ret = owl_host->irq; + goto err_release_channel; + } + +-- +2.39.2 + diff --git a/queue-5.15/mmc-sdhci-acpi-fix-deferred-probing.patch b/queue-5.15/mmc-sdhci-acpi-fix-deferred-probing.patch new file mode 100644 index 00000000000..9b91b626d84 --- /dev/null +++ b/queue-5.15/mmc-sdhci-acpi-fix-deferred-probing.patch @@ -0,0 +1,40 @@ +From ae2dfb42191b9e708b006a7f0bf92936c5b37b61 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:18 +0300 +Subject: mmc: sdhci-acpi: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit b465dea5e1540c7d7b5211adaf94926980d3014b ] + +The driver overrides the error codes returned by platform_get_irq() to +-EINVAL, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: 1b7ba57ecc86 ("mmc: sdhci-acpi: Handle return value of platform_get_irq") +Signed-off-by: Sergey Shtylyov +Acked-by: Adrian Hunter +Link: https://lore.kernel.org/r/20230617203622.6812-9-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/sdhci-acpi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c +index 8fe65f172a611..f4e15eef70454 100644 +--- a/drivers/mmc/host/sdhci-acpi.c ++++ b/drivers/mmc/host/sdhci-acpi.c +@@ -910,7 +910,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev) + host->ops = &sdhci_acpi_ops_dflt; + host->irq = platform_get_irq(pdev, 0); + if (host->irq < 0) { +- err = -EINVAL; ++ err = host->irq; + goto err_free; + } + +-- +2.39.2 + diff --git a/queue-5.15/mmc-sh_mmcif-fix-deferred-probing.patch b/queue-5.15/mmc-sh_mmcif-fix-deferred-probing.patch new file mode 100644 index 00000000000..4cabddd1726 --- /dev/null +++ b/queue-5.15/mmc-sh_mmcif-fix-deferred-probing.patch @@ -0,0 +1,39 @@ +From 1ee61842fa8ce21c22c61156089e290867083edf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:20 +0300 +Subject: mmc: sh_mmcif: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit 5b067d7f855c61df7f8e2e8ccbcee133c282415e ] + +The driver overrides the error codes returned by platform_get_irq() to +-ENXIO, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating the +error codes upstream. + +Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-11-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/sh_mmcif.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c +index bcc595c70a9fb..e12fe29b275c2 100644 +--- a/drivers/mmc/host/sh_mmcif.c ++++ b/drivers/mmc/host/sh_mmcif.c +@@ -1398,7 +1398,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) + irq[0] = platform_get_irq(pdev, 0); + irq[1] = platform_get_irq_optional(pdev, 1); + if (irq[0] < 0) +- return -ENXIO; ++ return irq[0]; + + reg = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(reg)) +-- +2.39.2 + diff --git a/queue-5.15/mmc-usdhi60rol0-fix-deferred-probing.patch b/queue-5.15/mmc-usdhi60rol0-fix-deferred-probing.patch new file mode 100644 index 00000000000..c1b93e710e3 --- /dev/null +++ b/queue-5.15/mmc-usdhi60rol0-fix-deferred-probing.patch @@ -0,0 +1,43 @@ +From 7f9494da876c2975036e95f50d3833ca426b6cbb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 23:36:22 +0300 +Subject: mmc: usdhi60rol0: fix deferred probing + +From: Sergey Shtylyov + +[ Upstream commit 413db499730248431c1005b392e8ed82c4fa19bf ] + +The driver overrides the error codes returned by platform_get_irq_byname() +to -ENODEV, so if it returns -EPROBE_DEFER, the driver will fail the probe +permanently instead of the deferred probing. Switch to propagating error +codes upstream. + +Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq") +Signed-off-by: Sergey Shtylyov +Link: https://lore.kernel.org/r/20230617203622.6812-13-s.shtylyov@omp.ru +Signed-off-by: Ulf Hansson +Signed-off-by: Sasha Levin +--- + drivers/mmc/host/usdhi6rol0.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c +index 99515be6e5e57..2032e4e1ee68b 100644 +--- a/drivers/mmc/host/usdhi6rol0.c ++++ b/drivers/mmc/host/usdhi6rol0.c +@@ -1757,8 +1757,10 @@ static int usdhi6_probe(struct platform_device *pdev) + irq_cd = platform_get_irq_byname(pdev, "card detect"); + irq_sd = platform_get_irq_byname(pdev, "data"); + irq_sdio = platform_get_irq_byname(pdev, "SDIO"); +- if (irq_sd < 0 || irq_sdio < 0) +- return -ENODEV; ++ if (irq_sd < 0) ++ return irq_sd; ++ if (irq_sdio < 0) ++ return irq_sdio; + + mmc = mmc_alloc_host(sizeof(struct usdhi6_host), dev); + if (!mmc) +-- +2.39.2 + diff --git a/queue-5.15/net-dsa-mt7530-fix-handling-of-bpdus-on-mt7530-switc.patch b/queue-5.15/net-dsa-mt7530-fix-handling-of-bpdus-on-mt7530-switc.patch new file mode 100644 index 00000000000..66685d80c73 --- /dev/null +++ b/queue-5.15/net-dsa-mt7530-fix-handling-of-bpdus-on-mt7530-switc.patch @@ -0,0 +1,71 @@ +From 2e05c86b050dffb6fd8178859cd8e0baf3c97a0f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 09:26:46 +0300 +Subject: net: dsa: mt7530: fix handling of BPDUs on MT7530 switch +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Arınç ÜNAL + +[ Upstream commit d7c66073559386b836bded7cdc8b66ee5c049129 ] + +BPDUs are link-local frames, therefore they must be trapped to the CPU +port. Currently, the MT7530 switch treats BPDUs as regular multicast +frames, therefore flooding them to user ports. To fix this, set BPDUs to be +trapped to the CPU port. Group this on mt7530_setup() and +mt7531_setup_common() into mt753x_trap_frames() and call that. + +Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") +Signed-off-by: Arınç ÜNAL +Reviewed-by: Vladimir Oltean +Reviewed-by: Russell King (Oracle) +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/dsa/mt7530.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c +index 4aa3d0cba7b84..f74d9fbd08178 100644 +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -993,6 +993,14 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) + mutex_unlock(&priv->reg_mutex); + } + ++static void ++mt753x_trap_frames(struct mt7530_priv *priv) ++{ ++ /* Trap BPDUs to the CPU port(s) */ ++ mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, ++ MT753X_BPDU_CPU_ONLY); ++} ++ + static int + mt753x_cpu_port_enable(struct dsa_switch *ds, int port) + { +@@ -2194,6 +2202,8 @@ mt7530_setup(struct dsa_switch *ds) + + priv->p6_interface = PHY_INTERFACE_MODE_NA; + ++ mt753x_trap_frames(priv); ++ + /* Enable and reset MIB counters */ + mt7530_mib_reset(ds); + +@@ -2300,8 +2310,8 @@ mt7531_setup_common(struct dsa_switch *ds) + BIT(cpu_dp->index)); + break; + } +- mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, +- MT753X_BPDU_CPU_ONLY); ++ ++ mt753x_trap_frames(priv); + + /* Enable and reset MIB counters */ + mt7530_mib_reset(ds); +-- +2.39.2 + diff --git a/queue-5.15/net-dsa-mt7530-fix-trapping-frames-on-non-mt7621-soc.patch b/queue-5.15/net-dsa-mt7530-fix-trapping-frames-on-non-mt7621-soc.patch new file mode 100644 index 00000000000..f1ff938303a --- /dev/null +++ b/queue-5.15/net-dsa-mt7530-fix-trapping-frames-on-non-mt7621-soc.patch @@ -0,0 +1,44 @@ +From 9557b076fe0912eaf972c3ef7bf95e497d99d78f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 09:26:45 +0300 +Subject: net: dsa: mt7530: fix trapping frames on non-MT7621 SoC MT7530 switch +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Arınç ÜNAL + +[ Upstream commit 4ae90f90e4909e3014e2dc6a0627964617a7b824 ] + +All MT7530 switch IP variants share the MT7530_MFC register, but the +current driver only writes it for the switch variant that is integrated in +the MT7621 SoC. Modify the code to include all MT7530 derivatives. + +Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") +Suggested-by: Vladimir Oltean +Signed-off-by: Arınç ÜNAL +Reviewed-by: Vladimir Oltean +Reviewed-by: Russell King (Oracle) +Reviewed-by: Florian Fainelli +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/dsa/mt7530.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c +index 4ec598efc3332..4aa3d0cba7b84 100644 +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -1015,7 +1015,7 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port) + UNU_FFP(BIT(port))); + + /* Set CPU port number */ +- if (priv->id == ID_MT7621) ++ if (priv->id == ID_MT7530 || priv->id == ID_MT7621) + mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port)); + + /* CPU port gets connected to all user ports of +-- +2.39.2 + diff --git a/queue-5.15/net-qca_spi-avoid-high-load-if-qca7000-is-not-availa.patch b/queue-5.15/net-qca_spi-avoid-high-load-if-qca7000-is-not-availa.patch new file mode 100644 index 00000000000..6b37787a2e7 --- /dev/null +++ b/queue-5.15/net-qca_spi-avoid-high-load-if-qca7000-is-not-availa.patch @@ -0,0 +1,40 @@ +From d4ff0f4ed6e74ad039972f6b8b214d5c3bb43fb6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 14 Jun 2023 23:06:56 +0200 +Subject: net: qca_spi: Avoid high load if QCA7000 is not available + +From: Stefan Wahren + +[ Upstream commit 92717c2356cb62c89e8a3dc37cbbab2502562524 ] + +In case the QCA7000 is not available via SPI (e.g. in reset), +the driver will cause a high load. The reason for this is +that the synchronization is never finished and schedule() +is never called. Since the synchronization is not timing +critical, it's safe to drop this from the scheduling condition. + +Signed-off-by: Stefan Wahren +Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000") +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/qualcomm/qca_spi.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c +index 8427fe1b8fd1c..2205bb437e680 100644 +--- a/drivers/net/ethernet/qualcomm/qca_spi.c ++++ b/drivers/net/ethernet/qualcomm/qca_spi.c +@@ -582,8 +582,7 @@ qcaspi_spi_thread(void *data) + while (!kthread_should_stop()) { + set_current_state(TASK_INTERRUPTIBLE); + if ((qca->intr_req == qca->intr_svc) && +- (qca->txr.skb[qca->txr.head] == NULL) && +- (qca->sync == QCASPI_SYNC_READY)) ++ !qca->txr.skb[qca->txr.head]) + schedule(); + + set_current_state(TASK_RUNNING); +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nf_tables-add-nft_trans_prepare_error-to-d.patch b/queue-5.15/netfilter-nf_tables-add-nft_trans_prepare_error-to-d.patch new file mode 100644 index 00000000000..15cd933f1b6 --- /dev/null +++ b/queue-5.15/netfilter-nf_tables-add-nft_trans_prepare_error-to-d.patch @@ -0,0 +1,177 @@ +From 5197b5e0845db7a9aced4e57eba704d762a1bc49 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 14:45:26 +0200 +Subject: netfilter: nf_tables: add NFT_TRANS_PREPARE_ERROR to deal with bound + set/chain + +From: Pablo Neira Ayuso + +[ Upstream commit 26b5a5712eb85e253724e56a54c17f8519bd8e4e ] + +Add a new state to deal with rule expressions deactivation from the +newrule error path, otherwise the anonymous set remains in the list in +inactive state for the next generation. Mark the set/chain transaction +as unbound so the abort path releases this object, set it as inactive in +the next generation so it is not reachable anymore from this transaction +and reference counter is dropped. + +Fixes: 1240eb93f061 ("netfilter: nf_tables: incorrect error path handling with NFT_MSG_NEWRULE") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + include/net/netfilter/nf_tables.h | 2 ++ + net/netfilter/nf_tables_api.c | 45 ++++++++++++++++++++++++++----- + net/netfilter/nft_immediate.c | 3 +++ + 3 files changed, 43 insertions(+), 7 deletions(-) + +diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h +index 1a879140f9966..603c156da210b 100644 +--- a/include/net/netfilter/nf_tables.h ++++ b/include/net/netfilter/nf_tables.h +@@ -863,6 +863,7 @@ struct nft_expr_type { + + enum nft_trans_phase { + NFT_TRANS_PREPARE, ++ NFT_TRANS_PREPARE_ERROR, + NFT_TRANS_ABORT, + NFT_TRANS_COMMIT, + NFT_TRANS_RELEASE +@@ -1041,6 +1042,7 @@ int nft_setelem_validate(const struct nft_ctx *ctx, struct nft_set *set, + struct nft_set_elem *elem); + int nft_set_catchall_validate(const struct nft_ctx *ctx, struct nft_set *set); + int nf_tables_bind_chain(const struct nft_ctx *ctx, struct nft_chain *chain); ++void nf_tables_unbind_chain(const struct nft_ctx *ctx, struct nft_chain *chain); + + enum nft_chain_types { + NFT_CHAIN_T_DEFAULT = 0, +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index 83828c530b439..120b885fb44a6 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -171,7 +171,8 @@ static void nft_trans_destroy(struct nft_trans *trans) + kfree(trans); + } + +-static void nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set) ++static void __nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set, ++ bool bind) + { + struct nftables_pernet *nft_net; + struct net *net = ctx->net; +@@ -185,17 +186,28 @@ static void nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set) + switch (trans->msg_type) { + case NFT_MSG_NEWSET: + if (nft_trans_set(trans) == set) +- nft_trans_set_bound(trans) = true; ++ nft_trans_set_bound(trans) = bind; + break; + case NFT_MSG_NEWSETELEM: + if (nft_trans_elem_set(trans) == set) +- nft_trans_elem_set_bound(trans) = true; ++ nft_trans_elem_set_bound(trans) = bind; + break; + } + } + } + +-static void nft_chain_trans_bind(const struct nft_ctx *ctx, struct nft_chain *chain) ++static void nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set) ++{ ++ return __nft_set_trans_bind(ctx, set, true); ++} ++ ++static void nft_set_trans_unbind(const struct nft_ctx *ctx, struct nft_set *set) ++{ ++ return __nft_set_trans_bind(ctx, set, false); ++} ++ ++static void __nft_chain_trans_bind(const struct nft_ctx *ctx, ++ struct nft_chain *chain, bool bind) + { + struct nftables_pernet *nft_net; + struct net *net = ctx->net; +@@ -209,16 +221,22 @@ static void nft_chain_trans_bind(const struct nft_ctx *ctx, struct nft_chain *ch + switch (trans->msg_type) { + case NFT_MSG_NEWCHAIN: + if (nft_trans_chain(trans) == chain) +- nft_trans_chain_bound(trans) = true; ++ nft_trans_chain_bound(trans) = bind; + break; + case NFT_MSG_NEWRULE: + if (trans->ctx.chain == chain) +- nft_trans_rule_bound(trans) = true; ++ nft_trans_rule_bound(trans) = bind; + break; + } + } + } + ++static void nft_chain_trans_bind(const struct nft_ctx *ctx, ++ struct nft_chain *chain) ++{ ++ __nft_chain_trans_bind(ctx, chain, true); ++} ++ + int nf_tables_bind_chain(const struct nft_ctx *ctx, struct nft_chain *chain) + { + if (!nft_chain_binding(chain)) +@@ -237,6 +255,11 @@ int nf_tables_bind_chain(const struct nft_ctx *ctx, struct nft_chain *chain) + return 0; + } + ++void nf_tables_unbind_chain(const struct nft_ctx *ctx, struct nft_chain *chain) ++{ ++ __nft_chain_trans_bind(ctx, chain, false); ++} ++ + static int nft_netdev_register_hooks(struct net *net, + struct list_head *hook_list) + { +@@ -3612,7 +3635,7 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info, + if (flow) + nft_flow_rule_destroy(flow); + err_release_rule: +- nft_rule_expr_deactivate(&ctx, rule, NFT_TRANS_PREPARE); ++ nft_rule_expr_deactivate(&ctx, rule, NFT_TRANS_PREPARE_ERROR); + nf_tables_rule_destroy(&ctx, rule); + err_release_expr: + for (i = 0; i < n; i++) { +@@ -4893,6 +4916,13 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set, + enum nft_trans_phase phase) + { + switch (phase) { ++ case NFT_TRANS_PREPARE_ERROR: ++ nft_set_trans_unbind(ctx, set); ++ if (nft_set_is_anonymous(set)) ++ nft_deactivate_next(ctx->net, set); ++ ++ set->use--; ++ break; + case NFT_TRANS_PREPARE: + if (nft_set_is_anonymous(set)) + nft_deactivate_next(ctx->net, set); +@@ -7337,6 +7367,7 @@ void nf_tables_deactivate_flowtable(const struct nft_ctx *ctx, + enum nft_trans_phase phase) + { + switch (phase) { ++ case NFT_TRANS_PREPARE_ERROR: + case NFT_TRANS_PREPARE: + case NFT_TRANS_ABORT: + case NFT_TRANS_RELEASE: +diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c +index 9d4248898ce4b..6b0efab4fad09 100644 +--- a/net/netfilter/nft_immediate.c ++++ b/net/netfilter/nft_immediate.c +@@ -150,6 +150,9 @@ static void nft_immediate_deactivate(const struct nft_ctx *ctx, + nft_rule_expr_deactivate(&chain_ctx, rule, phase); + + switch (phase) { ++ case NFT_TRANS_PREPARE_ERROR: ++ nf_tables_unbind_chain(ctx, chain); ++ fallthrough; + case NFT_TRANS_PREPARE: + nft_deactivate_next(ctx->net, chain); + break; +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nf_tables-disallow-element-updates-of-boun.patch b/queue-5.15/netfilter-nf_tables-disallow-element-updates-of-boun.patch new file mode 100644 index 00000000000..8fdd822d989 --- /dev/null +++ b/queue-5.15/netfilter-nf_tables-disallow-element-updates-of-boun.patch @@ -0,0 +1,49 @@ +From d89528621fe09eb3a609bd3459bf1ee07fa11bce Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 15:20:16 +0200 +Subject: netfilter: nf_tables: disallow element updates of bound anonymous + sets + +From: Pablo Neira Ayuso + +[ Upstream commit c88c535b592d3baeee74009f3eceeeaf0fdd5e1b ] + +Anonymous sets come with NFT_SET_CONSTANT from userspace. Although API +allows to create anonymous sets without NFT_SET_CONSTANT, it makes no +sense to allow to add and to delete elements for bound anonymous sets. + +Fixes: 96518518cc41 ("netfilter: add nftables") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nf_tables_api.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index 120b885fb44a6..c4e3aaeeb795c 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -6332,7 +6332,8 @@ static int nf_tables_newsetelem(struct sk_buff *skb, + if (IS_ERR(set)) + return PTR_ERR(set); + +- if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT) ++ if (!list_empty(&set->bindings) && ++ (set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS))) + return -EBUSY; + + nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); +@@ -6602,7 +6603,9 @@ static int nf_tables_delsetelem(struct sk_buff *skb, + set = nft_set_lookup(table, nla[NFTA_SET_ELEM_LIST_SET], genmask); + if (IS_ERR(set)) + return PTR_ERR(set); +- if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT) ++ ++ if (!list_empty(&set->bindings) && ++ (set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS))) + return -EBUSY; + + nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nf_tables-disallow-updates-of-anonymous-se.patch b/queue-5.15/netfilter-nf_tables-disallow-updates-of-anonymous-se.patch new file mode 100644 index 00000000000..89be3d1f4cd --- /dev/null +++ b/queue-5.15/netfilter-nf_tables-disallow-updates-of-anonymous-se.patch @@ -0,0 +1,36 @@ +From 8886b698cea927ec5b56acaf3b448b832c0c0a72 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 15:22:01 +0200 +Subject: netfilter: nf_tables: disallow updates of anonymous sets + +From: Pablo Neira Ayuso + +[ Upstream commit b770283c98e0eee9133c47bc03b6cc625dc94723 ] + +Disallow updates of set timeout and garbage collection parameters for +anonymous sets. + +Fixes: 123b99619cca ("netfilter: nf_tables: honor set timeout and garbage collection updates") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nf_tables_api.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index 66328326ec05e..826bd961d90c1 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -4628,6 +4628,9 @@ static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info, + if (info->nlh->nlmsg_flags & NLM_F_REPLACE) + return -EOPNOTSUPP; + ++ if (nft_set_is_anonymous(set)) ++ return -EOPNOTSUPP; ++ + err = nft_set_expr_alloc(&ctx, set, nla, exprs, &num_exprs, flags); + if (err < 0) + return err; +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nf_tables-fix-chain-binding-transaction-lo.patch b/queue-5.15/netfilter-nf_tables-fix-chain-binding-transaction-lo.patch new file mode 100644 index 00000000000..298675a2ebc --- /dev/null +++ b/queue-5.15/netfilter-nf_tables-fix-chain-binding-transaction-lo.patch @@ -0,0 +1,438 @@ +From 2204ea5ebc590149ebd9784fbe6aa877ca383431 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 14:45:22 +0200 +Subject: netfilter: nf_tables: fix chain binding transaction logic + +From: Pablo Neira Ayuso + +[ Upstream commit 4bedf9eee016286c835e3d8fa981ddece5338795 ] + +Add bound flag to rule and chain transactions as in 6a0a8d10a366 +("netfilter: nf_tables: use-after-free in failing rule with bound set") +to skip them in case that the chain is already bound from the abort +path. + +This patch fixes an imbalance in the chain use refcnt that triggers a +WARN_ON on the table and chain destroy path. + +This patch also disallows nested chain bindings, which is not +supported from userspace. + +The logic to deal with chain binding in nft_data_hold() and +nft_data_release() is not correct. The NFT_TRANS_PREPARE state needs a +special handling in case a chain is bound but next expressions in the +same rule fail to initialize as described by 1240eb93f061 ("netfilter: +nf_tables: incorrect error path handling with NFT_MSG_NEWRULE"). + +The chain is left bound if rule construction fails, so the objects +stored in this chain (and the chain itself) are released by the +transaction records from the abort path, follow up patch ("netfilter: +nf_tables: add NFT_TRANS_PREPARE_ERROR to deal with bound set/chain") +completes this error handling. + +When deleting an existing rule, chain bound flag is set off so the +rule expression .destroy path releases the objects. + +Fixes: d0e2c7de92c7 ("netfilter: nf_tables: add NFT_CHAIN_BINDING") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + include/net/netfilter/nf_tables.h | 21 +++++++- + net/netfilter/nf_tables_api.c | 86 +++++++++++++++++++----------- + net/netfilter/nft_immediate.c | 87 +++++++++++++++++++++++++++---- + 3 files changed, 153 insertions(+), 41 deletions(-) + +diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h +index 8bac5a5ca0f11..1a879140f9966 100644 +--- a/include/net/netfilter/nf_tables.h ++++ b/include/net/netfilter/nf_tables.h +@@ -968,7 +968,10 @@ static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule) + return (void *)&rule->data[rule->dlen]; + } + +-void nf_tables_rule_release(const struct nft_ctx *ctx, struct nft_rule *rule); ++void nft_rule_expr_activate(const struct nft_ctx *ctx, struct nft_rule *rule); ++void nft_rule_expr_deactivate(const struct nft_ctx *ctx, struct nft_rule *rule, ++ enum nft_trans_phase phase); ++void nf_tables_rule_destroy(const struct nft_ctx *ctx, struct nft_rule *rule); + + static inline void nft_set_elem_update_expr(const struct nft_set_ext *ext, + struct nft_regs *regs, +@@ -1037,6 +1040,7 @@ int nft_setelem_validate(const struct nft_ctx *ctx, struct nft_set *set, + const struct nft_set_iter *iter, + struct nft_set_elem *elem); + int nft_set_catchall_validate(const struct nft_ctx *ctx, struct nft_set *set); ++int nf_tables_bind_chain(const struct nft_ctx *ctx, struct nft_chain *chain); + + enum nft_chain_types { + NFT_CHAIN_T_DEFAULT = 0, +@@ -1073,11 +1077,17 @@ int nft_chain_validate_dependency(const struct nft_chain *chain, + int nft_chain_validate_hooks(const struct nft_chain *chain, + unsigned int hook_flags); + ++static inline bool nft_chain_binding(const struct nft_chain *chain) ++{ ++ return chain->flags & NFT_CHAIN_BINDING; ++} ++ + static inline bool nft_chain_is_bound(struct nft_chain *chain) + { + return (chain->flags & NFT_CHAIN_BINDING) && chain->bound; + } + ++int nft_chain_add(struct nft_table *table, struct nft_chain *chain); + void nft_chain_del(struct nft_chain *chain); + void nf_tables_chain_destroy(struct nft_ctx *ctx); + +@@ -1508,6 +1518,7 @@ struct nft_trans_rule { + struct nft_rule *rule; + struct nft_flow_rule *flow; + u32 rule_id; ++ bool bound; + }; + + #define nft_trans_rule(trans) \ +@@ -1516,6 +1527,8 @@ struct nft_trans_rule { + (((struct nft_trans_rule *)trans->data)->flow) + #define nft_trans_rule_id(trans) \ + (((struct nft_trans_rule *)trans->data)->rule_id) ++#define nft_trans_rule_bound(trans) \ ++ (((struct nft_trans_rule *)trans->data)->bound) + + struct nft_trans_set { + struct nft_set *set; +@@ -1540,13 +1553,17 @@ struct nft_trans_set { + (((struct nft_trans_set *)trans->data)->gc_int) + + struct nft_trans_chain { ++ struct nft_chain *chain; + bool update; + char *name; + struct nft_stats __percpu *stats; + u8 policy; ++ bool bound; + u32 chain_id; + }; + ++#define nft_trans_chain(trans) \ ++ (((struct nft_trans_chain *)trans->data)->chain) + #define nft_trans_chain_update(trans) \ + (((struct nft_trans_chain *)trans->data)->update) + #define nft_trans_chain_name(trans) \ +@@ -1555,6 +1572,8 @@ struct nft_trans_chain { + (((struct nft_trans_chain *)trans->data)->stats) + #define nft_trans_chain_policy(trans) \ + (((struct nft_trans_chain *)trans->data)->policy) ++#define nft_trans_chain_bound(trans) \ ++ (((struct nft_trans_chain *)trans->data)->bound) + #define nft_trans_chain_id(trans) \ + (((struct nft_trans_chain *)trans->data)->chain_id) + +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index 35b9f74f0bc61..83828c530b439 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -195,6 +195,48 @@ static void nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set) + } + } + ++static void nft_chain_trans_bind(const struct nft_ctx *ctx, struct nft_chain *chain) ++{ ++ struct nftables_pernet *nft_net; ++ struct net *net = ctx->net; ++ struct nft_trans *trans; ++ ++ if (!nft_chain_binding(chain)) ++ return; ++ ++ nft_net = nft_pernet(net); ++ list_for_each_entry_reverse(trans, &nft_net->commit_list, list) { ++ switch (trans->msg_type) { ++ case NFT_MSG_NEWCHAIN: ++ if (nft_trans_chain(trans) == chain) ++ nft_trans_chain_bound(trans) = true; ++ break; ++ case NFT_MSG_NEWRULE: ++ if (trans->ctx.chain == chain) ++ nft_trans_rule_bound(trans) = true; ++ break; ++ } ++ } ++} ++ ++int nf_tables_bind_chain(const struct nft_ctx *ctx, struct nft_chain *chain) ++{ ++ if (!nft_chain_binding(chain)) ++ return 0; ++ ++ if (nft_chain_binding(ctx->chain)) ++ return -EOPNOTSUPP; ++ ++ if (chain->bound) ++ return -EBUSY; ++ ++ chain->bound = true; ++ chain->use++; ++ nft_chain_trans_bind(ctx, chain); ++ ++ return 0; ++} ++ + static int nft_netdev_register_hooks(struct net *net, + struct list_head *hook_list) + { +@@ -340,8 +382,9 @@ static struct nft_trans *nft_trans_chain_add(struct nft_ctx *ctx, int msg_type) + ntohl(nla_get_be32(ctx->nla[NFTA_CHAIN_ID])); + } + } +- ++ nft_trans_chain(trans) = ctx->chain; + nft_trans_commit_list_add_tail(ctx->net, trans); ++ + return trans; + } + +@@ -359,8 +402,7 @@ static int nft_delchain(struct nft_ctx *ctx) + return 0; + } + +-static void nft_rule_expr_activate(const struct nft_ctx *ctx, +- struct nft_rule *rule) ++void nft_rule_expr_activate(const struct nft_ctx *ctx, struct nft_rule *rule) + { + struct nft_expr *expr; + +@@ -373,9 +415,8 @@ static void nft_rule_expr_activate(const struct nft_ctx *ctx, + } + } + +-static void nft_rule_expr_deactivate(const struct nft_ctx *ctx, +- struct nft_rule *rule, +- enum nft_trans_phase phase) ++void nft_rule_expr_deactivate(const struct nft_ctx *ctx, struct nft_rule *rule, ++ enum nft_trans_phase phase) + { + struct nft_expr *expr; + +@@ -2094,7 +2135,7 @@ static int nft_basechain_init(struct nft_base_chain *basechain, u8 family, + return 0; + } + +-static int nft_chain_add(struct nft_table *table, struct nft_chain *chain) ++int nft_chain_add(struct nft_table *table, struct nft_chain *chain) + { + int err; + +@@ -3220,8 +3261,7 @@ static int nf_tables_getrule(struct sk_buff *skb, const struct nfnl_info *info, + return err; + } + +-static void nf_tables_rule_destroy(const struct nft_ctx *ctx, +- struct nft_rule *rule) ++void nf_tables_rule_destroy(const struct nft_ctx *ctx, struct nft_rule *rule) + { + struct nft_expr *expr, *next; + +@@ -3238,7 +3278,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx, + kfree(rule); + } + +-void nf_tables_rule_release(const struct nft_ctx *ctx, struct nft_rule *rule) ++static void nf_tables_rule_release(const struct nft_ctx *ctx, struct nft_rule *rule) + { + nft_rule_expr_deactivate(ctx, rule, NFT_TRANS_RELEASE); + nf_tables_rule_destroy(ctx, rule); +@@ -6293,7 +6333,6 @@ static int nf_tables_newsetelem(struct sk_buff *skb, + void nft_data_hold(const struct nft_data *data, enum nft_data_types type) + { + struct nft_chain *chain; +- struct nft_rule *rule; + + if (type == NFT_DATA_VERDICT) { + switch (data->verdict.code) { +@@ -6301,15 +6340,6 @@ void nft_data_hold(const struct nft_data *data, enum nft_data_types type) + case NFT_GOTO: + chain = data->verdict.chain; + chain->use++; +- +- if (!nft_chain_is_bound(chain)) +- break; +- +- chain->table->use++; +- list_for_each_entry(rule, &chain->rules, list) +- chain->use++; +- +- nft_chain_add(chain->table, chain); + break; + } + } +@@ -9162,7 +9192,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action) + kfree(nft_trans_chain_name(trans)); + nft_trans_destroy(trans); + } else { +- if (nft_chain_is_bound(trans->ctx.chain)) { ++ if (nft_trans_chain_bound(trans)) { + nft_trans_destroy(trans); + break; + } +@@ -9179,6 +9209,10 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action) + nft_trans_destroy(trans); + break; + case NFT_MSG_NEWRULE: ++ if (nft_trans_rule_bound(trans)) { ++ nft_trans_destroy(trans); ++ break; ++ } + trans->ctx.chain->use--; + list_del_rcu(&nft_trans_rule(trans)->list); + nft_rule_expr_deactivate(&trans->ctx, +@@ -9737,22 +9771,12 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data, + static void nft_verdict_uninit(const struct nft_data *data) + { + struct nft_chain *chain; +- struct nft_rule *rule; + + switch (data->verdict.code) { + case NFT_JUMP: + case NFT_GOTO: + chain = data->verdict.chain; + chain->use--; +- +- if (!nft_chain_is_bound(chain)) +- break; +- +- chain->table->use--; +- list_for_each_entry(rule, &chain->rules, list) +- chain->use--; +- +- nft_chain_del(chain); + break; + } + } +diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c +index fcdbc5ed3f367..9d4248898ce4b 100644 +--- a/net/netfilter/nft_immediate.c ++++ b/net/netfilter/nft_immediate.c +@@ -76,11 +76,9 @@ static int nft_immediate_init(const struct nft_ctx *ctx, + switch (priv->data.verdict.code) { + case NFT_JUMP: + case NFT_GOTO: +- if (nft_chain_is_bound(chain)) { +- err = -EBUSY; +- goto err1; +- } +- chain->bound = true; ++ err = nf_tables_bind_chain(ctx, chain); ++ if (err < 0) ++ return err; + break; + default: + break; +@@ -98,6 +96,31 @@ static void nft_immediate_activate(const struct nft_ctx *ctx, + const struct nft_expr *expr) + { + const struct nft_immediate_expr *priv = nft_expr_priv(expr); ++ const struct nft_data *data = &priv->data; ++ struct nft_ctx chain_ctx; ++ struct nft_chain *chain; ++ struct nft_rule *rule; ++ ++ if (priv->dreg == NFT_REG_VERDICT) { ++ switch (data->verdict.code) { ++ case NFT_JUMP: ++ case NFT_GOTO: ++ chain = data->verdict.chain; ++ if (!nft_chain_binding(chain)) ++ break; ++ ++ chain_ctx = *ctx; ++ chain_ctx.chain = chain; ++ ++ list_for_each_entry(rule, &chain->rules, list) ++ nft_rule_expr_activate(&chain_ctx, rule); ++ ++ nft_clear(ctx->net, chain); ++ break; ++ default: ++ break; ++ } ++ } + + return nft_data_hold(&priv->data, nft_dreg_to_type(priv->dreg)); + } +@@ -107,6 +130,40 @@ static void nft_immediate_deactivate(const struct nft_ctx *ctx, + enum nft_trans_phase phase) + { + const struct nft_immediate_expr *priv = nft_expr_priv(expr); ++ const struct nft_data *data = &priv->data; ++ struct nft_ctx chain_ctx; ++ struct nft_chain *chain; ++ struct nft_rule *rule; ++ ++ if (priv->dreg == NFT_REG_VERDICT) { ++ switch (data->verdict.code) { ++ case NFT_JUMP: ++ case NFT_GOTO: ++ chain = data->verdict.chain; ++ if (!nft_chain_binding(chain)) ++ break; ++ ++ chain_ctx = *ctx; ++ chain_ctx.chain = chain; ++ ++ list_for_each_entry(rule, &chain->rules, list) ++ nft_rule_expr_deactivate(&chain_ctx, rule, phase); ++ ++ switch (phase) { ++ case NFT_TRANS_PREPARE: ++ nft_deactivate_next(ctx->net, chain); ++ break; ++ default: ++ nft_chain_del(chain); ++ chain->bound = false; ++ chain->table->use--; ++ break; ++ } ++ break; ++ default: ++ break; ++ } ++ } + + if (phase == NFT_TRANS_COMMIT) + return; +@@ -131,15 +188,27 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx, + case NFT_GOTO: + chain = data->verdict.chain; + +- if (!nft_chain_is_bound(chain)) ++ if (!nft_chain_binding(chain)) ++ break; ++ ++ /* Rule construction failed, but chain is already bound: ++ * let the transaction records release this chain and its rules. ++ */ ++ if (chain->bound) { ++ chain->use--; + break; ++ } + ++ /* Rule has been deleted, release chain and its rules. */ + chain_ctx = *ctx; + chain_ctx.chain = chain; + +- list_for_each_entry_safe(rule, n, &chain->rules, list) +- nf_tables_rule_release(&chain_ctx, rule); +- ++ chain->use--; ++ list_for_each_entry_safe(rule, n, &chain->rules, list) { ++ chain->use--; ++ list_del(&rule->list); ++ nf_tables_rule_destroy(&chain_ctx, rule); ++ } + nf_tables_chain_destroy(&chain_ctx); + break; + default: +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nf_tables-reject-unbound-anonymous-set-bef.patch b/queue-5.15/netfilter-nf_tables-reject-unbound-anonymous-set-bef.patch new file mode 100644 index 00000000000..b9ef2d125cb --- /dev/null +++ b/queue-5.15/netfilter-nf_tables-reject-unbound-anonymous-set-bef.patch @@ -0,0 +1,145 @@ +From 1a9314e1ba8dbb8a640f049b766d05f69c4a7615 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 15:21:33 +0200 +Subject: netfilter: nf_tables: reject unbound anonymous set before commit + phase + +From: Pablo Neira Ayuso + +[ Upstream commit 938154b93be8cd611ddfd7bafc1849f3c4355201 ] + +Add a new list to track set transaction and to check for unbound +anonymous sets before entering the commit phase. + +Bail out at the end of the transaction handling if an anonymous set +remains unbound. + +Fixes: 96518518cc41 ("netfilter: add nftables") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + include/net/netfilter/nf_tables.h | 3 +++ + net/netfilter/nf_tables_api.c | 35 ++++++++++++++++++++++++++++--- + 2 files changed, 35 insertions(+), 3 deletions(-) + +diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h +index 603c156da210b..7da74b9428b9f 100644 +--- a/include/net/netfilter/nf_tables.h ++++ b/include/net/netfilter/nf_tables.h +@@ -1503,6 +1503,7 @@ static inline void nft_set_elem_clear_busy(struct nft_set_ext *ext) + * struct nft_trans - nf_tables object update in transaction + * + * @list: used internally ++ * @binding_list: list of objects with possible bindings + * @msg_type: message type + * @put_net: ctx->net needs to be put + * @ctx: transaction context +@@ -1510,6 +1511,7 @@ static inline void nft_set_elem_clear_busy(struct nft_set_ext *ext) + */ + struct nft_trans { + struct list_head list; ++ struct list_head binding_list; + int msg_type; + bool put_net; + struct nft_ctx ctx; +@@ -1648,6 +1650,7 @@ static inline int nft_request_module(struct net *net, const char *fmt, ...) { re + struct nftables_pernet { + struct list_head tables; + struct list_head commit_list; ++ struct list_head binding_list; + struct list_head module_list; + struct list_head notify_list; + struct mutex commit_mutex; +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index c4e3aaeeb795c..010ef3bce9e5f 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -153,6 +153,7 @@ static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx, + return NULL; + + INIT_LIST_HEAD(&trans->list); ++ INIT_LIST_HEAD(&trans->binding_list); + trans->msg_type = msg_type; + trans->ctx = *ctx; + +@@ -165,9 +166,15 @@ static struct nft_trans *nft_trans_alloc(const struct nft_ctx *ctx, + return nft_trans_alloc_gfp(ctx, msg_type, size, GFP_KERNEL); + } + +-static void nft_trans_destroy(struct nft_trans *trans) ++static void nft_trans_list_del(struct nft_trans *trans) + { + list_del(&trans->list); ++ list_del(&trans->binding_list); ++} ++ ++static void nft_trans_destroy(struct nft_trans *trans) ++{ ++ nft_trans_list_del(trans); + kfree(trans); + } + +@@ -359,6 +366,14 @@ static void nft_trans_commit_list_add_tail(struct net *net, struct nft_trans *tr + { + struct nftables_pernet *nft_net = nft_pernet(net); + ++ switch (trans->msg_type) { ++ case NFT_MSG_NEWSET: ++ if (!nft_trans_set_update(trans) && ++ nft_set_is_anonymous(nft_trans_set(trans))) ++ list_add_tail(&trans->binding_list, &nft_net->binding_list); ++ break; ++ } ++ + list_add_tail(&trans->list, &nft_net->commit_list); + } + +@@ -8565,7 +8580,7 @@ static void nf_tables_trans_destroy_work(struct work_struct *w) + synchronize_rcu(); + + list_for_each_entry_safe(trans, next, &head, list) { +- list_del(&trans->list); ++ nft_trans_list_del(trans); + nft_commit_release(trans); + } + } +@@ -8883,6 +8898,19 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) + return 0; + } + ++ list_for_each_entry(trans, &nft_net->binding_list, binding_list) { ++ switch (trans->msg_type) { ++ case NFT_MSG_NEWSET: ++ if (!nft_trans_set_update(trans) && ++ nft_set_is_anonymous(nft_trans_set(trans)) && ++ !nft_trans_set_bound(trans)) { ++ pr_warn_once("nftables ruleset with unbound set\n"); ++ return -EINVAL; ++ } ++ break; ++ } ++ } ++ + /* 0. Validate ruleset, otherwise roll back for error reporting. */ + if (nf_tables_validate(net) < 0) + return -EAGAIN; +@@ -9356,7 +9384,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action) + + list_for_each_entry_safe_reverse(trans, next, + &nft_net->commit_list, list) { +- list_del(&trans->list); ++ nft_trans_list_del(trans); + nf_tables_abort_release(trans); + } + +@@ -10129,6 +10157,7 @@ static int __net_init nf_tables_init_net(struct net *net) + + INIT_LIST_HEAD(&nft_net->tables); + INIT_LIST_HEAD(&nft_net->commit_list); ++ INIT_LIST_HEAD(&nft_net->binding_list); + INIT_LIST_HEAD(&nft_net->module_list); + INIT_LIST_HEAD(&nft_net->notify_list); + mutex_init(&nft_net->commit_mutex); +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nf_tables-reject-unbound-chain-set-before-.patch b/queue-5.15/netfilter-nf_tables-reject-unbound-chain-set-before-.patch new file mode 100644 index 00000000000..10452c1a088 --- /dev/null +++ b/queue-5.15/netfilter-nf_tables-reject-unbound-chain-set-before-.patch @@ -0,0 +1,56 @@ +From c8edfc71464c7061415286e468b00d9266ea0b83 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 15:21:39 +0200 +Subject: netfilter: nf_tables: reject unbound chain set before commit phase + +From: Pablo Neira Ayuso + +[ Upstream commit 62e1e94b246e685d89c3163aaef4b160e42ceb02 ] + +Use binding list to track set transaction and to check for unbound +chains before entering the commit phase. + +Bail out if chain binding remain unused before entering the commit +step. + +Fixes: d0e2c7de92c7 ("netfilter: nf_tables: add NFT_CHAIN_BINDING") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nf_tables_api.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index 010ef3bce9e5f..66328326ec05e 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -372,6 +372,11 @@ static void nft_trans_commit_list_add_tail(struct net *net, struct nft_trans *tr + nft_set_is_anonymous(nft_trans_set(trans))) + list_add_tail(&trans->binding_list, &nft_net->binding_list); + break; ++ case NFT_MSG_NEWCHAIN: ++ if (!nft_trans_chain_update(trans) && ++ nft_chain_binding(nft_trans_chain(trans))) ++ list_add_tail(&trans->binding_list, &nft_net->binding_list); ++ break; + } + + list_add_tail(&trans->list, &nft_net->commit_list); +@@ -8908,6 +8913,14 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) + return -EINVAL; + } + break; ++ case NFT_MSG_NEWCHAIN: ++ if (!nft_trans_chain_update(trans) && ++ nft_chain_binding(nft_trans_chain(trans)) && ++ !nft_trans_chain_bound(trans)) { ++ pr_warn_once("nftables ruleset with unbound chain\n"); ++ return -EINVAL; ++ } ++ break; + } + } + +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nfnetlink_osf-fix-module-autoload.patch b/queue-5.15/netfilter-nfnetlink_osf-fix-module-autoload.patch new file mode 100644 index 00000000000..6379bb324a9 --- /dev/null +++ b/queue-5.15/netfilter-nfnetlink_osf-fix-module-autoload.patch @@ -0,0 +1,40 @@ +From 5237851d57cf9c9d82c8317c9978ae9712489bd0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 15 Jun 2023 10:14:25 +0200 +Subject: netfilter: nfnetlink_osf: fix module autoload + +From: Pablo Neira Ayuso + +[ Upstream commit 62f9a68a36d4441a6c412b81faed102594bc6670 ] + +Move the alias from xt_osf to nfnetlink_osf. + +Fixes: f9324952088f ("netfilter: nfnetlink_osf: extract nfnetlink_subsystem code from xt_osf.c") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nfnetlink_osf.c | 1 + + net/netfilter/xt_osf.c | 1 - + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c +index ee6840bd59337..8f1bfa6ccc2d9 100644 +--- a/net/netfilter/nfnetlink_osf.c ++++ b/net/netfilter/nfnetlink_osf.c +@@ -439,3 +439,4 @@ module_init(nfnl_osf_init); + module_exit(nfnl_osf_fini); + + MODULE_LICENSE("GPL"); ++MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_OSF); +diff --git a/net/netfilter/xt_osf.c b/net/netfilter/xt_osf.c +index e1990baf3a3b7..dc9485854002a 100644 +--- a/net/netfilter/xt_osf.c ++++ b/net/netfilter/xt_osf.c +@@ -71,4 +71,3 @@ MODULE_AUTHOR("Evgeniy Polyakov "); + MODULE_DESCRIPTION("Passive OS fingerprint matching."); + MODULE_ALIAS("ipt_osf"); + MODULE_ALIAS("ip6t_osf"); +-MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_OSF); +-- +2.39.2 + diff --git a/queue-5.15/netfilter-nft_set_pipapo-.walk-does-not-deal-with-ge.patch b/queue-5.15/netfilter-nft_set_pipapo-.walk-does-not-deal-with-ge.patch new file mode 100644 index 00000000000..31f2843f0fa --- /dev/null +++ b/queue-5.15/netfilter-nft_set_pipapo-.walk-does-not-deal-with-ge.patch @@ -0,0 +1,46 @@ +From fdfc774d0ad77fc94a15aa71ce6321fec1248c40 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 16 Jun 2023 15:20:04 +0200 +Subject: netfilter: nft_set_pipapo: .walk does not deal with generations + +From: Pablo Neira Ayuso + +[ Upstream commit 2b84e215f87443c74ac0aa7f76bb172d43a87033 ] + +The .walk callback iterates over the current active set, but it might be +useful to iterate over the next generation set. Use the generation mask +to determine what set view (either current or next generation) is use +for the walk iteration. + +Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nft_set_pipapo.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c +index 15e451dc3fc46..78e1ec8badde3 100644 +--- a/net/netfilter/nft_set_pipapo.c ++++ b/net/netfilter/nft_set_pipapo.c +@@ -1974,12 +1974,16 @@ static void nft_pipapo_walk(const struct nft_ctx *ctx, struct nft_set *set, + struct nft_set_iter *iter) + { + struct nft_pipapo *priv = nft_set_priv(set); ++ struct net *net = read_pnet(&set->net); + struct nft_pipapo_match *m; + struct nft_pipapo_field *f; + int i, r; + + rcu_read_lock(); +- m = rcu_dereference(priv->match); ++ if (iter->genmask == nft_genmask_cur(net)) ++ m = rcu_dereference(priv->match); ++ else ++ m = priv->clone; + + if (unlikely(!m)) + goto out; +-- +2.39.2 + diff --git a/queue-5.15/nfcsim.c-fix-error-checking-for-debugfs_create_dir.patch b/queue-5.15/nfcsim.c-fix-error-checking-for-debugfs_create_dir.patch new file mode 100644 index 00000000000..77289c21efb --- /dev/null +++ b/queue-5.15/nfcsim.c-fix-error-checking-for-debugfs_create_dir.patch @@ -0,0 +1,40 @@ +From ef66c6aeb0d76be1351d8c4900aec90d424755d5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 May 2023 22:27:46 +0500 +Subject: nfcsim.c: Fix error checking for debugfs_create_dir + +From: Osama Muhammad + +[ Upstream commit 9b9e46aa07273ceb96866b2e812b46f1ee0b8d2f ] + +This patch fixes the error checking in nfcsim.c. +The DebugFS kernel API is developed in +a way that the caller can safely ignore the errors that +occur during the creation of DebugFS nodes. + +Signed-off-by: Osama Muhammad +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/nfc/nfcsim.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c +index 85bf8d586c707..0f6befe8be1e2 100644 +--- a/drivers/nfc/nfcsim.c ++++ b/drivers/nfc/nfcsim.c +@@ -336,10 +336,6 @@ static struct dentry *nfcsim_debugfs_root; + static void nfcsim_debugfs_init(void) + { + nfcsim_debugfs_root = debugfs_create_dir("nfcsim", NULL); +- +- if (!nfcsim_debugfs_root) +- pr_err("Could not create debugfs entry\n"); +- + } + + static void nfcsim_debugfs_remove(void) +-- +2.39.2 + diff --git a/queue-5.15/nvme-double-ka-polling-frequency-to-avoid-kato-with-.patch b/queue-5.15/nvme-double-ka-polling-frequency-to-avoid-kato-with-.patch new file mode 100644 index 00000000000..bea6b5e2a60 --- /dev/null +++ b/queue-5.15/nvme-double-ka-polling-frequency-to-avoid-kato-with-.patch @@ -0,0 +1,81 @@ +From 53ea6a8170f872c1613144a78a73bfd5291842e1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 May 2023 12:22:02 -0600 +Subject: nvme: double KA polling frequency to avoid KATO with TBKAS on +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Uday Shankar + +[ Upstream commit ea4d453b9ec9ea279c39744cd0ecb47ef48ede35 ] + +With TBKAS on, the completion of one command can defer sending a +keep alive for up to twice the delay between successive runs of +nvme_keep_alive_work. The current delay of KATO / 2 thus makes it +possible for one command to defer sending a keep alive for up to +KATO, which can result in the controller detecting a KATO. The following +trace demonstrates the issue, taking KATO = 8 for simplicity: + +1. t = 0: run nvme_keep_alive_work, no keep-alive sent +2. t = ε: I/O completion seen, set comp_seen = true +3. t = 4: run nvme_keep_alive_work, see comp_seen == true, + skip sending keep-alive, set comp_seen = false +4. t = 8: run nvme_keep_alive_work, see comp_seen == false, + send a keep-alive command. + +Here, there is a delay of 8 - ε between receiving a command completion +and sending the next command. With ε small, the controller is likely to +detect a keep alive timeout. + +Fix this by running nvme_keep_alive_work with a delay of KATO / 4 +whenever TBKAS is on. Going through the above trace now gives us a +worst-case delay of 4 - ε, which is in line with the recommendation of +sending a command every KATO / 2 in the NVMe specification. + +Reported-by: Costa Sapuntzakis +Reported-by: Randy Jennings +Signed-off-by: Uday Shankar +Reviewed-by: Hannes Reinecke +Reviewed-by: Sagi Grimberg +Reviewed-by: Christoph Hellwig +Signed-off-by: Keith Busch +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/core.c | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c +index e5318b38c6624..98a7649a0f061 100644 +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -1247,9 +1247,25 @@ EXPORT_SYMBOL_NS_GPL(nvme_execute_passthru_rq, NVME_TARGET_PASSTHRU); + * The host should send Keep Alive commands at half of the Keep Alive Timeout + * accounting for transport roundtrip times [..]. + */ ++static unsigned long nvme_keep_alive_work_period(struct nvme_ctrl *ctrl) ++{ ++ unsigned long delay = ctrl->kato * HZ / 2; ++ ++ /* ++ * When using Traffic Based Keep Alive, we need to run ++ * nvme_keep_alive_work at twice the normal frequency, as one ++ * command completion can postpone sending a keep alive command ++ * by up to twice the delay between runs. ++ */ ++ if (ctrl->ctratt & NVME_CTRL_ATTR_TBKAS) ++ delay /= 2; ++ return delay; ++} ++ + static void nvme_queue_keep_alive_work(struct nvme_ctrl *ctrl) + { +- queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ / 2); ++ queue_delayed_work(nvme_wq, &ctrl->ka_work, ++ nvme_keep_alive_work_period(ctrl)); + } + + static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status) +-- +2.39.2 + diff --git a/queue-5.15/revert-net-phy-dp83867-perform-soft-reset-and-retain.patch b/queue-5.15/revert-net-phy-dp83867-perform-soft-reset-and-retain.patch new file mode 100644 index 00000000000..b5a11721cbe --- /dev/null +++ b/queue-5.15/revert-net-phy-dp83867-perform-soft-reset-and-retain.patch @@ -0,0 +1,47 @@ +From b660e498a2c2e7ddd1b17e8325ce01a342420a19 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 19 Jun 2023 17:44:35 +0200 +Subject: Revert "net: phy: dp83867: perform soft reset and retain established + link" + +From: Francesco Dolcini + +[ Upstream commit a129b41fe0a8b4da828c46b10f5244ca07a3fec3 ] + +This reverts commit da9ef50f545f86ffe6ff786174d26500c4db737a. + +This fixes a regression in which the link would come up, but no +communication was possible. + +The reverted commit was also removing a comment about +DP83867_PHYCR_FORCE_LINK_GOOD, this is not added back in this commits +since it seems that this is unrelated to the original code change. + +Closes: https://lore.kernel.org/all/ZGuDJos8D7N0J6Z2@francesco-nb.int.toradex.com/ +Fixes: da9ef50f545f ("net: phy: dp83867: perform soft reset and retain established link") +Signed-off-by: Francesco Dolcini +Reviewed-by: Andrew Lunn +Reviewed-by: Praneeth Bajjuri +Link: https://lore.kernel.org/r/20230619154435.355485-1-francesco@dolcini.it +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/phy/dp83867.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c +index 6230dd5e29902..76ca43108d992 100644 +--- a/drivers/net/phy/dp83867.c ++++ b/drivers/net/phy/dp83867.c +@@ -836,7 +836,7 @@ static int dp83867_phy_reset(struct phy_device *phydev) + { + int err; + +- err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART); ++ err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET); + if (err < 0) + return err; + +-- +2.39.2 + diff --git a/queue-5.15/s390-cio-unregister-device-when-the-only-path-is-gon.patch b/queue-5.15/s390-cio-unregister-device-when-the-only-path-is-gon.patch new file mode 100644 index 00000000000..54b3e9c0441 --- /dev/null +++ b/queue-5.15/s390-cio-unregister-device-when-the-only-path-is-gon.patch @@ -0,0 +1,62 @@ +From 4607b9246c141eb4a2a4a86cb3f28a5bcba57db2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 May 2023 20:53:20 +0200 +Subject: s390/cio: unregister device when the only path is gone + +From: Vineeth Vijayan + +[ Upstream commit 89c0c62e947a01e7a36b54582fd9c9e346170255 ] + +Currently, if the device is offline and all the channel paths are +either configured or varied offline, the associated subchannel gets +unregistered. Don't unregister the subchannel, instead unregister +offline device. + +Signed-off-by: Vineeth Vijayan +Reviewed-by: Peter Oberparleiter +Signed-off-by: Alexander Gordeev +Signed-off-by: Sasha Levin +--- + drivers/s390/cio/device.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c +index b21fa57d1a46b..a111154a90465 100644 +--- a/drivers/s390/cio/device.c ++++ b/drivers/s390/cio/device.c +@@ -1379,6 +1379,7 @@ void ccw_device_set_notoper(struct ccw_device *cdev) + enum io_sch_action { + IO_SCH_UNREG, + IO_SCH_ORPH_UNREG, ++ IO_SCH_UNREG_CDEV, + IO_SCH_ATTACH, + IO_SCH_UNREG_ATTACH, + IO_SCH_ORPH_ATTACH, +@@ -1411,7 +1412,7 @@ static enum io_sch_action sch_get_action(struct subchannel *sch) + } + if ((sch->schib.pmcw.pam & sch->opm) == 0) { + if (ccw_device_notify(cdev, CIO_NO_PATH) != NOTIFY_OK) +- return IO_SCH_UNREG; ++ return IO_SCH_UNREG_CDEV; + return IO_SCH_DISC; + } + if (device_is_disconnected(cdev)) +@@ -1473,6 +1474,7 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process) + case IO_SCH_ORPH_ATTACH: + ccw_device_set_disconnected(cdev); + break; ++ case IO_SCH_UNREG_CDEV: + case IO_SCH_UNREG_ATTACH: + case IO_SCH_UNREG: + if (!cdev) +@@ -1506,6 +1508,7 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process) + if (rc) + goto out; + break; ++ case IO_SCH_UNREG_CDEV: + case IO_SCH_UNREG_ATTACH: + spin_lock_irqsave(sch->lock, flags); + sch_set_cdev(sch, NULL); +-- +2.39.2 + diff --git a/queue-5.15/s390-purgatory-disable-branch-profiling.patch b/queue-5.15/s390-purgatory-disable-branch-profiling.patch new file mode 100644 index 00000000000..cd3310426fb --- /dev/null +++ b/queue-5.15/s390-purgatory-disable-branch-profiling.patch @@ -0,0 +1,36 @@ +From 00b6eec3525a1b73f5785e15de83ca92c872e9ef Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 May 2023 19:41:45 +0200 +Subject: s390/purgatory: disable branch profiling + +From: Alexander Gordeev + +[ Upstream commit 03c5c83b70dca3729a3eb488e668e5044bd9a5ea ] + +Avoid linker error for randomly generated config file that +has CONFIG_BRANCH_PROFILE_NONE enabled and make it similar +to riscv, x86 and also to commit 4bf3ec384edf ("s390: disable +branch profiling for vdso"). + +Reviewed-by: Vasily Gorbik +Signed-off-by: Alexander Gordeev +Signed-off-by: Sasha Levin +--- + arch/s390/purgatory/Makefile | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile +index 360ada80d20c3..d22ec8acb13c5 100644 +--- a/arch/s390/purgatory/Makefile ++++ b/arch/s390/purgatory/Makefile +@@ -26,6 +26,7 @@ KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare + KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding + KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common + KBUILD_CFLAGS += -fno-stack-protector ++KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING + KBUILD_CFLAGS += $(CLANG_FLAGS) + KBUILD_CFLAGS += $(call cc-option,-fno-PIE) + KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS)) +-- +2.39.2 + diff --git a/queue-5.15/sch_netem-acquire-qdisc-lock-in-netem_change.patch b/queue-5.15/sch_netem-acquire-qdisc-lock-in-netem_change.patch new file mode 100644 index 00000000000..7c6ba56c6b1 --- /dev/null +++ b/queue-5.15/sch_netem-acquire-qdisc-lock-in-netem_change.patch @@ -0,0 +1,109 @@ +From 1234642bd49e205d69739f311a9f2d9ee7e98b86 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 20 Jun 2023 18:44:25 +0000 +Subject: sch_netem: acquire qdisc lock in netem_change() + +From: Eric Dumazet + +[ Upstream commit 2174a08db80d1efeea382e25ac41c4e7511eb6d6 ] + +syzbot managed to trigger a divide error [1] in netem. + +It could happen if q->rate changes while netem_enqueue() +is running, since q->rate is read twice. + +It turns out netem_change() always lacked proper synchronization. + +[1] +divide error: 0000 [#1] SMP KASAN +CPU: 1 PID: 7867 Comm: syz-executor.1 Not tainted 6.1.30-syzkaller #0 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023 +RIP: 0010:div64_u64 include/linux/math64.h:69 [inline] +RIP: 0010:packet_time_ns net/sched/sch_netem.c:357 [inline] +RIP: 0010:netem_enqueue+0x2067/0x36d0 net/sched/sch_netem.c:576 +Code: 89 e2 48 69 da 00 ca 9a 3b 42 80 3c 28 00 4c 8b a4 24 88 00 00 00 74 0d 4c 89 e7 e8 c3 4f 3b fd 48 8b 4c 24 18 48 89 d8 31 d2 <49> f7 34 24 49 01 c7 4c 8b 64 24 48 4d 01 f7 4c 89 e3 48 c1 eb 03 +RSP: 0018:ffffc9000dccea60 EFLAGS: 00010246 +RAX: 000001a442624200 RBX: 000001a442624200 RCX: ffff888108a4f000 +RDX: 0000000000000000 RSI: 000000000000070d RDI: 000000000000070d +RBP: ffffc9000dcceb90 R08: ffffffff849c5e26 R09: fffffbfff10e1297 +R10: 0000000000000000 R11: dffffc0000000001 R12: ffff888108a4f358 +R13: dffffc0000000000 R14: 0000001a8cd9a7ec R15: 0000000000000000 +FS: 00007fa73fe18700(0000) GS:ffff8881f6b00000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 00007fa73fdf7718 CR3: 000000011d36e000 CR4: 0000000000350ee0 +Call Trace: + +[] __dev_xmit_skb net/core/dev.c:3931 [inline] +[] __dev_queue_xmit+0xcf5/0x3370 net/core/dev.c:4290 +[] dev_queue_xmit include/linux/netdevice.h:3030 [inline] +[] neigh_hh_output include/net/neighbour.h:531 [inline] +[] neigh_output include/net/neighbour.h:545 [inline] +[] ip_finish_output2+0xb92/0x10d0 net/ipv4/ip_output.c:235 +[] __ip_finish_output+0xc3/0x2b0 +[] ip_finish_output+0x31/0x2a0 net/ipv4/ip_output.c:323 +[] NF_HOOK_COND include/linux/netfilter.h:298 [inline] +[] ip_output+0x224/0x2a0 net/ipv4/ip_output.c:437 +[] dst_output include/net/dst.h:444 [inline] +[] ip_local_out net/ipv4/ip_output.c:127 [inline] +[] __ip_queue_xmit+0x1425/0x2000 net/ipv4/ip_output.c:542 +[] ip_queue_xmit+0x4c/0x70 net/ipv4/ip_output.c:556 + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Reported-by: syzbot +Signed-off-by: Eric Dumazet +Cc: Stephen Hemminger +Cc: Jamal Hadi Salim +Cc: Cong Wang +Cc: Jiri Pirko +Reviewed-by: Jamal Hadi Salim +Reviewed-by: Simon Horman +Link: https://lore.kernel.org/r/20230620184425.1179809-1-edumazet@google.com +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + net/sched/sch_netem.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c +index adc5407fd5d58..be42b1196786b 100644 +--- a/net/sched/sch_netem.c ++++ b/net/sched/sch_netem.c +@@ -969,6 +969,7 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, + if (ret < 0) + return ret; + ++ sch_tree_lock(sch); + /* backup q->clg and q->loss_model */ + old_clg = q->clg; + old_loss_model = q->loss_model; +@@ -977,7 +978,7 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, + ret = get_loss_clg(q, tb[TCA_NETEM_LOSS]); + if (ret) { + q->loss_model = old_loss_model; +- return ret; ++ goto unlock; + } + } else { + q->loss_model = CLG_RANDOM; +@@ -1044,6 +1045,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, + /* capping jitter to the range acceptable by tabledist() */ + q->jitter = min_t(s64, abs(q->jitter), INT_MAX); + ++unlock: ++ sch_tree_unlock(sch); + return ret; + + get_table_failure: +@@ -1053,7 +1056,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, + */ + q->clg = old_clg; + q->loss_model = old_loss_model; +- return ret; ++ ++ goto unlock; + } + + static int netem_init(struct Qdisc *sch, struct nlattr *opt, +-- +2.39.2 + diff --git a/queue-5.15/scsi-target-iscsi-prevent-login-threads-from-racing-.patch b/queue-5.15/scsi-target-iscsi-prevent-login-threads-from-racing-.patch new file mode 100644 index 00000000000..554fe72992d --- /dev/null +++ b/queue-5.15/scsi-target-iscsi-prevent-login-threads-from-racing-.patch @@ -0,0 +1,71 @@ +From 42c4b56297c3b11ce669b04bed316827cd699dcd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 May 2023 18:22:19 +0200 +Subject: scsi: target: iscsi: Prevent login threads from racing between each + other + +From: Maurizio Lombardi + +[ Upstream commit 2a737d3b8c792400118d6cf94958f559de9c5e59 ] + +The tpg->np_login_sem is a semaphore that is used to serialize the login +process when multiple login threads run concurrently against the same +target portal group. + +The iscsi_target_locate_portal() function finds the tpg, calls +iscsit_access_np() against the np_login_sem semaphore and saves the tpg +pointer in conn->tpg; + +If iscsi_target_locate_portal() fails, the caller will check for the +conn->tpg pointer and, if it's not NULL, then it will assume that +iscsi_target_locate_portal() called iscsit_access_np() on the semaphore. + +Make sure that conn->tpg gets initialized only if iscsit_access_np() was +successful, otherwise iscsit_deaccess_np() may end up being called against +a semaphore we never took, allowing more than one thread to access the same +tpg. + +Signed-off-by: Maurizio Lombardi +Link: https://lore.kernel.org/r/20230508162219.1731964-4-mlombard@redhat.com +Reviewed-by: Mike Christie +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/target/iscsi/iscsi_target_nego.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c +index c0ed6f8e5c5b9..32a2852352db1 100644 +--- a/drivers/target/iscsi/iscsi_target_nego.c ++++ b/drivers/target/iscsi/iscsi_target_nego.c +@@ -1071,6 +1071,7 @@ int iscsi_target_locate_portal( + iscsi_target_set_sock_callbacks(conn); + + login->np = np; ++ conn->tpg = NULL; + + login_req = (struct iscsi_login_req *) login->req; + payload_length = ntoh24(login_req->dlength); +@@ -1138,7 +1139,6 @@ int iscsi_target_locate_portal( + */ + sessiontype = strncmp(s_buf, DISCOVERY, 9); + if (!sessiontype) { +- conn->tpg = iscsit_global->discovery_tpg; + if (!login->leading_connection) + goto get_target; + +@@ -1155,9 +1155,11 @@ int iscsi_target_locate_portal( + * Serialize access across the discovery struct iscsi_portal_group to + * process login attempt. + */ ++ conn->tpg = iscsit_global->discovery_tpg; + if (iscsit_access_np(np, conn->tpg) < 0) { + iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, + ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE); ++ conn->tpg = NULL; + ret = -1; + goto out; + } +-- +2.39.2 + diff --git a/queue-5.15/selftests-forwarding-fix-race-condition-in-mirror-in.patch b/queue-5.15/selftests-forwarding-fix-race-condition-in-mirror-in.patch new file mode 100644 index 00000000000..b87e63c68a6 --- /dev/null +++ b/queue-5.15/selftests-forwarding-fix-race-condition-in-mirror-in.patch @@ -0,0 +1,79 @@ +From cffc74b1d207864295f6cec771b13206d140e99a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 20 Jun 2023 14:45:15 +0200 +Subject: selftests: forwarding: Fix race condition in mirror installation + +From: Danielle Ratson + +[ Upstream commit c7c059fba6fb19c3bc924925c984772e733cb594 ] + +When mirroring to a gretap in hardware the device expects to be +programmed with the egress port and all the encapsulating headers. This +requires the driver to resolve the path the packet will take in the +software data path and program the device accordingly. + +If the path cannot be resolved (in this case because of an unresolved +neighbor), then mirror installation fails until the path is resolved. +This results in a race that causes the test to sometimes fail. + +Fix this by setting the neighbor's state to permanent in a couple of +tests, so that it is always valid. + +Fixes: 35c31d5c323f ("selftests: forwarding: Test mirror-to-gretap w/ UL 802.1d") +Fixes: 239e754af854 ("selftests: forwarding: Test mirror-to-gretap w/ UL 802.1q") +Signed-off-by: Danielle Ratson +Reviewed-by: Petr Machata +Signed-off-by: Petr Machata +Link: https://lore.kernel.org/r/268816ac729cb6028c7a34d4dda6f4ec7af55333.1687264607.git.petrm@nvidia.com +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + .../testing/selftests/net/forwarding/mirror_gre_bridge_1d.sh | 4 ++++ + .../testing/selftests/net/forwarding/mirror_gre_bridge_1q.sh | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d.sh b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d.sh +index c5095da7f6bf8..aec752a22e9ec 100755 +--- a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d.sh ++++ b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d.sh +@@ -93,12 +93,16 @@ cleanup() + + test_gretap() + { ++ ip neigh replace 192.0.2.130 lladdr $(mac_get $h3) \ ++ nud permanent dev br2 + full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap" + full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap" + } + + test_ip6gretap() + { ++ ip neigh replace 2001:db8:2::2 lladdr $(mac_get $h3) \ ++ nud permanent dev br2 + full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap" + full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap" + } +diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1q.sh +index 9ff22f28032dd..0cf4c47a46f9b 100755 +--- a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1q.sh ++++ b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1q.sh +@@ -90,12 +90,16 @@ cleanup() + + test_gretap() + { ++ ip neigh replace 192.0.2.130 lladdr $(mac_get $h3) \ ++ nud permanent dev br1 + full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap" + full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap" + } + + test_ip6gretap() + { ++ ip neigh replace 2001:db8:2::2 lladdr $(mac_get $h3) \ ++ nud permanent dev br1 + full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap" + full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap" + } +-- +2.39.2 + diff --git a/queue-5.15/selftests-net-fcnal-test-check-if-fips-mode-is-enabl.patch b/queue-5.15/selftests-net-fcnal-test-check-if-fips-mode-is-enabl.patch new file mode 100644 index 00000000000..035069e58e7 --- /dev/null +++ b/queue-5.15/selftests-net-fcnal-test-check-if-fips-mode-is-enabl.patch @@ -0,0 +1,92 @@ +From e24dff7722efe3479c88fb36e7c6c86433b0289d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 13 Jun 2023 09:32:22 -0300 +Subject: selftests: net: fcnal-test: check if FIPS mode is enabled + +From: Magali Lemes + +[ Upstream commit d7a2fc1437f71cb058c7b11bc33dfc19e4bf277a ] + +There are some MD5 tests which fail when the kernel is in FIPS mode, +since MD5 is not FIPS compliant. Add a check and only run those tests +if FIPS mode is not enabled. + +Fixes: f0bee1ebb5594 ("fcnal-test: Add TCP MD5 tests") +Fixes: 5cad8bce26e01 ("fcnal-test: Add TCP MD5 tests for VRF") +Reviewed-by: David Ahern +Signed-off-by: Magali Lemes +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/net/fcnal-test.sh | 27 ++++++++++++++++------- + 1 file changed, 19 insertions(+), 8 deletions(-) + +diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh +index 364c82b797c19..6ecdbbe1b54fb 100755 +--- a/tools/testing/selftests/net/fcnal-test.sh ++++ b/tools/testing/selftests/net/fcnal-test.sh +@@ -84,6 +84,13 @@ NSC_CMD="ip netns exec ${NSC}" + + which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping) + ++# Check if FIPS mode is enabled ++if [ -f /proc/sys/crypto/fips_enabled ]; then ++ fips_enabled=`cat /proc/sys/crypto/fips_enabled` ++else ++ fips_enabled=0 ++fi ++ + ################################################################################ + # utilities + +@@ -1202,7 +1209,7 @@ ipv4_tcp_novrf() + run_cmd nettest -d ${NSA_DEV} -r ${a} + log_test_addr ${a} $? 1 "No server, device client, local conn" + +- ipv4_tcp_md5_novrf ++ [ "$fips_enabled" = "1" ] || ipv4_tcp_md5_novrf + } + + ipv4_tcp_vrf() +@@ -1256,9 +1263,11 @@ ipv4_tcp_vrf() + log_test_addr ${a} $? 1 "Global server, local connection" + + # run MD5 tests +- setup_vrf_dup +- ipv4_tcp_md5 +- cleanup_vrf_dup ++ if [ "$fips_enabled" = "0" ]; then ++ setup_vrf_dup ++ ipv4_tcp_md5 ++ cleanup_vrf_dup ++ fi + + # + # enable VRF global server +@@ -2674,7 +2683,7 @@ ipv6_tcp_novrf() + log_test_addr ${a} $? 1 "No server, device client, local conn" + done + +- ipv6_tcp_md5_novrf ++ [ "$fips_enabled" = "1" ] || ipv6_tcp_md5_novrf + } + + ipv6_tcp_vrf() +@@ -2744,9 +2753,11 @@ ipv6_tcp_vrf() + log_test_addr ${a} $? 1 "Global server, local connection" + + # run MD5 tests +- setup_vrf_dup +- ipv6_tcp_md5 +- cleanup_vrf_dup ++ if [ "$fips_enabled" = "0" ]; then ++ setup_vrf_dup ++ ipv6_tcp_md5 ++ cleanup_vrf_dup ++ fi + + # + # enable VRF global server +-- +2.39.2 + diff --git a/queue-5.15/series b/queue-5.15/series index da0a9af1db2..07be55555a1 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -34,3 +34,61 @@ io_uring-net-clear-msg_controllen-on-partial-sendmsg-retry.patch io_uring-net-disable-partial-retries-for-recvmsg-with-cmsg.patch nilfs2-prevent-general-protection-fault-in-nilfs_clear_dirty_page.patch x86-mm-avoid-using-set_pgd-outside-of-real-pgd-pages.patch +memfd-check-for-non-null-file_seals-in-memfd_create-.patch +mmc-meson-gx-fix-deferred-probing.patch +ieee802154-hwsim-fix-possible-memory-leaks.patch +xfrm-treat-already-verified-secpath-entries-as-optio.patch +xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch +xfrm-ensure-policies-always-checked-on-xfrm-i-input-.patch +bpf-track-immediate-values-written-to-stack-by-bpf_s.patch +bpf-fix-verifier-id-tracking-of-scalars-on-spill.patch +xfrm-fix-inbound-ipv4-udp-esp-packets-to-udpv6-duals.patch +selftests-net-fcnal-test-check-if-fips-mode-is-enabl.patch +xfrm-linearize-the-skb-after-offloading-if-needed.patch +net-qca_spi-avoid-high-load-if-qca7000-is-not-availa.patch +mmc-mtk-sd-fix-deferred-probing.patch +mmc-mvsdio-fix-deferred-probing.patch +mmc-omap-fix-deferred-probing.patch +mmc-omap_hsmmc-fix-deferred-probing.patch +mmc-owl-fix-deferred-probing.patch +mmc-sdhci-acpi-fix-deferred-probing.patch +mmc-sh_mmcif-fix-deferred-probing.patch +mmc-usdhi60rol0-fix-deferred-probing.patch +ipvs-align-inner_mac_header-for-encapsulation.patch +net-dsa-mt7530-fix-trapping-frames-on-non-mt7621-soc.patch +net-dsa-mt7530-fix-handling-of-bpdus-on-mt7530-switc.patch +be2net-extend-xmit-workaround-to-be3-chip.patch +netfilter-nf_tables-fix-chain-binding-transaction-lo.patch +netfilter-nf_tables-add-nft_trans_prepare_error-to-d.patch +netfilter-nft_set_pipapo-.walk-does-not-deal-with-ge.patch +netfilter-nf_tables-disallow-element-updates-of-boun.patch +netfilter-nf_tables-reject-unbound-anonymous-set-bef.patch +netfilter-nf_tables-reject-unbound-chain-set-before-.patch +netfilter-nf_tables-disallow-updates-of-anonymous-se.patch +netfilter-nfnetlink_osf-fix-module-autoload.patch +revert-net-phy-dp83867-perform-soft-reset-and-retain.patch +bpf-btf-accept-function-names-that-contain-dots.patch +selftests-forwarding-fix-race-condition-in-mirror-in.patch +sch_netem-acquire-qdisc-lock-in-netem_change.patch +gpio-allow-per-parent-interrupt-data.patch +gpiolib-fix-gpio-chip-irq-initialization-restriction.patch +gpio-sifive-add-missing-check-for-platform_get_irq.patch +scsi-target-iscsi-prevent-login-threads-from-racing-.patch +hid-wacom-add-error-check-to-wacom_parse_and_registe.patch +arm64-add-missing-set-way-cmo-encodings.patch +media-cec-core-don-t-set-last_initiator-if-tx-in-pro.patch +nfcsim.c-fix-error-checking-for-debugfs_create_dir.patch +usb-gadget-udc-fix-null-dereference-in-remove.patch +nvme-double-ka-polling-frequency-to-avoid-kato-with-.patch +input-soc_button_array-add-invalid-acpi_index-dmi-qu.patch +s390-cio-unregister-device-when-the-only-path-is-gon.patch +spi-lpspi-disable-lpspi-module-irq-in-dma-mode.patch +asoc-simple-card-add-missing-of_node_put-in-case-of-.patch +soundwire-dmi-quirks-add-new-mapping-for-hp-spectre-.patch +asoc-nau8824-add-quirk-to-active-high-jack-detect.patch +s390-purgatory-disable-branch-profiling.patch +arm-dts-fix-erroneous-ads-touchscreen-polarities.patch +drm-exynos-vidi-fix-a-wrong-error-return.patch +drm-exynos-fix-race-condition-uaf-in-exynos_g2d_exec.patch +drm-radeon-fix-race-condition-uaf-in-radeon_gem_set_.patch +vhost_net-revert-upend_idx-only-on-retriable-error.patch diff --git a/queue-5.15/soundwire-dmi-quirks-add-new-mapping-for-hp-spectre-.patch b/queue-5.15/soundwire-dmi-quirks-add-new-mapping-for-hp-spectre-.patch new file mode 100644 index 00000000000..ac070896d45 --- /dev/null +++ b/queue-5.15/soundwire-dmi-quirks-add-new-mapping-for-hp-spectre-.patch @@ -0,0 +1,44 @@ +From 2a3c7b5d3aa68ce9977706ea83bce7fa7444ea1a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 May 2023 15:48:59 +0800 +Subject: soundwire: dmi-quirks: add new mapping for HP Spectre x360 + +From: Pierre-Louis Bossart + +[ Upstream commit 700581ede41d029403feec935df4616309696fd7 ] + +A BIOS/DMI update seems to have broken some devices, let's add a new +mapping. + +Link: https://github.com/thesofproject/linux/issues/4323 +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Rander Wang +Signed-off-by: Bard Liao +Link: https://lore.kernel.org/r/20230515074859.3097-1-yung-chuan.liao@linux.intel.com +Signed-off-by: Vinod Koul +Signed-off-by: Sasha Levin +--- + drivers/soundwire/dmi-quirks.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/drivers/soundwire/dmi-quirks.c b/drivers/soundwire/dmi-quirks.c +index 2bf534632f644..39f0cc2a5b333 100644 +--- a/drivers/soundwire/dmi-quirks.c ++++ b/drivers/soundwire/dmi-quirks.c +@@ -63,6 +63,13 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { + }, + .driver_data = (void *)intel_tgl_bios, + }, ++ { ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "HP"), ++ DMI_MATCH(DMI_BOARD_NAME, "8709"), ++ }, ++ .driver_data = (void *)intel_tgl_bios, ++ }, + { + /* quirk used for NUC15 'Bishop County' LAPBC510 and LAPBC710 skews */ + .matches = { +-- +2.39.2 + diff --git a/queue-5.15/spi-lpspi-disable-lpspi-module-irq-in-dma-mode.patch b/queue-5.15/spi-lpspi-disable-lpspi-module-irq-in-dma-mode.patch new file mode 100644 index 00000000000..38cf14e8c39 --- /dev/null +++ b/queue-5.15/spi-lpspi-disable-lpspi-module-irq-in-dma-mode.patch @@ -0,0 +1,45 @@ +From 2bced354e7f87d961e6f075dad07d4994cd6a2cc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 5 May 2023 14:35:57 +0800 +Subject: spi: lpspi: disable lpspi module irq in DMA mode + +From: Clark Wang + +[ Upstream commit 9728fb3ce11729aa8c276825ddf504edeb00611d ] + +When all bits of IER are set to 0, we still can observe the lpspi irq events +when using DMA mode to transfer data. + +So disable irq to avoid the too much irq events. + +Signed-off-by: Clark Wang +Link: https://lore.kernel.org/r/20230505063557.3962220-1-xiaoning.wang@nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-fsl-lpspi.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c +index 5d98611dd999d..c5ff6e8c45be0 100644 +--- a/drivers/spi/spi-fsl-lpspi.c ++++ b/drivers/spi/spi-fsl-lpspi.c +@@ -906,9 +906,14 @@ static int fsl_lpspi_probe(struct platform_device *pdev) + ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller); + if (ret == -EPROBE_DEFER) + goto out_pm_get; +- + if (ret < 0) + dev_err(&pdev->dev, "dma setup error %d, use pio\n", ret); ++ else ++ /* ++ * disable LPSPI module IRQ when enable DMA mode successfully, ++ * to prevent the unexpected LPSPI module IRQ events. ++ */ ++ disable_irq(irq); + + ret = devm_spi_register_controller(&pdev->dev, controller); + if (ret < 0) { +-- +2.39.2 + diff --git a/queue-5.15/usb-gadget-udc-fix-null-dereference-in-remove.patch b/queue-5.15/usb-gadget-udc-fix-null-dereference-in-remove.patch new file mode 100644 index 00000000000..a75f9f453c8 --- /dev/null +++ b/queue-5.15/usb-gadget-udc-fix-null-dereference-in-remove.patch @@ -0,0 +1,39 @@ +From 6f40d566617bcd88d60d6612405d19f8b27bb626 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 May 2023 18:38:37 +0300 +Subject: usb: gadget: udc: fix NULL dereference in remove() + +From: Dan Carpenter + +[ Upstream commit 016da9c65fec9f0e78c4909ed9a0f2d567af6775 ] + +The "udc" pointer was never set in the probe() function so it will +lead to a NULL dereference in udc_pci_remove() when we do: + + usb_del_gadget_udc(&udc->gadget); + +Signed-off-by: Dan Carpenter +Link: https://lore.kernel.org/r/ZG+A/dNpFWAlCChk@kili +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/gadget/udc/amd5536udc_pci.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c +index c80f9bd51b750..a36913ae31f9e 100644 +--- a/drivers/usb/gadget/udc/amd5536udc_pci.c ++++ b/drivers/usb/gadget/udc/amd5536udc_pci.c +@@ -170,6 +170,9 @@ static int udc_pci_probe( + retval = -ENODEV; + goto err_probe; + } ++ ++ udc = dev; ++ + return 0; + + err_probe: +-- +2.39.2 + diff --git a/queue-5.15/vhost_net-revert-upend_idx-only-on-retriable-error.patch b/queue-5.15/vhost_net-revert-upend_idx-only-on-retriable-error.patch new file mode 100644 index 00000000000..475c114ddbd --- /dev/null +++ b/queue-5.15/vhost_net-revert-upend_idx-only-on-retriable-error.patch @@ -0,0 +1,60 @@ +From f50647f59fb5a758280595735dcc2fc7861008e3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Apr 2023 23:44:11 +0300 +Subject: vhost_net: revert upend_idx only on retriable error + +From: Andrey Smetanin + +[ Upstream commit 1f5d2e3bab16369d5d4b4020a25db4ab1f4f082c ] + +Fix possible virtqueue used buffers leak and corresponding stuck +in case of temporary -EIO from sendmsg() which is produced by +tun driver while backend device is not up. + +In case of no-retriable error and zcopy do not revert upend_idx +to pass packet data (that is update used_idx in corresponding +vhost_zerocopy_signal_used()) as if packet data has been +transferred successfully. + +v2: set vq->heads[ubuf->desc].len equal to VHOST_DMA_DONE_LEN +in case of fake successful transmit. + +Signed-off-by: Andrey Smetanin +Message-Id: <20230424204411.24888-1-asmetanin@yandex-team.ru> +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Andrey Smetanin +Acked-by: Jason Wang +Signed-off-by: Sasha Levin +--- + drivers/vhost/net.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c +index 32148f0112004..00f10d3402590 100644 +--- a/drivers/vhost/net.c ++++ b/drivers/vhost/net.c +@@ -933,13 +933,18 @@ static void handle_tx_zerocopy(struct vhost_net *net, struct socket *sock) + + err = sock->ops->sendmsg(sock, &msg, len); + if (unlikely(err < 0)) { ++ bool retry = err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS; ++ + if (zcopy_used) { + if (vq->heads[ubuf->desc].len == VHOST_DMA_IN_PROGRESS) + vhost_net_ubuf_put(ubufs); +- nvq->upend_idx = ((unsigned)nvq->upend_idx - 1) +- % UIO_MAXIOV; ++ if (retry) ++ nvq->upend_idx = ((unsigned)nvq->upend_idx - 1) ++ % UIO_MAXIOV; ++ else ++ vq->heads[ubuf->desc].len = VHOST_DMA_DONE_LEN; + } +- if (err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS) { ++ if (retry) { + vhost_discard_vq_desc(vq, 1); + vhost_net_enable_vq(net, vq); + break; +-- +2.39.2 + diff --git a/queue-5.15/xfrm-ensure-policies-always-checked-on-xfrm-i-input-.patch b/queue-5.15/xfrm-ensure-policies-always-checked-on-xfrm-i-input-.patch new file mode 100644 index 00000000000..0c26597b480 --- /dev/null +++ b/queue-5.15/xfrm-ensure-policies-always-checked-on-xfrm-i-input-.patch @@ -0,0 +1,111 @@ +From 541aad846d0bef946c4f3c49e672a0122dbce811 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 May 2023 01:30:22 +0000 +Subject: xfrm: Ensure policies always checked on XFRM-I input path + +From: Benedict Wong + +[ Upstream commit a287f5b0cfc6804c5b12a4be13c7c9fe27869e90 ] + +This change adds methods in the XFRM-I input path that ensures that +policies are checked prior to processing of the subsequent decapsulated +packet, after which the relevant policies may no longer be resolvable +(due to changing src/dst/proto/etc). + +Notably, raw ESP/AH packets did not perform policy checks inherently, +whereas all other encapsulated packets (UDP, TCP encapsulated) do policy +checks after calling xfrm_input handling in the respective encapsulation +layer. + +Fixes: b0355dbbf13c ("Fix XFRM-I support for nested ESP tunnels") +Test: Verified with additional Android Kernel Unit tests +Test: Verified against Android CTS +Signed-off-by: Benedict Wong +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/xfrm/xfrm_interface_core.c | 54 +++++++++++++++++++++++++++++++--- + 1 file changed, 50 insertions(+), 4 deletions(-) + +diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c +index 1e8b26eecb3f8..694eec6ca147e 100644 +--- a/net/xfrm/xfrm_interface_core.c ++++ b/net/xfrm/xfrm_interface_core.c +@@ -207,6 +207,52 @@ static void xfrmi_scrub_packet(struct sk_buff *skb, bool xnet) + skb->mark = 0; + } + ++static int xfrmi_input(struct sk_buff *skb, int nexthdr, __be32 spi, ++ int encap_type, unsigned short family) ++{ ++ struct sec_path *sp; ++ ++ sp = skb_sec_path(skb); ++ if (sp && (sp->len || sp->olen) && ++ !xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family)) ++ goto discard; ++ ++ XFRM_SPI_SKB_CB(skb)->family = family; ++ if (family == AF_INET) { ++ XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr); ++ XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = NULL; ++ } else { ++ XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr); ++ XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL; ++ } ++ ++ return xfrm_input(skb, nexthdr, spi, encap_type); ++discard: ++ kfree_skb(skb); ++ return 0; ++} ++ ++static int xfrmi4_rcv(struct sk_buff *skb) ++{ ++ return xfrmi_input(skb, ip_hdr(skb)->protocol, 0, 0, AF_INET); ++} ++ ++static int xfrmi6_rcv(struct sk_buff *skb) ++{ ++ return xfrmi_input(skb, skb_network_header(skb)[IP6CB(skb)->nhoff], ++ 0, 0, AF_INET6); ++} ++ ++static int xfrmi4_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) ++{ ++ return xfrmi_input(skb, nexthdr, spi, encap_type, AF_INET); ++} ++ ++static int xfrmi6_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) ++{ ++ return xfrmi_input(skb, nexthdr, spi, encap_type, AF_INET6); ++} ++ + static int xfrmi_rcv_cb(struct sk_buff *skb, int err) + { + const struct xfrm_mode *inner_mode; +@@ -774,8 +820,8 @@ static struct pernet_operations xfrmi_net_ops = { + }; + + static struct xfrm6_protocol xfrmi_esp6_protocol __read_mostly = { +- .handler = xfrm6_rcv, +- .input_handler = xfrm_input, ++ .handler = xfrmi6_rcv, ++ .input_handler = xfrmi6_input, + .cb_handler = xfrmi_rcv_cb, + .err_handler = xfrmi6_err, + .priority = 10, +@@ -825,8 +871,8 @@ static struct xfrm6_tunnel xfrmi_ip6ip_handler __read_mostly = { + #endif + + static struct xfrm4_protocol xfrmi_esp4_protocol __read_mostly = { +- .handler = xfrm4_rcv, +- .input_handler = xfrm_input, ++ .handler = xfrmi4_rcv, ++ .input_handler = xfrmi4_input, + .cb_handler = xfrmi_rcv_cb, + .err_handler = xfrmi4_err, + .priority = 10, +-- +2.39.2 + diff --git a/queue-5.15/xfrm-fix-inbound-ipv4-udp-esp-packets-to-udpv6-duals.patch b/queue-5.15/xfrm-fix-inbound-ipv4-udp-esp-packets-to-udpv6-duals.patch new file mode 100644 index 00000000000..bf0843c410d --- /dev/null +++ b/queue-5.15/xfrm-fix-inbound-ipv4-udp-esp-packets-to-udpv6-duals.patch @@ -0,0 +1,63 @@ +From f0da4f96b3a9cfffbcf37a3007787c51fdb212c6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 5 Jun 2023 04:06:54 -0700 +Subject: xfrm: fix inbound ipv4/udp/esp packets to UDPv6 dualstack sockets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Maciej Å»enczykowski + +[ Upstream commit 1166a530a84758bb9e6b448fc8c195ed413f5ded ] + +Before Linux v5.8 an AF_INET6 SOCK_DGRAM (udp/udplite) socket +with SOL_UDP, UDP_ENCAP, UDP_ENCAP_ESPINUDP{,_NON_IKE} enabled +would just unconditionally use xfrm4_udp_encap_rcv(), afterwards +such a socket would use the newly added xfrm6_udp_encap_rcv() +which only handles IPv6 packets. + +Cc: Sabrina Dubroca +Cc: Steffen Klassert +Cc: Jakub Kicinski +Cc: Benedict Wong +Cc: Yan Yan +Fixes: 0146dca70b87 ("xfrm: add support for UDPv6 encapsulation of ESP") +Signed-off-by: Maciej Å»enczykowski +Reviewed-by: Simon Horman +Reviewed-by: Sabrina Dubroca +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/ipv4/xfrm4_input.c | 1 + + net/ipv6/xfrm6_input.c | 3 +++ + 2 files changed, 4 insertions(+) + +diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c +index ad2afeef4f106..eac206a290d05 100644 +--- a/net/ipv4/xfrm4_input.c ++++ b/net/ipv4/xfrm4_input.c +@@ -164,6 +164,7 @@ int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) + kfree_skb(skb); + return 0; + } ++EXPORT_SYMBOL(xfrm4_udp_encap_rcv); + + int xfrm4_rcv(struct sk_buff *skb) + { +diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c +index 04cbeefd89828..4907ab241d6be 100644 +--- a/net/ipv6/xfrm6_input.c ++++ b/net/ipv6/xfrm6_input.c +@@ -86,6 +86,9 @@ int xfrm6_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) + __be32 *udpdata32; + __u16 encap_type = up->encap_type; + ++ if (skb->protocol == htons(ETH_P_IP)) ++ return xfrm4_udp_encap_rcv(sk, skb); ++ + /* if this is not encapsulated socket, then just return now */ + if (!encap_type) + return 1; +-- +2.39.2 + diff --git a/queue-5.15/xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch b/queue-5.15/xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch new file mode 100644 index 00000000000..a2dd40c9f92 --- /dev/null +++ b/queue-5.15/xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch @@ -0,0 +1,42 @@ +From 9afa47eff2eb61da089c1e66b6cf7cca2580914d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Dec 2022 10:46:56 +0200 +Subject: xfrm: interface: rename xfrm_interface.c to xfrm_interface_core.c + +From: Eyal Birger + +[ Upstream commit ee9a113ab63468137802898bcd2c598998c96938 ] + +This change allows adding additional files to the xfrm_interface module. + +Signed-off-by: Eyal Birger +Link: https://lore.kernel.org/r/20221203084659.1837829-2-eyal.birger@gmail.com +Signed-off-by: Martin KaFai Lau +Stable-dep-of: a287f5b0cfc6 ("xfrm: Ensure policies always checked on XFRM-I input path") +Signed-off-by: Sasha Levin +--- + net/xfrm/Makefile | 2 ++ + net/xfrm/{xfrm_interface.c => xfrm_interface_core.c} | 0 + 2 files changed, 2 insertions(+) + rename net/xfrm/{xfrm_interface.c => xfrm_interface_core.c} (100%) + +diff --git a/net/xfrm/Makefile b/net/xfrm/Makefile +index 494aa744bfb9a..08a2870fdd36f 100644 +--- a/net/xfrm/Makefile ++++ b/net/xfrm/Makefile +@@ -3,6 +3,8 @@ + # Makefile for the XFRM subsystem. + # + ++xfrm_interface-$(CONFIG_XFRM_INTERFACE) += xfrm_interface_core.o ++ + obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \ + xfrm_input.o xfrm_output.o \ + xfrm_sysctl.o xfrm_replay.o xfrm_device.o +diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface_core.c +similarity index 100% +rename from net/xfrm/xfrm_interface.c +rename to net/xfrm/xfrm_interface_core.c +-- +2.39.2 + diff --git a/queue-5.15/xfrm-linearize-the-skb-after-offloading-if-needed.patch b/queue-5.15/xfrm-linearize-the-skb-after-offloading-if-needed.patch new file mode 100644 index 00000000000..135cea44f44 --- /dev/null +++ b/queue-5.15/xfrm-linearize-the-skb-after-offloading-if-needed.patch @@ -0,0 +1,64 @@ +From e1085b5e41366222127b7d33d96f445f85a2ed88 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 14 Jun 2023 12:02:02 +0200 +Subject: xfrm: Linearize the skb after offloading if needed. + +From: Sebastian Andrzej Siewior + +[ Upstream commit f015b900bc3285322029b4a7d132d6aeb0e51857 ] + +With offloading enabled, esp_xmit() gets invoked very late, from within +validate_xmit_xfrm() which is after validate_xmit_skb() validates and +linearizes the skb if the underlying device does not support fragments. + +esp_output_tail() may add a fragment to the skb while adding the auth +tag/ IV. Devices without the proper support will then send skb->data +points to with the correct length so the packet will have garbage at the +end. A pcap sniffer will claim that the proper data has been sent since +it parses the skb properly. + +It is not affected with INET_ESP_OFFLOAD disabled. + +Linearize the skb after offloading if the sending hardware requires it. +It was tested on v4, v6 has been adopted. + +Fixes: 7785bba299a8d ("esp: Add a software GRO codepath") +Signed-off-by: Sebastian Andrzej Siewior +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/ipv4/esp4_offload.c | 3 +++ + net/ipv6/esp6_offload.c | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c +index 2ddba1e2cf228..ab6fe94b8fd90 100644 +--- a/net/ipv4/esp4_offload.c ++++ b/net/ipv4/esp4_offload.c +@@ -337,6 +337,9 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_ + + secpath_reset(skb); + ++ if (skb_needs_linearize(skb, skb->dev->features) && ++ __skb_linearize(skb)) ++ return -ENOMEM; + return 0; + } + +diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c +index 4cc19acfc369e..6b30f34c79783 100644 +--- a/net/ipv6/esp6_offload.c ++++ b/net/ipv6/esp6_offload.c +@@ -372,6 +372,9 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features + + secpath_reset(skb); + ++ if (skb_needs_linearize(skb, skb->dev->features) && ++ __skb_linearize(skb)) ++ return -ENOMEM; + return 0; + } + +-- +2.39.2 + diff --git a/queue-5.15/xfrm-treat-already-verified-secpath-entries-as-optio.patch b/queue-5.15/xfrm-treat-already-verified-secpath-entries-as-optio.patch new file mode 100644 index 00000000000..bb7139ebaa6 --- /dev/null +++ b/queue-5.15/xfrm-treat-already-verified-secpath-entries-as-optio.patch @@ -0,0 +1,100 @@ +From 7b07f377d85edc5bf90e3bc54612e67b957fe05a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 May 2023 01:30:21 +0000 +Subject: xfrm: Treat already-verified secpath entries as optional + +From: Benedict Wong + +[ Upstream commit 1f8b6df6a997a430b0c48b504638154b520781ad ] + +This change allows inbound traffic through nested IPsec tunnels to +successfully match policies and templates, while retaining the secpath +stack trace as necessary for netfilter policies. + +Specifically, this patch marks secpath entries that have already matched +against a relevant policy as having been verified, allowing it to be +treated as optional and skipped after a tunnel decapsulation (during +which the src/dst/proto/etc may have changed, and the correct policy +chain no long be resolvable). + +This approach is taken as opposed to the iteration in b0355dbbf13c, +where the secpath was cleared, since that breaks subsequent validations +that rely on the existence of the secpath entries (netfilter policies, or +transport-in-tunnel mode, where policies remain resolvable). + +Fixes: b0355dbbf13c ("Fix XFRM-I support for nested ESP tunnels") +Test: Tested against Android Kernel Unit Tests +Test: Tested against Android CTS +Signed-off-by: Benedict Wong +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + include/net/xfrm.h | 1 + + net/xfrm/xfrm_input.c | 1 + + net/xfrm/xfrm_policy.c | 12 ++++++++++++ + 3 files changed, 14 insertions(+) + +diff --git a/include/net/xfrm.h b/include/net/xfrm.h +index 73030094c6e6f..6156ed2950f97 100644 +--- a/include/net/xfrm.h ++++ b/include/net/xfrm.h +@@ -1026,6 +1026,7 @@ struct xfrm_offload { + struct sec_path { + int len; + int olen; ++ int verified_cnt; + + struct xfrm_state *xvec[XFRM_MAX_DEPTH]; + struct xfrm_offload ovec[XFRM_MAX_OFFLOAD_DEPTH]; +diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c +index 7c5958a2eed46..a6861832710d9 100644 +--- a/net/xfrm/xfrm_input.c ++++ b/net/xfrm/xfrm_input.c +@@ -130,6 +130,7 @@ struct sec_path *secpath_set(struct sk_buff *skb) + memset(sp->ovec, 0, sizeof(sp->ovec)); + sp->olen = 0; + sp->len = 0; ++ sp->verified_cnt = 0; + + return sp; + } +diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c +index 3e28a84ab9227..b0a19cc928799 100644 +--- a/net/xfrm/xfrm_policy.c ++++ b/net/xfrm/xfrm_policy.c +@@ -3275,6 +3275,13 @@ xfrm_policy_ok(const struct xfrm_tmpl *tmpl, const struct sec_path *sp, int star + if (xfrm_state_ok(tmpl, sp->xvec[idx], family, if_id)) + return ++idx; + if (sp->xvec[idx]->props.mode != XFRM_MODE_TRANSPORT) { ++ if (idx < sp->verified_cnt) { ++ /* Secpath entry previously verified, consider optional and ++ * continue searching ++ */ ++ continue; ++ } ++ + if (start == -1) + start = -2-idx; + break; +@@ -3647,6 +3654,9 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, + * Order is _important_. Later we will implement + * some barriers, but at the moment barriers + * are implied between each two transformations. ++ * Upon success, marks secpath entries as having been ++ * verified to allow them to be skipped in future policy ++ * checks (e.g. nested tunnels). + */ + for (i = xfrm_nr-1, k = 0; i >= 0; i--) { + k = xfrm_policy_ok(tpp[i], sp, k, family, if_id); +@@ -3665,6 +3675,8 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, + } + + xfrm_pols_put(pols, npols); ++ sp->verified_cnt = k; ++ + return 1; + } + XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLBLOCK); +-- +2.39.2 +