FAILED: patch "[PATCH] net/ncsi: fix locking in Get MAC Address handling" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 9e2bbab94b88295dcc57c7580393c9ee08d7314d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025012017-prancing-barracuda-8925@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9e2bbab94b88295dcc57c7580393c9ee08d7314d Mon Sep 17 00:00:00 2001
From: Paul Fertser <[email protected]>
Date: Thu, 9 Jan 2025 17:50:54 +0300
Subject: [PATCH] net/ncsi: fix locking in Get MAC Address handling
Obtaining RTNL lock in a response handler is not allowed since it runs in an atomic softirq context. Postpone setting the MAC address by adding a dedicated step to the configuration FSM.
net/ncsi/internal.h +2 -0
@@ -289,6 +289,7 @@ enum { ncsi_dev_state_config_sp =0x0301 , ncsi_dev_state_config_cis, ncsi_dev_state_config_oem_gma, + ncsi_dev_state_config_apply_mac, ncsi_dev_state_config_clear_vids, ncsi_dev_state_config_svf, ncsi_dev_state_config_ev,
@@ -322,6 +323,7 @@ struct ncsi_dev_priv {#define NCSI_DEV_RESHUFFLE 4#define NCSI_DEV_RESET 8/* Reset state of NC */ unsigned int gma_flag;/* OEM GMA flag */ +struct sockaddr pending_mac;/* MAC address received from GMA */ spinlock_t lock;/* Protect the NCSI device */ unsigned int package_probe_id;/* Current ID during probe */ unsigned int package_num;/* Number of packages */
net/ncsi/ncsi-manage.c +14 -2
@@ -1038,7 +1038,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) : ncsi_dev_state_config_clear_vids;break ;case ncsi_dev_state_config_oem_gma: - nd->state = ncsi_dev_state_config_clear_vids; + nd->state = ncsi_dev_state_config_apply_mac; nca.package = np->id; nca.channel = nc->id;
@@ -1050,10 +1050,22 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) nca.type =NCSI_PKT_CMD_OEM ; ret =ncsi_gma_handler (&nca, nc->version.mf_id); } -if (ret <0 ) +if (ret <0 ) { + nd->state = ncsi_dev_state_config_clear_vids;schedule_work (&ndp->work); + }break ; +case ncsi_dev_state_config_apply_mac: +rtnl_lock (); + ret =dev_set_mac_address (dev, &ndp->pending_mac,NULL ); +rtnl_unlock (); +if (ret <0 ) +netdev_warn (dev,"NCSI: 'Writing MAC address to device failed\n" ); + + nd->state = ncsi_dev_state_config_clear_vids; + + fallthrough;case ncsi_dev_state_config_clear_vids:case ncsi_dev_state_config_svf:case ncsi_dev_state_config_ev:
net/ncsi/ncsi-rsp.c +6 -13
@@ -628,16 +628,14 @@ static int ncsi_rsp_handler_snfc(struct ncsi_request *nr)static int ncsi_rsp_handler_oem_gma (struct ncsi_request *nr,int mfr_id) {struct ncsi_dev_priv *ndp = nr->ndp; +struct sockaddr *saddr = &ndp->pending_mac;struct net_device *ndev = ndp->ndev.dev;struct ncsi_rsp_oem_pkt *rsp; -struct sockaddr saddr;u32 mac_addr_off =0 ; -int ret =0 ;/* Get the response header */ rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header (nr->rsp); - saddr.sa_family = ndev->type; ndev->priv_flags |=IFF_LIVE_ADDR_CHANGE ;if (mfr_id ==NCSI_OEM_MFR_BCM_ID ) mac_addr_off =BCM_MAC_ADDR_OFFSET ;
@@ -646,22 +644,17 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id)else if (mfr_id ==NCSI_OEM_MFR_INTEL_ID ) mac_addr_off =INTEL_MAC_ADDR_OFFSET ; -memcpy (saddr.sa_data, &rsp->data[mac_addr_off],ETH_ALEN ); + saddr->sa_family = ndev->type; +memcpy (saddr->sa_data, &rsp->data[mac_addr_off],ETH_ALEN );if (mfr_id ==NCSI_OEM_MFR_BCM_ID || mfr_id ==NCSI_OEM_MFR_INTEL_ID ) -eth_addr_inc ((u8 *)saddr.sa_data); -if (!is_valid_ether_addr ((const u8 *)saddr.sa_data)) +eth_addr_inc ((u8 *)saddr->sa_data); +if (!is_valid_ether_addr ((const u8 *)saddr->sa_data))return -ENXIO ;/* Set the flag for GMA command which should only be called once */ ndp->gma_flag =1 ; -rtnl_lock (); - ret =dev_set_mac_address (ndev, &saddr,NULL ); -rtnl_unlock (); -if (ret <0 ) -netdev_warn (ndev,"NCSI: 'Writing mac address to device failed\n" ); - -return ret; +return 0 ; }/* Response handler for Mellanox card */