From: Sasha Levin Date: Sun, 20 Aug 2023 23:42:09 +0000 (-0400) Subject: Fixes for 4.19 X-Git-Tag: v6.4.12~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b40b82a1fe58d618139a7680aadde5564a87f0b2;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/asoc-meson-axg-tdm-formatter-fix-channel-slot-alloca.patch b/queue-4.19/asoc-meson-axg-tdm-formatter-fix-channel-slot-alloca.patch new file mode 100644 index 00000000000..c0b4f908ae1 --- /dev/null +++ b/queue-4.19/asoc-meson-axg-tdm-formatter-fix-channel-slot-alloca.patch @@ -0,0 +1,110 @@ +From ce1cc5f75e674ec0aa3e7c1746ce0e72e848808f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 9 Aug 2023 19:19:31 +0200 +Subject: ASoC: meson: axg-tdm-formatter: fix channel slot allocation + +From: Jerome Brunet + +[ Upstream commit c1f848f12103920ca165758aedb1c10904e193e1 ] + +When the tdm lane mask is computed, the driver currently fills the 1st lane +before moving on to the next. If the stream has less channels than the +lanes can accommodate, slots will be disabled on the last lanes. + +Unfortunately, the HW distribute channels in a different way. It distribute +channels in pair on each lanes before moving on the next slots. + +This difference leads to problems if a device has an interface with more +than 1 lane and with more than 2 slots per lane. + +For example: a playback interface with 2 lanes and 4 slots each (total 8 +slots - zero based numbering) +- Playing a 8ch stream: + - All slots activated by the driver + - channel #2 will be played on lane #1 - slot #0 following HW placement +- Playing a 4ch stream: + - Lane #1 disabled by the driver + - channel #2 will be played on lane #0 - slot #2 + +This behaviour is obviously not desirable. + +Change the way slots are activated on the TDM lanes to follow what the HW +does and make sure each channel always get mapped to the same slot/lane. + +Fixes: 1a11d88f499c ("ASoC: meson: add tdm formatter base driver") +Signed-off-by: Jerome Brunet +Link: https://lore.kernel.org/r/20230809171931.1244502-1-jbrunet@baylibre.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/meson/axg-tdm-formatter.c | 42 ++++++++++++++++++----------- + 1 file changed, 26 insertions(+), 16 deletions(-) + +diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c +index 43e390f9358a4..a195160b68208 100644 +--- a/sound/soc/meson/axg-tdm-formatter.c ++++ b/sound/soc/meson/axg-tdm-formatter.c +@@ -28,27 +28,32 @@ int axg_tdm_formatter_set_channel_masks(struct regmap *map, + struct axg_tdm_stream *ts, + unsigned int offset) + { +- unsigned int val, ch = ts->channels; +- unsigned long mask; +- int i, j; ++ unsigned int ch = ts->channels; ++ u32 val[AXG_TDM_NUM_LANES]; ++ int i, j, k; ++ ++ /* ++ * We need to mimick the slot distribution used by the HW to keep the ++ * channel placement consistent regardless of the number of channel ++ * in the stream. This is why the odd algorithm below is used. ++ */ ++ memset(val, 0, sizeof(*val) * AXG_TDM_NUM_LANES); + + /* + * Distribute the channels of the stream over the available slots +- * of each TDM lane ++ * of each TDM lane. We need to go over the 32 slots ... + */ +- for (i = 0; i < AXG_TDM_NUM_LANES; i++) { +- val = 0; +- mask = ts->mask[i]; +- +- for (j = find_first_bit(&mask, 32); +- (j < 32) && ch; +- j = find_next_bit(&mask, 32, j + 1)) { +- val |= 1 << j; +- ch -= 1; ++ for (i = 0; (i < 32) && ch; i += 2) { ++ /* ... of all the lanes ... */ ++ for (j = 0; j < AXG_TDM_NUM_LANES; j++) { ++ /* ... then distribute the channels in pairs */ ++ for (k = 0; k < 2; k++) { ++ if ((BIT(i + k) & ts->mask[j]) && ch) { ++ val[j] |= BIT(i + k); ++ ch -= 1; ++ } ++ } + } +- +- regmap_write(map, offset, val); +- offset += regmap_get_reg_stride(map); + } + + /* +@@ -61,6 +66,11 @@ int axg_tdm_formatter_set_channel_masks(struct regmap *map, + return -EINVAL; + } + ++ for (i = 0; i < AXG_TDM_NUM_LANES; i++) { ++ regmap_write(map, offset, val[i]); ++ offset += regmap_get_reg_stride(map); ++ } ++ + return 0; + } + EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks); +-- +2.40.1 + diff --git a/queue-4.19/asoc-rt5665-add-missed-regulator_bulk_disable.patch b/queue-4.19/asoc-rt5665-add-missed-regulator_bulk_disable.patch new file mode 100644 index 00000000000..63650326afc --- /dev/null +++ b/queue-4.19/asoc-rt5665-add-missed-regulator_bulk_disable.patch @@ -0,0 +1,38 @@ +From 997e5ca318cd078e9bd8bb31cd0f6dde63b1cddb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Aug 2023 23:59:11 +0800 +Subject: ASoC: rt5665: add missed regulator_bulk_disable + +From: Zhang Shurong + +[ Upstream commit c163108e706909570f8aa9aa5bcf6806e2b4c98c ] + +The driver forgets to call regulator_bulk_disable() + +Add the missed call to fix it. + +Fixes: 33ada14a26c8 ("ASoC: add rt5665 codec driver") +Signed-off-by: Zhang Shurong +Link: https://lore.kernel.org/r/tencent_A560D01E3E0A00A85A12F137E4B5205B3508@qq.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/rt5665.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c +index 6ba99f5ed3f42..a7ed2a19c3ec2 100644 +--- a/sound/soc/codecs/rt5665.c ++++ b/sound/soc/codecs/rt5665.c +@@ -4475,6 +4475,8 @@ static void rt5665_remove(struct snd_soc_component *component) + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); + + regmap_write(rt5665->regmap, RT5665_RESET, 0); ++ ++ regulator_bulk_disable(ARRAY_SIZE(rt5665->supplies), rt5665->supplies); + } + + #ifdef CONFIG_PM +-- +2.40.1 + diff --git a/queue-4.19/i40e-fix-misleading-debug-logs.patch b/queue-4.19/i40e-fix-misleading-debug-logs.patch new file mode 100644 index 00000000000..a40a1eaf8bd --- /dev/null +++ b/queue-4.19/i40e-fix-misleading-debug-logs.patch @@ -0,0 +1,67 @@ +From 26f5dbb28ccfb1e961b4f26d0092fd081beb296d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Aug 2023 09:47:32 +0200 +Subject: i40e: fix misleading debug logs + +From: Andrii Staikov + +[ Upstream commit 2f2beb8874cb0844e84ad26e990f05f4f13ff63f ] + +Change "write" into the actual "read" word. +Change parameters description. + +Fixes: 7073f46e443e ("i40e: Add AQ commands for NVM Update for X722") +Signed-off-by: Aleksandr Loktionov +Signed-off-by: Andrii Staikov +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/i40e/i40e_nvm.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c +index 0299e5bbb9022..10e9e60f6cf77 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c +@@ -210,11 +210,11 @@ static i40e_status i40e_read_nvm_word_srctl(struct i40e_hw *hw, u16 offset, + * @hw: pointer to the HW structure. + * @module_pointer: module pointer location in words from the NVM beginning + * @offset: offset in words from module start +- * @words: number of words to write +- * @data: buffer with words to write to the Shadow RAM ++ * @words: number of words to read ++ * @data: buffer with words to read to the Shadow RAM + * @last_command: tells the AdminQ that this is the last command + * +- * Writes a 16 bit words buffer to the Shadow RAM using the admin command. ++ * Reads a 16 bit words buffer to the Shadow RAM using the admin command. + **/ + static i40e_status i40e_read_nvm_aq(struct i40e_hw *hw, + u8 module_pointer, u32 offset, +@@ -234,18 +234,18 @@ static i40e_status i40e_read_nvm_aq(struct i40e_hw *hw, + */ + if ((offset + words) > hw->nvm.sr_size) + i40e_debug(hw, I40E_DEBUG_NVM, +- "NVM write error: offset %d beyond Shadow RAM limit %d\n", ++ "NVM read error: offset %d beyond Shadow RAM limit %d\n", + (offset + words), hw->nvm.sr_size); + else if (words > I40E_SR_SECTOR_SIZE_IN_WORDS) +- /* We can write only up to 4KB (one sector), in one AQ write */ ++ /* We can read only up to 4KB (one sector), in one AQ write */ + i40e_debug(hw, I40E_DEBUG_NVM, +- "NVM write fail error: tried to write %d words, limit is %d.\n", ++ "NVM read fail error: tried to read %d words, limit is %d.\n", + words, I40E_SR_SECTOR_SIZE_IN_WORDS); + else if (((offset + (words - 1)) / I40E_SR_SECTOR_SIZE_IN_WORDS) + != (offset / I40E_SR_SECTOR_SIZE_IN_WORDS)) +- /* A single write cannot spread over two sectors */ ++ /* A single read cannot spread over two sectors */ + i40e_debug(hw, I40E_DEBUG_NVM, +- "NVM write error: cannot spread over two sectors in a single write offset=%d words=%d\n", ++ "NVM read error: cannot spread over two sectors in a single read offset=%d words=%d\n", + offset, words); + else + ret_code = i40e_aq_read_nvm(hw, module_pointer, +-- +2.40.1 + diff --git a/queue-4.19/ip6_vti-fix-slab-use-after-free-in-decode_session6.patch b/queue-4.19/ip6_vti-fix-slab-use-after-free-in-decode_session6.patch new file mode 100644 index 00000000000..a8c5f68a288 --- /dev/null +++ b/queue-4.19/ip6_vti-fix-slab-use-after-free-in-decode_session6.patch @@ -0,0 +1,117 @@ +From d4e48f80a551c1404f18ae068ef6f5692e0625d8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Jul 2023 17:40:52 +0800 +Subject: ip6_vti: fix slab-use-after-free in decode_session6 + +From: Zhengchao Shao + +[ Upstream commit 9fd41f1ba638938c9a1195d09bc6fa3be2712f25 ] + +When ipv6_vti device is set to the qdisc of the sfb type, the cb field +of the sent skb may be modified during enqueuing. Then, +slab-use-after-free may occur when ipv6_vti device sends IPv6 packets. + +The stack information is as follows: +BUG: KASAN: slab-use-after-free in decode_session6+0x103f/0x1890 +Read of size 1 at addr ffff88802e08edc2 by task swapper/0/0 +CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.4.0-next-20230707-00001-g84e2cad7f979 #410 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014 +Call Trace: + +dump_stack_lvl+0xd9/0x150 +print_address_description.constprop.0+0x2c/0x3c0 +kasan_report+0x11d/0x130 +decode_session6+0x103f/0x1890 +__xfrm_decode_session+0x54/0xb0 +vti6_tnl_xmit+0x3e6/0x1ee0 +dev_hard_start_xmit+0x187/0x700 +sch_direct_xmit+0x1a3/0xc30 +__qdisc_run+0x510/0x17a0 +__dev_queue_xmit+0x2215/0x3b10 +neigh_connected_output+0x3c2/0x550 +ip6_finish_output2+0x55a/0x1550 +ip6_finish_output+0x6b9/0x1270 +ip6_output+0x1f1/0x540 +ndisc_send_skb+0xa63/0x1890 +ndisc_send_rs+0x132/0x6f0 +addrconf_rs_timer+0x3f1/0x870 +call_timer_fn+0x1a0/0x580 +expire_timers+0x29b/0x4b0 +run_timer_softirq+0x326/0x910 +__do_softirq+0x1d4/0x905 +irq_exit_rcu+0xb7/0x120 +sysvec_apic_timer_interrupt+0x97/0xc0 + +Allocated by task 9176: +kasan_save_stack+0x22/0x40 +kasan_set_track+0x25/0x30 +__kasan_slab_alloc+0x7f/0x90 +kmem_cache_alloc_node+0x1cd/0x410 +kmalloc_reserve+0x165/0x270 +__alloc_skb+0x129/0x330 +netlink_sendmsg+0x9b1/0xe30 +sock_sendmsg+0xde/0x190 +____sys_sendmsg+0x739/0x920 +___sys_sendmsg+0x110/0x1b0 +__sys_sendmsg+0xf7/0x1c0 +do_syscall_64+0x39/0xb0 +entry_SYSCALL_64_after_hwframe+0x63/0xcd +Freed by task 9176: +kasan_save_stack+0x22/0x40 +kasan_set_track+0x25/0x30 +kasan_save_free_info+0x2b/0x40 +____kasan_slab_free+0x160/0x1c0 +slab_free_freelist_hook+0x11b/0x220 +kmem_cache_free+0xf0/0x490 +skb_free_head+0x17f/0x1b0 +skb_release_data+0x59c/0x850 +consume_skb+0xd2/0x170 +netlink_unicast+0x54f/0x7f0 +netlink_sendmsg+0x926/0xe30 +sock_sendmsg+0xde/0x190 +____sys_sendmsg+0x739/0x920 +___sys_sendmsg+0x110/0x1b0 +__sys_sendmsg+0xf7/0x1c0 +do_syscall_64+0x39/0xb0 +entry_SYSCALL_64_after_hwframe+0x63/0xcd +The buggy address belongs to the object at ffff88802e08ed00 +which belongs to the cache skbuff_small_head of size 640 +The buggy address is located 194 bytes inside of +freed 640-byte region [ffff88802e08ed00, ffff88802e08ef80) + +As commit f855691975bb ("xfrm6: Fix the nexthdr offset in +_decode_session6.") showed, xfrm_decode_session was originally intended +only for the receive path. IP6CB(skb)->nhoff is not set during +transmission. Therefore, set the cb field in the skb to 0 before +sending packets. + +Fixes: f855691975bb ("xfrm6: Fix the nexthdr offset in _decode_session6.") +Signed-off-by: Zhengchao Shao +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/ipv6/ip6_vti.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c +index 866ce815625e5..a64050e775882 100644 +--- a/net/ipv6/ip6_vti.c ++++ b/net/ipv6/ip6_vti.c +@@ -562,12 +562,12 @@ vti6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) + vti6_addr_conflict(t, ipv6_hdr(skb))) + goto tx_err; + +- xfrm_decode_session(skb, &fl, AF_INET6); + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); ++ xfrm_decode_session(skb, &fl, AF_INET6); + break; + case htons(ETH_P_IP): +- xfrm_decode_session(skb, &fl, AF_INET); + memset(IPCB(skb), 0, sizeof(*IPCB(skb))); ++ xfrm_decode_session(skb, &fl, AF_INET); + break; + default: + goto tx_err; +-- +2.40.1 + diff --git a/queue-4.19/ip_vti-fix-potential-slab-use-after-free-in-decode_s.patch b/queue-4.19/ip_vti-fix-potential-slab-use-after-free-in-decode_s.patch new file mode 100644 index 00000000000..26b06401def --- /dev/null +++ b/queue-4.19/ip_vti-fix-potential-slab-use-after-free-in-decode_s.patch @@ -0,0 +1,48 @@ +From 92ea350436432a617eb8eded8f2145f08a21b860 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Jul 2023 17:40:53 +0800 +Subject: ip_vti: fix potential slab-use-after-free in decode_session6 + +From: Zhengchao Shao + +[ Upstream commit 6018a266279b1a75143c7c0804dd08a5fc4c3e0b ] + +When ip_vti device is set to the qdisc of the sfb type, the cb field +of the sent skb may be modified during enqueuing. Then, +slab-use-after-free may occur when ip_vti device sends IPv6 packets. +As commit f855691975bb ("xfrm6: Fix the nexthdr offset in +_decode_session6.") showed, xfrm_decode_session was originally intended +only for the receive path. IP6CB(skb)->nhoff is not set during +transmission. Therefore, set the cb field in the skb to 0 before +sending packets. + +Fixes: f855691975bb ("xfrm6: Fix the nexthdr offset in _decode_session6.") +Signed-off-by: Zhengchao Shao +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/ipv4/ip_vti.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c +index 15c71b08c2df4..a3536dfe9b16b 100644 +--- a/net/ipv4/ip_vti.c ++++ b/net/ipv4/ip_vti.c +@@ -319,12 +319,12 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) + + switch (skb->protocol) { + case htons(ETH_P_IP): +- xfrm_decode_session(skb, &fl, AF_INET); + memset(IPCB(skb), 0, sizeof(*IPCB(skb))); ++ xfrm_decode_session(skb, &fl, AF_INET); + break; + case htons(ETH_P_IPV6): +- xfrm_decode_session(skb, &fl, AF_INET6); + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); ++ xfrm_decode_session(skb, &fl, AF_INET6); + break; + default: + goto tx_err; +-- +2.40.1 + diff --git a/queue-4.19/net-af_key-fix-sadb_x_filter-validation.patch b/queue-4.19/net-af_key-fix-sadb_x_filter-validation.patch new file mode 100644 index 00000000000..b8f89cf3d5e --- /dev/null +++ b/queue-4.19/net-af_key-fix-sadb_x_filter-validation.patch @@ -0,0 +1,41 @@ +From b9cbee87eef71b27e659420767187e60546531eb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 27 Jun 2023 11:39:54 +0800 +Subject: net: af_key: fix sadb_x_filter validation + +From: Lin Ma + +[ Upstream commit 75065a8929069bc93181848818e23f147a73f83a ] + +When running xfrm_state_walk_init(), the xfrm_address_filter being used +is okay to have a splen/dplen that equals to sizeof(xfrm_address_t)<<3. +This commit replaces >= to > to make sure the boundary checking is +correct. + +Fixes: 37bd22420f85 ("af_key: pfkey_dump needs parameter validation") +Signed-off-by: Lin Ma +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/key/af_key.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/net/key/af_key.c b/net/key/af_key.c +index b8456e2f11673..47ffa69ca6f67 100644 +--- a/net/key/af_key.c ++++ b/net/key/af_key.c +@@ -1858,9 +1858,9 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms + if (ext_hdrs[SADB_X_EXT_FILTER - 1]) { + struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1]; + +- if ((xfilter->sadb_x_filter_splen >= ++ if ((xfilter->sadb_x_filter_splen > + (sizeof(xfrm_address_t) << 3)) || +- (xfilter->sadb_x_filter_dplen >= ++ (xfilter->sadb_x_filter_dplen > + (sizeof(xfrm_address_t) << 3))) { + mutex_unlock(&pfk->dump_lock); + return -EINVAL; +-- +2.40.1 + diff --git a/queue-4.19/net-do-not-allow-gso_size-to-be-set-to-gso_by_frags.patch b/queue-4.19/net-do-not-allow-gso_size-to-be-set-to-gso_by_frags.patch new file mode 100644 index 00000000000..ae23cb0a44e --- /dev/null +++ b/queue-4.19/net-do-not-allow-gso_size-to-be-set-to-gso_by_frags.patch @@ -0,0 +1,90 @@ +From 805872b7caba03e412b175798cf06e1a8dc3c97f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 16 Aug 2023 14:21:58 +0000 +Subject: net: do not allow gso_size to be set to GSO_BY_FRAGS + +From: Eric Dumazet + +[ Upstream commit b616be6b97688f2f2bd7c4a47ab32f27f94fb2a9 ] + +One missing check in virtio_net_hdr_to_skb() allowed +syzbot to crash kernels again [1] + +Do not allow gso_size to be set to GSO_BY_FRAGS (0xffff), +because this magic value is used by the kernel. + +[1] +general protection fault, probably for non-canonical address 0xdffffc000000000e: 0000 [#1] PREEMPT SMP KASAN +KASAN: null-ptr-deref in range [0x0000000000000070-0x0000000000000077] +CPU: 0 PID: 5039 Comm: syz-executor401 Not tainted 6.5.0-rc5-next-20230809-syzkaller #0 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023 +RIP: 0010:skb_segment+0x1a52/0x3ef0 net/core/skbuff.c:4500 +Code: 00 00 00 e9 ab eb ff ff e8 6b 96 5d f9 48 8b 84 24 00 01 00 00 48 8d 78 70 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e ea 21 00 00 48 8b 84 24 00 01 +RSP: 0018:ffffc90003d3f1c8 EFLAGS: 00010202 +RAX: dffffc0000000000 RBX: 000000000001fffe RCX: 0000000000000000 +RDX: 000000000000000e RSI: ffffffff882a3115 RDI: 0000000000000070 +RBP: ffffc90003d3f378 R08: 0000000000000005 R09: 000000000000ffff +R10: 000000000000ffff R11: 5ee4a93e456187d6 R12: 000000000001ffc6 +R13: dffffc0000000000 R14: 0000000000000008 R15: 000000000000ffff +FS: 00005555563f2380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 0000000020020000 CR3: 000000001626d000 CR4: 00000000003506f0 +DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 +DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 +Call Trace: + +udp6_ufo_fragment+0x9d2/0xd50 net/ipv6/udp_offload.c:109 +ipv6_gso_segment+0x5c4/0x17b0 net/ipv6/ip6_offload.c:120 +skb_mac_gso_segment+0x292/0x610 net/core/gso.c:53 +__skb_gso_segment+0x339/0x710 net/core/gso.c:124 +skb_gso_segment include/net/gso.h:83 [inline] +validate_xmit_skb+0x3a5/0xf10 net/core/dev.c:3625 +__dev_queue_xmit+0x8f0/0x3d60 net/core/dev.c:4329 +dev_queue_xmit include/linux/netdevice.h:3082 [inline] +packet_xmit+0x257/0x380 net/packet/af_packet.c:276 +packet_snd net/packet/af_packet.c:3087 [inline] +packet_sendmsg+0x24c7/0x5570 net/packet/af_packet.c:3119 +sock_sendmsg_nosec net/socket.c:727 [inline] +sock_sendmsg+0xd9/0x180 net/socket.c:750 +____sys_sendmsg+0x6ac/0x940 net/socket.c:2496 +___sys_sendmsg+0x135/0x1d0 net/socket.c:2550 +__sys_sendmsg+0x117/0x1e0 net/socket.c:2579 +do_syscall_x64 arch/x86/entry/common.c:50 [inline] +do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 +entry_SYSCALL_64_after_hwframe+0x63/0xcd +RIP: 0033:0x7ff27cdb34d9 + +Fixes: 3953c46c3ac7 ("sk_buff: allow segmenting based on frag sizes") +Reported-by: syzbot +Signed-off-by: Eric Dumazet +Cc: Xin Long +Cc: "Michael S. Tsirkin" +Cc: Jason Wang +Reviewed-by: Willem de Bruijn +Reviewed-by: Marcelo Ricardo Leitner +Reviewed-by: Xuan Zhuo +Link: https://lore.kernel.org/r/20230816142158.1779798-1-edumazet@google.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + include/linux/virtio_net.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h +index faee73c084d49..d49c1aad24643 100644 +--- a/include/linux/virtio_net.h ++++ b/include/linux/virtio_net.h +@@ -148,6 +148,10 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, + if (gso_type & SKB_GSO_UDP) + nh_off -= thlen; + ++ /* Kernel has a special handling for GSO_BY_FRAGS. */ ++ if (gso_size == GSO_BY_FRAGS) ++ return -EINVAL; ++ + /* Too small packets are not really GSO ones. */ + if (skb->len - nh_off > gso_size) { + shinfo->gso_size = gso_size; +-- +2.40.1 + diff --git a/queue-4.19/net-xfrm-fix-xfrm_address_filter-oob-read.patch b/queue-4.19/net-xfrm-fix-xfrm_address_filter-oob-read.patch new file mode 100644 index 00000000000..5ac2141b196 --- /dev/null +++ b/queue-4.19/net-xfrm-fix-xfrm_address_filter-oob-read.patch @@ -0,0 +1,202 @@ +From 88040b5c3fdc60c3c722bd64bd4ac852344e71fb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 27 Jun 2023 11:31:38 +0800 +Subject: net: xfrm: Fix xfrm_address_filter OOB read + +From: Lin Ma + +[ Upstream commit dfa73c17d55b921e1d4e154976de35317e43a93a ] + +We found below OOB crash: + +[ 44.211730] ================================================================== +[ 44.212045] BUG: KASAN: slab-out-of-bounds in memcmp+0x8b/0xb0 +[ 44.212045] Read of size 8 at addr ffff88800870f320 by task poc.xfrm/97 +[ 44.212045] +[ 44.212045] CPU: 0 PID: 97 Comm: poc.xfrm Not tainted 6.4.0-rc7-00072-gdad9774deaf1-dirty #4 +[ 44.212045] Call Trace: +[ 44.212045] +[ 44.212045] dump_stack_lvl+0x37/0x50 +[ 44.212045] print_report+0xcc/0x620 +[ 44.212045] ? __virt_addr_valid+0xf3/0x170 +[ 44.212045] ? memcmp+0x8b/0xb0 +[ 44.212045] kasan_report+0xb2/0xe0 +[ 44.212045] ? memcmp+0x8b/0xb0 +[ 44.212045] kasan_check_range+0x39/0x1c0 +[ 44.212045] memcmp+0x8b/0xb0 +[ 44.212045] xfrm_state_walk+0x21c/0x420 +[ 44.212045] ? __pfx_dump_one_state+0x10/0x10 +[ 44.212045] xfrm_dump_sa+0x1e2/0x290 +[ 44.212045] ? __pfx_xfrm_dump_sa+0x10/0x10 +[ 44.212045] ? __kernel_text_address+0xd/0x40 +[ 44.212045] ? kasan_unpoison+0x27/0x60 +[ 44.212045] ? mutex_lock+0x60/0xe0 +[ 44.212045] ? __pfx_mutex_lock+0x10/0x10 +[ 44.212045] ? kasan_save_stack+0x22/0x50 +[ 44.212045] netlink_dump+0x322/0x6c0 +[ 44.212045] ? __pfx_netlink_dump+0x10/0x10 +[ 44.212045] ? mutex_unlock+0x7f/0xd0 +[ 44.212045] ? __pfx_mutex_unlock+0x10/0x10 +[ 44.212045] __netlink_dump_start+0x353/0x430 +[ 44.212045] xfrm_user_rcv_msg+0x3a4/0x410 +[ 44.212045] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 +[ 44.212045] ? __pfx_xfrm_user_rcv_msg+0x10/0x10 +[ 44.212045] ? __pfx_xfrm_dump_sa+0x10/0x10 +[ 44.212045] ? __pfx_xfrm_dump_sa_done+0x10/0x10 +[ 44.212045] ? __stack_depot_save+0x382/0x4e0 +[ 44.212045] ? filter_irq_stacks+0x1c/0x70 +[ 44.212045] ? kasan_save_stack+0x32/0x50 +[ 44.212045] ? kasan_save_stack+0x22/0x50 +[ 44.212045] ? kasan_set_track+0x25/0x30 +[ 44.212045] ? __kasan_slab_alloc+0x59/0x70 +[ 44.212045] ? kmem_cache_alloc_node+0xf7/0x260 +[ 44.212045] ? kmalloc_reserve+0xab/0x120 +[ 44.212045] ? __alloc_skb+0xcf/0x210 +[ 44.212045] ? netlink_sendmsg+0x509/0x700 +[ 44.212045] ? sock_sendmsg+0xde/0xe0 +[ 44.212045] ? __sys_sendto+0x18d/0x230 +[ 44.212045] ? __x64_sys_sendto+0x71/0x90 +[ 44.212045] ? do_syscall_64+0x3f/0x90 +[ 44.212045] ? entry_SYSCALL_64_after_hwframe+0x72/0xdc +[ 44.212045] ? netlink_sendmsg+0x509/0x700 +[ 44.212045] ? sock_sendmsg+0xde/0xe0 +[ 44.212045] ? __sys_sendto+0x18d/0x230 +[ 44.212045] ? __x64_sys_sendto+0x71/0x90 +[ 44.212045] ? do_syscall_64+0x3f/0x90 +[ 44.212045] ? entry_SYSCALL_64_after_hwframe+0x72/0xdc +[ 44.212045] ? kasan_save_stack+0x22/0x50 +[ 44.212045] ? kasan_set_track+0x25/0x30 +[ 44.212045] ? kasan_save_free_info+0x2e/0x50 +[ 44.212045] ? __kasan_slab_free+0x10a/0x190 +[ 44.212045] ? kmem_cache_free+0x9c/0x340 +[ 44.212045] ? netlink_recvmsg+0x23c/0x660 +[ 44.212045] ? sock_recvmsg+0xeb/0xf0 +[ 44.212045] ? __sys_recvfrom+0x13c/0x1f0 +[ 44.212045] ? __x64_sys_recvfrom+0x71/0x90 +[ 44.212045] ? do_syscall_64+0x3f/0x90 +[ 44.212045] ? entry_SYSCALL_64_after_hwframe+0x72/0xdc +[ 44.212045] ? copyout+0x3e/0x50 +[ 44.212045] netlink_rcv_skb+0xd6/0x210 +[ 44.212045] ? __pfx_xfrm_user_rcv_msg+0x10/0x10 +[ 44.212045] ? __pfx_netlink_rcv_skb+0x10/0x10 +[ 44.212045] ? __pfx_sock_has_perm+0x10/0x10 +[ 44.212045] ? mutex_lock+0x8d/0xe0 +[ 44.212045] ? __pfx_mutex_lock+0x10/0x10 +[ 44.212045] xfrm_netlink_rcv+0x44/0x50 +[ 44.212045] netlink_unicast+0x36f/0x4c0 +[ 44.212045] ? __pfx_netlink_unicast+0x10/0x10 +[ 44.212045] ? netlink_recvmsg+0x500/0x660 +[ 44.212045] netlink_sendmsg+0x3b7/0x700 +[ 44.212045] ? __pfx_netlink_sendmsg+0x10/0x10 +[ 44.212045] ? __pfx_netlink_sendmsg+0x10/0x10 +[ 44.212045] sock_sendmsg+0xde/0xe0 +[ 44.212045] __sys_sendto+0x18d/0x230 +[ 44.212045] ? __pfx___sys_sendto+0x10/0x10 +[ 44.212045] ? rcu_core+0x44a/0xe10 +[ 44.212045] ? __rseq_handle_notify_resume+0x45b/0x740 +[ 44.212045] ? _raw_spin_lock_irq+0x81/0xe0 +[ 44.212045] ? __pfx___rseq_handle_notify_resume+0x10/0x10 +[ 44.212045] ? __pfx_restore_fpregs_from_fpstate+0x10/0x10 +[ 44.212045] ? __pfx_blkcg_maybe_throttle_current+0x10/0x10 +[ 44.212045] ? __pfx_task_work_run+0x10/0x10 +[ 44.212045] __x64_sys_sendto+0x71/0x90 +[ 44.212045] do_syscall_64+0x3f/0x90 +[ 44.212045] entry_SYSCALL_64_after_hwframe+0x72/0xdc +[ 44.212045] RIP: 0033:0x44b7da +[ 44.212045] RSP: 002b:00007ffdc8838548 EFLAGS: 00000246 ORIG_RAX: 000000000000002c +[ 44.212045] RAX: ffffffffffffffda RBX: 00007ffdc8839978 RCX: 000000000044b7da +[ 44.212045] RDX: 0000000000000038 RSI: 00007ffdc8838770 RDI: 0000000000000003 +[ 44.212045] RBP: 00007ffdc88385b0 R08: 00007ffdc883858c R09: 000000000000000c +[ 44.212045] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 +[ 44.212045] R13: 00007ffdc8839968 R14: 00000000004c37d0 R15: 0000000000000001 +[ 44.212045] +[ 44.212045] +[ 44.212045] Allocated by task 97: +[ 44.212045] kasan_save_stack+0x22/0x50 +[ 44.212045] kasan_set_track+0x25/0x30 +[ 44.212045] __kasan_kmalloc+0x7f/0x90 +[ 44.212045] __kmalloc_node_track_caller+0x5b/0x140 +[ 44.212045] kmemdup+0x21/0x50 +[ 44.212045] xfrm_dump_sa+0x17d/0x290 +[ 44.212045] netlink_dump+0x322/0x6c0 +[ 44.212045] __netlink_dump_start+0x353/0x430 +[ 44.212045] xfrm_user_rcv_msg+0x3a4/0x410 +[ 44.212045] netlink_rcv_skb+0xd6/0x210 +[ 44.212045] xfrm_netlink_rcv+0x44/0x50 +[ 44.212045] netlink_unicast+0x36f/0x4c0 +[ 44.212045] netlink_sendmsg+0x3b7/0x700 +[ 44.212045] sock_sendmsg+0xde/0xe0 +[ 44.212045] __sys_sendto+0x18d/0x230 +[ 44.212045] __x64_sys_sendto+0x71/0x90 +[ 44.212045] do_syscall_64+0x3f/0x90 +[ 44.212045] entry_SYSCALL_64_after_hwframe+0x72/0xdc +[ 44.212045] +[ 44.212045] The buggy address belongs to the object at ffff88800870f300 +[ 44.212045] which belongs to the cache kmalloc-64 of size 64 +[ 44.212045] The buggy address is located 32 bytes inside of +[ 44.212045] allocated 36-byte region [ffff88800870f300, ffff88800870f324) +[ 44.212045] +[ 44.212045] The buggy address belongs to the physical page: +[ 44.212045] page:00000000e4de16ee refcount:1 mapcount:0 mapping:000000000 ... +[ 44.212045] flags: 0x100000000000200(slab|node=0|zone=1) +[ 44.212045] page_type: 0xffffffff() +[ 44.212045] raw: 0100000000000200 ffff888004c41640 dead000000000122 0000000000000000 +[ 44.212045] raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000 +[ 44.212045] page dumped because: kasan: bad access detected +[ 44.212045] +[ 44.212045] Memory state around the buggy address: +[ 44.212045] ffff88800870f200: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc +[ 44.212045] ffff88800870f280: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc +[ 44.212045] >ffff88800870f300: 00 00 00 00 04 fc fc fc fc fc fc fc fc fc fc fc +[ 44.212045] ^ +[ 44.212045] ffff88800870f380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 44.212045] ffff88800870f400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc +[ 44.212045] ================================================================== + +By investigating the code, we find the root cause of this OOB is the lack +of checks in xfrm_dump_sa(). The buggy code allows a malicious user to pass +arbitrary value of filter->splen/dplen. Hence, with crafted xfrm states, +the attacker can achieve 8 bytes heap OOB read, which causes info leak. + + if (attrs[XFRMA_ADDRESS_FILTER]) { + filter = kmemdup(nla_data(attrs[XFRMA_ADDRESS_FILTER]), + sizeof(*filter), GFP_KERNEL); + if (filter == NULL) + return -ENOMEM; + // NO MORE CHECKS HERE !!! + } + +This patch fixes the OOB by adding necessary boundary checks, just like +the code in pfkey_dump() function. + +Fixes: d3623099d350 ("ipsec: add support of limited SA dump") +Signed-off-by: Lin Ma +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/xfrm/xfrm_user.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c +index 94c7ebc26c48e..03322e015eaed 100644 +--- a/net/xfrm/xfrm_user.c ++++ b/net/xfrm/xfrm_user.c +@@ -1036,6 +1036,15 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb) + sizeof(*filter), GFP_KERNEL); + if (filter == NULL) + return -ENOMEM; ++ ++ /* see addr_match(), (prefix length >> 5) << 2 ++ * will be used to compare xfrm_address_t ++ */ ++ if (filter->splen > (sizeof(xfrm_address_t) << 3) || ++ filter->dplen > (sizeof(xfrm_address_t) << 3)) { ++ kfree(filter); ++ return -EINVAL; ++ } + } + + if (attrs[XFRMA_PROTO]) +-- +2.40.1 + diff --git a/queue-4.19/netfilter-nft_dynset-disallow-object-maps.patch b/queue-4.19/netfilter-nft_dynset-disallow-object-maps.patch new file mode 100644 index 00000000000..b08f1fe1e40 --- /dev/null +++ b/queue-4.19/netfilter-nft_dynset-disallow-object-maps.patch @@ -0,0 +1,36 @@ +From 90d89118b8e5e0d8a452e7d1fdcf58276fc3b367 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 15 Aug 2023 15:39:02 +0200 +Subject: netfilter: nft_dynset: disallow object maps + +From: Pablo Neira Ayuso + +[ Upstream commit 23185c6aed1ffb8fc44087880ba2767aba493779 ] + +Do not allow to insert elements from datapath to objects maps. + +Fixes: 8aeff920dcc9 ("netfilter: nf_tables: add stateful object reference to set elements") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Florian Westphal +Signed-off-by: Sasha Levin +--- + net/netfilter/nft_dynset.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c +index 651c9784904cb..a4c6aba7da7ee 100644 +--- a/net/netfilter/nft_dynset.c ++++ b/net/netfilter/nft_dynset.c +@@ -144,6 +144,9 @@ static int nft_dynset_init(const struct nft_ctx *ctx, + if (IS_ERR(set)) + return PTR_ERR(set); + ++ if (set->flags & NFT_SET_OBJECT) ++ return -EOPNOTSUPP; ++ + if (set->ops->update == NULL) + return -EOPNOTSUPP; + +-- +2.40.1 + diff --git a/queue-4.19/selftests-mirror_gre_changes-tighten-up-the-ttl-test.patch b/queue-4.19/selftests-mirror_gre_changes-tighten-up-the-ttl-test.patch new file mode 100644 index 00000000000..83ce5d64bbc --- /dev/null +++ b/queue-4.19/selftests-mirror_gre_changes-tighten-up-the-ttl-test.patch @@ -0,0 +1,48 @@ +From 107033d7a0bc5d192a66782c5aec904de7bb1f33 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 11 Aug 2023 17:59:27 +0200 +Subject: selftests: mirror_gre_changes: Tighten up the TTL test match + +From: Petr Machata + +[ Upstream commit 855067defa36b1f9effad8c219d9a85b655cf500 ] + +This test verifies whether the encapsulated packets have the correct +configured TTL. It does so by sending ICMP packets through the test +topology and mirroring them to a gretap netdevice. On a busy host +however, more than just the test ICMP packets may end up flowing +through the topology, get mirrored, and counted. This leads to +potential spurious failures as the test observes much more mirrored +packets than the sent test packets, and assumes a bug. + +Fix this by tightening up the mirror action match. Change it from +matchall to a flower classifier matching on ICMP packets specifically. + +Fixes: 45315673e0c5 ("selftests: forwarding: Test changes in mirror-to-gretap") +Signed-off-by: Petr Machata +Tested-by: Mirsad Todorovac +Reviewed-by: Ido Schimmel +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/net/forwarding/mirror_gre_changes.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_changes.sh b/tools/testing/selftests/net/forwarding/mirror_gre_changes.sh +index 135902aa8b114..a372863c9efdb 100755 +--- a/tools/testing/selftests/net/forwarding/mirror_gre_changes.sh ++++ b/tools/testing/selftests/net/forwarding/mirror_gre_changes.sh +@@ -72,7 +72,8 @@ test_span_gre_ttl() + + RET=0 + +- mirror_install $swp1 ingress $tundev "matchall $tcflags" ++ mirror_install $swp1 ingress $tundev \ ++ "prot ip flower $tcflags ip_prot icmp" + tc filter add dev $h3 ingress pref 77 prot $prot \ + flower ip_ttl 50 action pass + +-- +2.40.1 + diff --git a/queue-4.19/series b/queue-4.19/series index 14797ff17e4..f3acedea29a 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -57,3 +57,18 @@ virtio-mmio-don-t-break-lifecycle-of-vm_dev.patch fbdev-mmp-fix-value-check-in-mmphw_probe.patch powerpc-rtas_flash-allow-user-copy-to-flash-block-cache-objects.patch btrfs-fix-bug_on-condition-in-btrfs_cancel_balance.patch +net-xfrm-fix-xfrm_address_filter-oob-read.patch +net-af_key-fix-sadb_x_filter-validation.patch +xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch +xfrm-fix-slab-use-after-free-in-decode_session6.patch +ip6_vti-fix-slab-use-after-free-in-decode_session6.patch +ip_vti-fix-potential-slab-use-after-free-in-decode_s.patch +xfrm-add-null-check-in-xfrm_update_ae_params.patch +selftests-mirror_gre_changes-tighten-up-the-ttl-test.patch +netfilter-nft_dynset-disallow-object-maps.patch +team-fix-incorrect-deletion-of-eth_p_8021ad-protocol.patch +i40e-fix-misleading-debug-logs.patch +sock-fix-misuse-of-sk_under_memory_pressure.patch +net-do-not-allow-gso_size-to-be-set-to-gso_by_frags.patch +asoc-rt5665-add-missed-regulator_bulk_disable.patch +asoc-meson-axg-tdm-formatter-fix-channel-slot-alloca.patch diff --git a/queue-4.19/sock-fix-misuse-of-sk_under_memory_pressure.patch b/queue-4.19/sock-fix-misuse-of-sk_under_memory_pressure.patch new file mode 100644 index 00000000000..205d13c18b9 --- /dev/null +++ b/queue-4.19/sock-fix-misuse-of-sk_under_memory_pressure.patch @@ -0,0 +1,74 @@ +From 23f2246c069e0d9e540af5950a19ca2607ddda27 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 16 Aug 2023 17:12:22 +0800 +Subject: sock: Fix misuse of sk_under_memory_pressure() + +From: Abel Wu + +[ Upstream commit 2d0c88e84e483982067a82073f6125490ddf3614 ] + +The status of global socket memory pressure is updated when: + + a) __sk_mem_raise_allocated(): + + enter: sk_memory_allocated(sk) > sysctl_mem[1] + leave: sk_memory_allocated(sk) <= sysctl_mem[0] + + b) __sk_mem_reduce_allocated(): + + leave: sk_under_memory_pressure(sk) && + sk_memory_allocated(sk) < sysctl_mem[0] + +So the conditions of leaving global pressure are inconstant, which +may lead to the situation that one pressured net-memcg prevents the +global pressure from being cleared when there is indeed no global +pressure, thus the global constrains are still in effect unexpectedly +on the other sockets. + +This patch fixes this by ignoring the net-memcg's pressure when +deciding whether should leave global memory pressure. + +Fixes: e1aab161e013 ("socket: initial cgroup code.") +Signed-off-by: Abel Wu +Acked-by: Shakeel Butt +Link: https://lore.kernel.org/r/20230816091226.1542-1-wuyun.abel@bytedance.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + include/net/sock.h | 6 ++++++ + net/core/sock.c | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/include/net/sock.h b/include/net/sock.h +index 72739f72e4b90..bcb1901ac13a5 100644 +--- a/include/net/sock.h ++++ b/include/net/sock.h +@@ -1265,6 +1265,12 @@ static inline bool sk_has_memory_pressure(const struct sock *sk) + return sk->sk_prot->memory_pressure != NULL; + } + ++static inline bool sk_under_global_memory_pressure(const struct sock *sk) ++{ ++ return sk->sk_prot->memory_pressure && ++ !!*sk->sk_prot->memory_pressure; ++} ++ + static inline bool sk_under_memory_pressure(const struct sock *sk) + { + if (!sk->sk_prot->memory_pressure) +diff --git a/net/core/sock.c b/net/core/sock.c +index 3e6da3694a5a5..4e3ed80a68ceb 100644 +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2538,7 +2538,7 @@ void __sk_mem_reduce_allocated(struct sock *sk, int amount) + if (mem_cgroup_sockets_enabled && sk->sk_memcg) + mem_cgroup_uncharge_skmem(sk->sk_memcg, amount); + +- if (sk_under_memory_pressure(sk) && ++ if (sk_under_global_memory_pressure(sk) && + (sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0))) + sk_leave_memory_pressure(sk); + } +-- +2.40.1 + diff --git a/queue-4.19/team-fix-incorrect-deletion-of-eth_p_8021ad-protocol.patch b/queue-4.19/team-fix-incorrect-deletion-of-eth_p_8021ad-protocol.patch new file mode 100644 index 00000000000..f5f38b153b4 --- /dev/null +++ b/queue-4.19/team-fix-incorrect-deletion-of-eth_p_8021ad-protocol.patch @@ -0,0 +1,54 @@ +From 060d9848a8336318de9bb493d5d3faf73fc19033 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 14 Aug 2023 11:23:01 +0800 +Subject: team: Fix incorrect deletion of ETH_P_8021AD protocol vid from slaves + +From: Ziyang Xuan + +[ Upstream commit dafcbce07136d799edc4c67f04f9fd69ff1eac1f ] + +Similar to commit 01f4fd270870 ("bonding: Fix incorrect deletion of +ETH_P_8021AD protocol vid from slaves"), we can trigger BUG_ON(!vlan_info) +in unregister_vlan_dev() with the following testcase: + + # ip netns add ns1 + # ip netns exec ns1 ip link add team1 type team + # ip netns exec ns1 ip link add team_slave type veth peer veth2 + # ip netns exec ns1 ip link set team_slave master team1 + # ip netns exec ns1 ip link add link team_slave name team_slave.10 type vlan id 10 protocol 802.1ad + # ip netns exec ns1 ip link add link team1 name team1.10 type vlan id 10 protocol 802.1ad + # ip netns exec ns1 ip link set team_slave nomaster + # ip netns del ns1 + +Add S-VLAN tag related features support to team driver. So the team driver +will always propagate the VLAN info to its slaves. + +Fixes: 8ad227ff89a7 ("net: vlan: add 802.1ad support") +Suggested-by: Ido Schimmel +Signed-off-by: Ziyang Xuan +Reviewed-by: Simon Horman +Link: https://lore.kernel.org/r/20230814032301.2804971-1-william.xuanziyang@huawei.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/team/team.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c +index d80bc5f59b3fc..8b5e1ec6aabfb 100644 +--- a/drivers/net/team/team.c ++++ b/drivers/net/team/team.c +@@ -2168,7 +2168,9 @@ static void team_setup(struct net_device *dev) + + dev->hw_features = TEAM_VLAN_FEATURES | + NETIF_F_HW_VLAN_CTAG_RX | +- NETIF_F_HW_VLAN_CTAG_FILTER; ++ NETIF_F_HW_VLAN_CTAG_FILTER | ++ NETIF_F_HW_VLAN_STAG_RX | ++ NETIF_F_HW_VLAN_STAG_FILTER; + + dev->hw_features |= NETIF_F_GSO_ENCAP_ALL | NETIF_F_GSO_UDP_L4; + dev->features |= dev->hw_features; +-- +2.40.1 + diff --git a/queue-4.19/xfrm-add-null-check-in-xfrm_update_ae_params.patch b/queue-4.19/xfrm-add-null-check-in-xfrm_update_ae_params.patch new file mode 100644 index 00000000000..7174ee5a9a0 --- /dev/null +++ b/queue-4.19/xfrm-add-null-check-in-xfrm_update_ae_params.patch @@ -0,0 +1,104 @@ +From 96ad717fb5a685e777a5206975945d0bf57f960c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 21 Jul 2023 22:51:03 +0800 +Subject: xfrm: add NULL check in xfrm_update_ae_params + +From: Lin Ma + +[ Upstream commit 00374d9b6d9f932802b55181be9831aa948e5b7c ] + +Normally, x->replay_esn and x->preplay_esn should be allocated at +xfrm_alloc_replay_state_esn(...) in xfrm_state_construct(...), hence the +xfrm_update_ae_params(...) is okay to update them. However, the current +implementation of xfrm_new_ae(...) allows a malicious user to directly +dereference a NULL pointer and crash the kernel like below. + +BUG: kernel NULL pointer dereference, address: 0000000000000000 +PGD 8253067 P4D 8253067 PUD 8e0e067 PMD 0 +Oops: 0002 [#1] PREEMPT SMP KASAN NOPTI +CPU: 0 PID: 98 Comm: poc.npd Not tainted 6.4.0-rc7-00072-gdad9774deaf1 #8 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.o4 +RIP: 0010:memcpy_orig+0xad/0x140 +Code: e8 4c 89 5f e0 48 8d 7f e0 73 d2 83 c2 20 48 29 d6 48 29 d7 83 fa 10 72 34 4c 8b 06 4c 8b 4e 08 c +RSP: 0018:ffff888008f57658 EFLAGS: 00000202 +RAX: 0000000000000000 RBX: ffff888008bd0000 RCX: ffffffff8238e571 +RDX: 0000000000000018 RSI: ffff888007f64844 RDI: 0000000000000000 +RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 +R10: 0000000000000000 R11: 0000000000000000 R12: ffff888008f57818 +R13: ffff888007f64aa4 R14: 0000000000000000 R15: 0000000000000000 +FS: 00000000014013c0(0000) GS:ffff88806d600000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 0000000000000000 CR3: 00000000054d8000 CR4: 00000000000006f0 +Call Trace: + + ? __die+0x1f/0x70 + ? page_fault_oops+0x1e8/0x500 + ? __pfx_is_prefetch.constprop.0+0x10/0x10 + ? __pfx_page_fault_oops+0x10/0x10 + ? _raw_spin_unlock_irqrestore+0x11/0x40 + ? fixup_exception+0x36/0x460 + ? _raw_spin_unlock_irqrestore+0x11/0x40 + ? exc_page_fault+0x5e/0xc0 + ? asm_exc_page_fault+0x26/0x30 + ? xfrm_update_ae_params+0xd1/0x260 + ? memcpy_orig+0xad/0x140 + ? __pfx__raw_spin_lock_bh+0x10/0x10 + xfrm_update_ae_params+0xe7/0x260 + xfrm_new_ae+0x298/0x4e0 + ? __pfx_xfrm_new_ae+0x10/0x10 + ? __pfx_xfrm_new_ae+0x10/0x10 + xfrm_user_rcv_msg+0x25a/0x410 + ? __pfx_xfrm_user_rcv_msg+0x10/0x10 + ? __alloc_skb+0xcf/0x210 + ? stack_trace_save+0x90/0xd0 + ? filter_irq_stacks+0x1c/0x70 + ? __stack_depot_save+0x39/0x4e0 + ? __kasan_slab_free+0x10a/0x190 + ? kmem_cache_free+0x9c/0x340 + ? netlink_recvmsg+0x23c/0x660 + ? sock_recvmsg+0xeb/0xf0 + ? __sys_recvfrom+0x13c/0x1f0 + ? __x64_sys_recvfrom+0x71/0x90 + ? do_syscall_64+0x3f/0x90 + ? entry_SYSCALL_64_after_hwframe+0x72/0xdc + ? copyout+0x3e/0x50 + netlink_rcv_skb+0xd6/0x210 + ? __pfx_xfrm_user_rcv_msg+0x10/0x10 + ? __pfx_netlink_rcv_skb+0x10/0x10 + ? __pfx_sock_has_perm+0x10/0x10 + ? mutex_lock+0x8d/0xe0 + ? __pfx_mutex_lock+0x10/0x10 + xfrm_netlink_rcv+0x44/0x50 + netlink_unicast+0x36f/0x4c0 + ? __pfx_netlink_unicast+0x10/0x10 + ? netlink_recvmsg+0x500/0x660 + netlink_sendmsg+0x3b7/0x700 + +This Null-ptr-deref bug is assigned CVE-2023-3772. And this commit +adds additional NULL check in xfrm_update_ae_params to fix the NPD. + +Fixes: d8647b79c3b7 ("xfrm: Add user interface for esn and big anti-replay windows") +Signed-off-by: Lin Ma +Reviewed-by: Leon Romanovsky +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/xfrm/xfrm_user.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c +index 03322e015eaed..b5c0e6e6cefa8 100644 +--- a/net/xfrm/xfrm_user.c ++++ b/net/xfrm/xfrm_user.c +@@ -521,7 +521,7 @@ static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs, + struct nlattr *et = attrs[XFRMA_ETIMER_THRESH]; + struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH]; + +- if (re) { ++ if (re && x->replay_esn && x->preplay_esn) { + struct xfrm_replay_state_esn *replay_esn; + replay_esn = nla_data(re); + memcpy(x->replay_esn, replay_esn, +-- +2.40.1 + diff --git a/queue-4.19/xfrm-fix-slab-use-after-free-in-decode_session6.patch b/queue-4.19/xfrm-fix-slab-use-after-free-in-decode_session6.patch new file mode 100644 index 00000000000..3c27367a951 --- /dev/null +++ b/queue-4.19/xfrm-fix-slab-use-after-free-in-decode_session6.patch @@ -0,0 +1,122 @@ +From c189b369d9201e0033d04175632915503d88bd85 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Jul 2023 17:40:51 +0800 +Subject: xfrm: fix slab-use-after-free in decode_session6 + +From: Zhengchao Shao + +[ Upstream commit 53223f2ed1ef5c90dad814daaaefea4e68a933c8 ] + +When the xfrm device is set to the qdisc of the sfb type, the cb field +of the sent skb may be modified during enqueuing. Then, +slab-use-after-free may occur when the xfrm device sends IPv6 packets. + +The stack information is as follows: +BUG: KASAN: slab-use-after-free in decode_session6+0x103f/0x1890 +Read of size 1 at addr ffff8881111458ef by task swapper/3/0 +CPU: 3 PID: 0 Comm: swapper/3 Not tainted 6.4.0-next-20230707 #409 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014 +Call Trace: + +dump_stack_lvl+0xd9/0x150 +print_address_description.constprop.0+0x2c/0x3c0 +kasan_report+0x11d/0x130 +decode_session6+0x103f/0x1890 +__xfrm_decode_session+0x54/0xb0 +xfrmi_xmit+0x173/0x1ca0 +dev_hard_start_xmit+0x187/0x700 +sch_direct_xmit+0x1a3/0xc30 +__qdisc_run+0x510/0x17a0 +__dev_queue_xmit+0x2215/0x3b10 +neigh_connected_output+0x3c2/0x550 +ip6_finish_output2+0x55a/0x1550 +ip6_finish_output+0x6b9/0x1270 +ip6_output+0x1f1/0x540 +ndisc_send_skb+0xa63/0x1890 +ndisc_send_rs+0x132/0x6f0 +addrconf_rs_timer+0x3f1/0x870 +call_timer_fn+0x1a0/0x580 +expire_timers+0x29b/0x4b0 +run_timer_softirq+0x326/0x910 +__do_softirq+0x1d4/0x905 +irq_exit_rcu+0xb7/0x120 +sysvec_apic_timer_interrupt+0x97/0xc0 + + +asm_sysvec_apic_timer_interrupt+0x1a/0x20 +RIP: 0010:intel_idle_hlt+0x23/0x30 +Code: 1f 84 00 00 00 00 00 f3 0f 1e fa 41 54 41 89 d4 0f 1f 44 00 00 66 90 0f 1f 44 00 00 0f 00 2d c4 9f ab 00 0f 1f 44 00 00 fb f4 44 89 e0 41 5c c3 66 0f 1f 44 00 00 f3 0f 1e fa 41 54 41 89 d4 +RSP: 0018:ffffc90000197d78 EFLAGS: 00000246 +RAX: 00000000000a83c3 RBX: ffffe8ffffd09c50 RCX: ffffffff8a22d8e5 +RDX: 0000000000000001 RSI: ffffffff8d3f8080 RDI: ffffe8ffffd09c50 +RBP: ffffffff8d3f8080 R08: 0000000000000001 R09: ffffed1026ba6d9d +R10: ffff888135d36ceb R11: 0000000000000001 R12: 0000000000000001 +R13: ffffffff8d3f8100 R14: 0000000000000001 R15: 0000000000000000 +cpuidle_enter_state+0xd3/0x6f0 +cpuidle_enter+0x4e/0xa0 +do_idle+0x2fe/0x3c0 +cpu_startup_entry+0x18/0x20 +start_secondary+0x200/0x290 +secondary_startup_64_no_verify+0x167/0x16b + +Allocated by task 939: +kasan_save_stack+0x22/0x40 +kasan_set_track+0x25/0x30 +__kasan_slab_alloc+0x7f/0x90 +kmem_cache_alloc_node+0x1cd/0x410 +kmalloc_reserve+0x165/0x270 +__alloc_skb+0x129/0x330 +inet6_ifa_notify+0x118/0x230 +__ipv6_ifa_notify+0x177/0xbe0 +addrconf_dad_completed+0x133/0xe00 +addrconf_dad_work+0x764/0x1390 +process_one_work+0xa32/0x16f0 +worker_thread+0x67d/0x10c0 +kthread+0x344/0x440 +ret_from_fork+0x1f/0x30 +The buggy address belongs to the object at ffff888111145800 +which belongs to the cache skbuff_small_head of size 640 +The buggy address is located 239 bytes inside of +freed 640-byte region [ffff888111145800, ffff888111145a80) + +As commit f855691975bb ("xfrm6: Fix the nexthdr offset in +_decode_session6.") showed, xfrm_decode_session was originally intended +only for the receive path. IP6CB(skb)->nhoff is not set during +transmission. Therefore, set the cb field in the skb to 0 before +sending packets. + +Fixes: f855691975bb ("xfrm6: Fix the nexthdr offset in _decode_session6.") +Signed-off-by: Zhengchao Shao +Signed-off-by: Steffen Klassert +Signed-off-by: Sasha Levin +--- + net/xfrm/xfrm_interface_core.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c +index 3c642328a117c..40081af62b68f 100644 +--- a/net/xfrm/xfrm_interface_core.c ++++ b/net/xfrm/xfrm_interface_core.c +@@ -354,8 +354,8 @@ static netdev_tx_t xfrmi_xmit(struct sk_buff *skb, struct net_device *dev) + + switch (skb->protocol) { + case htons(ETH_P_IPV6): +- xfrm_decode_session(skb, &fl, AF_INET6); + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); ++ xfrm_decode_session(skb, &fl, AF_INET6); + if (!dst) { + fl.u.ip6.flowi6_oif = dev->ifindex; + fl.u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC; +@@ -369,8 +369,8 @@ static netdev_tx_t xfrmi_xmit(struct sk_buff *skb, struct net_device *dev) + } + break; + case htons(ETH_P_IP): +- xfrm_decode_session(skb, &fl, AF_INET); + memset(IPCB(skb), 0, sizeof(*IPCB(skb))); ++ xfrm_decode_session(skb, &fl, AF_INET); + if (!dst) { + struct rtable *rt; + +-- +2.40.1 + diff --git a/queue-4.19/xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch b/queue-4.19/xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch new file mode 100644 index 00000000000..deb2bc2f0ac --- /dev/null +++ b/queue-4.19/xfrm-interface-rename-xfrm_interface.c-to-xfrm_inter.patch @@ -0,0 +1,42 @@ +From 9a9e8de0ba8bbf6cb3b1aa0df35b48c766efdd5b 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: 53223f2ed1ef ("xfrm: fix slab-use-after-free in decode_session6") +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 fbc4552d17b85..6e5e307f985e4 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.40.1 +