From e7dc7d41f95d16601c9c66d4941cdc5c3403041f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 14 Oct 2024 16:03:41 +0200 Subject: [PATCH] 5.15-stable patches added patches: ext4-fix-warning-in-ext4_dio_write_end_io.patch net-axienet-start-napi-before-enabling-rx-tx.patch selftests-net-more-strict-check-in-net_helper.patch --- ...fix-warning-in-ext4_dio_write_end_io.patch | 64 +++++++++++++++++++ ...net-start-napi-before-enabling-rx-tx.patch | 36 +++++++++++ ...-net-more-strict-check-in-net_helper.patch | 57 +++++++++++++++++ queue-5.15/series | 3 + 4 files changed, 160 insertions(+) create mode 100644 queue-5.15/ext4-fix-warning-in-ext4_dio_write_end_io.patch create mode 100644 queue-5.15/net-axienet-start-napi-before-enabling-rx-tx.patch create mode 100644 queue-5.15/selftests-net-more-strict-check-in-net_helper.patch diff --git a/queue-5.15/ext4-fix-warning-in-ext4_dio_write_end_io.patch b/queue-5.15/ext4-fix-warning-in-ext4_dio_write_end_io.patch new file mode 100644 index 00000000000..e89333523af --- /dev/null +++ b/queue-5.15/ext4-fix-warning-in-ext4_dio_write_end_io.patch @@ -0,0 +1,64 @@ +From 619f75dae2cf117b1d07f27b046b9ffb071c4685 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Thu, 30 Nov 2023 10:56:53 +0100 +Subject: ext4: fix warning in ext4_dio_write_end_io() + +From: Jan Kara + +commit 619f75dae2cf117b1d07f27b046b9ffb071c4685 upstream. + +The syzbot has reported that it can hit the warning in +ext4_dio_write_end_io() because i_size < i_disksize. Indeed the +reproducer creates a race between DIO IO completion and truncate +expanding the file and thus ext4_dio_write_end_io() sees an inconsistent +inode state where i_disksize is already updated but i_size is not +updated yet. Since we are careful when setting up DIO write and consider +it extending (and thus performing the IO synchronously with i_rwsem held +exclusively) whenever it goes past either of i_size or i_disksize, we +can use the same test during IO completion without risking entering +ext4_handle_inode_extension() without i_rwsem held. This way we make it +obvious both i_size and i_disksize are large enough when we report DIO +completion without relying on unreliable WARN_ON. + +Reported-by: +Fixes: 91562895f803 ("ext4: properly sync file size update after O_SYNC direct IO") +Signed-off-by: Jan Kara +Reviewed-by: Ritesh Harjani (IBM) +Link: https://lore.kernel.org/r/20231130095653.22679-1-jack@suse.cz +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/file.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +--- a/fs/ext4/file.c ++++ b/fs/ext4/file.c +@@ -322,9 +322,10 @@ static void ext4_inode_extension_cleanup + return; + } + /* +- * If i_disksize got extended due to writeback of delalloc blocks while +- * the DIO was running we could fail to cleanup the orphan list in +- * ext4_handle_inode_extension(). Do it now. ++ * If i_disksize got extended either due to writeback of delalloc ++ * blocks or extending truncate while the DIO was running we could fail ++ * to cleanup the orphan list in ext4_handle_inode_extension(). Do it ++ * now. + */ + if (!list_empty(&EXT4_I(inode)->i_orphan) && inode->i_nlink) { + handle_t *handle = ext4_journal_start(inode, EXT4_HT_INODE, 2); +@@ -359,10 +360,11 @@ static int ext4_dio_write_end_io(struct + * blocks. But the code in ext4_iomap_alloc() is careful to use + * zeroed/unwritten extents if this is possible; thus we won't leave + * uninitialized blocks in a file even if we didn't succeed in writing +- * as much as we intended. ++ * as much as we intended. Also we can race with truncate or write ++ * expanding the file so we have to be a bit careful here. + */ +- WARN_ON_ONCE(i_size_read(inode) < READ_ONCE(EXT4_I(inode)->i_disksize)); +- if (pos + size <= READ_ONCE(EXT4_I(inode)->i_disksize)) ++ if (pos + size <= READ_ONCE(EXT4_I(inode)->i_disksize) && ++ pos + size <= i_size_read(inode)) + return size; + return ext4_handle_inode_extension(inode, pos, size); + } diff --git a/queue-5.15/net-axienet-start-napi-before-enabling-rx-tx.patch b/queue-5.15/net-axienet-start-napi-before-enabling-rx-tx.patch new file mode 100644 index 00000000000..cd5b8fb3f65 --- /dev/null +++ b/queue-5.15/net-axienet-start-napi-before-enabling-rx-tx.patch @@ -0,0 +1,36 @@ +From 799a829507506924add8a7620493adc1c3cfda30 Mon Sep 17 00:00:00 2001 +From: Andy Chiu +Date: Fri, 26 Jul 2024 15:06:50 +0800 +Subject: net: axienet: start napi before enabling Rx/Tx + +From: Andy Chiu + +commit 799a829507506924add8a7620493adc1c3cfda30 upstream. + +softirq may get lost if an Rx interrupt comes before we call +napi_enable. Move napi_enable in front of axienet_setoptions(), which +turns on the device, to address the issue. + +Link: https://lists.gnu.org/archive/html/qemu-devel/2024-07/msg06160.html +Fixes: cc37610caaf8 ("net: axienet: implement NAPI and GRO receive") +Signed-off-by: Andy Chiu +Reviewed-by: Eric Dumazet +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c ++++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +@@ -1912,9 +1912,9 @@ static void axienet_dma_err_handler(stru + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + axienet_set_mac_address(ndev, NULL); + axienet_set_multicast_list(ndev); +- axienet_setoptions(ndev, lp->options); + napi_enable(&lp->napi_rx); + napi_enable(&lp->napi_tx); ++ axienet_setoptions(ndev, lp->options); + } + + /** diff --git a/queue-5.15/selftests-net-more-strict-check-in-net_helper.patch b/queue-5.15/selftests-net-more-strict-check-in-net_helper.patch new file mode 100644 index 00000000000..700353d72ea --- /dev/null +++ b/queue-5.15/selftests-net-more-strict-check-in-net_helper.patch @@ -0,0 +1,57 @@ +From a71d0908e32f3dd41e355d83eeadd44d94811fd6 Mon Sep 17 00:00:00 2001 +From: Paolo Abeni +Date: Mon, 12 Feb 2024 11:19:23 +0100 +Subject: selftests: net: more strict check in net_helper + +From: Paolo Abeni + +commit a71d0908e32f3dd41e355d83eeadd44d94811fd6 upstream. + +The helper waiting for a listener port can match any socket whose +hexadecimal representation of source or destination addresses +matches that of the given port. + +Additionally, any socket state is accepted. + +All the above can let the helper return successfully before the +relevant listener is actually ready, with unexpected results. + +So far I could not find any related failure in the netdev CI, but +the next patch is going to make the critical event more easily +reproducible. + +Address the issue matching the port hex only vs the relevant socket +field and additionally checking the socket state for TCP sockets. + +Fixes: 3bdd9fd29cb0 ("selftests/net: synchronize udpgro tests' tx and rx connection") +Signed-off-by: Paolo Abeni +Link: https://lore.kernel.org/r/192b3dbc443d953be32991d1b0ca432bd4c65008.1707731086.git.pabeni@redhat.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/net_helper.sh | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/tools/testing/selftests/net/net_helper.sh ++++ b/tools/testing/selftests/net/net_helper.sh +@@ -8,13 +8,16 @@ wait_local_port_listen() + local listener_ns="${1}" + local port="${2}" + local protocol="${3}" +- local port_hex ++ local pattern + local i + +- port_hex="$(printf "%04X" "${port}")" ++ pattern=":$(printf "%04X" "${port}") " ++ ++ # for tcp protocol additionally check the socket state ++ [ ${protocol} = "tcp" ] && pattern="${pattern}0A" + for i in $(seq 10); do +- if ip netns exec "${listener_ns}" cat /proc/net/"${protocol}"* | \ +- grep -q "${port_hex}"; then ++ if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \ ++ /proc/net/"${protocol}"* | grep -q "${pattern}"; then + break + fi + sleep 0.1 diff --git a/queue-5.15/series b/queue-5.15/series index 69fd57c1673..9fbd98f8a53 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -692,3 +692,6 @@ net-handle-l3mdev-in-ip_tunnel_init_flow.patch net-seg6-fix-seg6_lookup_any_nexthop-to-handle-vrfs-using-flowi_l3mdev.patch net-vrf-determine-the-dst-using-the-original-ifindex-for-multicast.patch netfilter-ip6t_rpfilter-fix-regression-with-vrf-interfaces.patch +ext4-fix-warning-in-ext4_dio_write_end_io.patch +net-axienet-start-napi-before-enabling-rx-tx.patch +selftests-net-more-strict-check-in-net_helper.patch -- 2.47.3