From: Greg Kroah-Hartman Date: Tue, 25 Jul 2023 10:39:38 +0000 (+0200) Subject: 5.15-stable patches X-Git-Tag: v5.4.251~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b8e12133e97cf331d0450680aed4a81021c3f5a;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: nixge-fix-mac-address-error-handling-again.patch --- diff --git a/queue-5.15/nixge-fix-mac-address-error-handling-again.patch b/queue-5.15/nixge-fix-mac-address-error-handling-again.patch new file mode 100644 index 00000000000..0087c8da1ad --- /dev/null +++ b/queue-5.15/nixge-fix-mac-address-error-handling-again.patch @@ -0,0 +1,58 @@ +From a68229ca634066975fff6d4780155bd2eb14a82a Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Mon, 22 Nov 2021 16:02:49 +0100 +Subject: nixge: fix mac address error handling again + +From: Arnd Bergmann + +commit a68229ca634066975fff6d4780155bd2eb14a82a upstream. + +The change to eth_hw_addr_set() caused gcc to correctly spot a +bug that was introduced in an earlier incorrect fix: + +In file included from include/linux/etherdevice.h:21, + from drivers/net/ethernet/ni/nixge.c:7: +In function '__dev_addr_set', + inlined from 'eth_hw_addr_set' at include/linux/etherdevice.h:319:2, + inlined from 'nixge_probe' at drivers/net/ethernet/ni/nixge.c:1286:3: +include/linux/netdevice.h:4648:9: error: 'memcpy' reading 6 bytes from a region of size 0 [-Werror=stringop-overread] + 4648 | memcpy(dev->dev_addr, addr, len); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +As nixge_get_nvmem_address() can return either NULL or an error +pointer, the NULL check is wrong, and we can end up reading from +ERR_PTR(-EOPNOTSUPP), which gcc knows to contain zero readable +bytes. + +Make the function always return an error pointer again but fix +the check to match that. + +Fixes: f3956ebb3bf0 ("ethernet: use eth_hw_addr_set() instead of ether_addr_copy()") +Fixes: abcd3d6fc640 ("net: nixge: Fix error path for obtaining mac address") +Signed-off-by: Arnd Bergmann +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/ni/nixge.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/ni/nixge.c ++++ b/drivers/net/ethernet/ni/nixge.c +@@ -1211,7 +1211,7 @@ static void *nixge_get_nvmem_address(str + + cell = nvmem_cell_get(dev, "address"); + if (IS_ERR(cell)) +- return NULL; ++ return cell; + + mac = nvmem_cell_read(cell, &cell_size); + nvmem_cell_put(cell); +@@ -1284,7 +1284,7 @@ static int nixge_probe(struct platform_d + ndev->max_mtu = NIXGE_JUMBO_MTU; + + mac_addr = nixge_get_nvmem_address(&pdev->dev); +- if (mac_addr && is_valid_ether_addr(mac_addr)) { ++ if (!IS_ERR(mac_addr) && is_valid_ether_addr(mac_addr)) { + eth_hw_addr_set(ndev, mac_addr); + kfree(mac_addr); + } else { diff --git a/queue-5.15/series b/queue-5.15/series index c03630a6c7e..e81fd5cd703 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -75,3 +75,4 @@ tcp-annotate-data-races-around-fastopenq.max_qlen.patch net-phy-prevent-stale-pointer-dereference-in-phy_ini.patch jbd2-recheck-chechpointing-non-dirty-buffer.patch tracing-histograms-return-an-error-if-we-fail-to-add-histogram-to-hist_vars-list.patch +nixge-fix-mac-address-error-handling-again.patch