Bug fixes from XDP and perout series
Subsystems (4)
PATCH v3 1/3 net: ti: icssg-prueth: Fix kernel warning while bringing down network interface
In reply to Meghana MalladiDuring network interface initialization, the NIC driver needs to register its Rx queue with the XDP, to ensure the incoming XDP buffer carries a pointer reference to this info and is stored inside xdp_rxq_info.
While this struct isn't tied to XDP prog, if there are any changes in Rx queue, the NIC driver needs to stop the Rx queue by unregistering with XDP before purging and reallocating memory. Drop page_pool destroy during Rx channel reset as this is already handled by XDP during xdp_rxq_info_unreg (Rx queue unregister), failing to do will cause the following warning:
warning logs: https://gist.github.com/MeghanaMalladiTI/eb627e5dc8de24e42d7d46572c13e576
--- drivers/net/ethernet/ti/icssg/icssg_common.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +0 -3
@@ -1215,9 +1215,6 @@ void prueth_reset_rx_chan(struct prueth_rx_chn *chn, prueth_rx_cleanup, !!i);if (disable)k3_udma_glue_disable_rx_chn (chn->rx_chn); - -page_pool_destroy (chn->pg_pool); - chn->pg_pool =NULL ; }EXPORT_SYMBOL_GPL (prueth_reset_rx_chan);
Signature · 1 line
2.43.0
v3 cover Bug fixes from XDP and perout series
This patch series consists of bug fixes from the XDP/perout series:
1. Fixes a kernel warning that occurs when bringing down the network interface.
2. Resolves a potential NULL pointer dereference in the emac_xmit_xdp_frame() function.
3. Resolves a potential NULL pointer dereference in the icss_iep_perout_enable() function
v2: https://lore.kernel.org/all/[email protected]/
Changes from v2 (v3-v2):
- Posting to net tree as the features have been merged to net.
Meghana Malladi (3):
net: ti: icssg-prueth: Fix kernel warning while bringing down network
interface
net: ti: icssg-prueth: Fix possible NULL pointer dereference inside
emac_xmit_xdp_frame()
net: ti: icss-iep: Fix possible NULL pointer dereference for perout
request
drivers/net/ethernet/ti/icssg/icss_iep.c | 4 ++-- drivers/net/ethernet/ti/icssg/icssg_common.c | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-)
base-commit: 2eb6c6a34cb1c22b09b219390cdff0f02cd90258
Signature · 1 line
2.43.0
PATCH v3 3/3 net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled, (iep->pps_enabled is not cleared during interface bring down) and driver will just return true even though there is no signal. Fix this by setting pps and perout flags to false instead of disabling perout to avoid possible null pointer dereference.
---
Changes from v2(v3-v2):
- Add Reported-by tag and link to the bug reported by Dan Carpenter <[email protected]>
- drop calling icss_iep_perout_enable() for disabling perout and set perout to false instead
drivers/net/ethernet/ti/icssg/icss_iep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/icssg/icss_iep.c +2 -2
@@ -820,9 +820,9 @@ int icss_iep_exit(struct icss_iep *iep)icss_iep_disable (iep);if (iep->pps_enabled) -icss_iep_pps_enable (iep, false); + iep->pps_enabled = false;else if (iep->perout_enabled) -icss_iep_perout_enable (iep,NULL , false); + iep->perout_enabled = false;return 0 ; }
Signature · 1 line
2.43.0
PATCH v3 2/3 net: ti: icssg-prueth: Fix possible NULL pointer dereference inside emac_xmit_xdp_frame()
In reply to Meghana MalladiThere is an error check inside emac_xmit_xdp_frame() function which is called when the driver wants to transmit XDP frame, to check if the allocated tx descriptor is NULL, if true to exit and return ICSSG_XDP_CONSUMED implying failure in transmission.
In this case trying to free a descriptor which is NULL will result in kernel crash due to NULL pointer dereference. Fix this error handling and increase netdev tx_dropped stats in the caller of this function if the function returns ICSSG_XDP_CONSUMED.
---
Changes from v2(v3-v2):
- Add Reported-by tag and link to the bug reported by Dan Carpenter <[email protected]>
drivers/net/ethernet/ti/icssg/icssg_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +4 -2
@@ -583,7 +583,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac, first_desc =k3_cppi_desc_pool_alloc (tx_chn->desc_pool);if (!first_desc) {netdev_dbg (ndev,"xdp tx: failed to allocate descriptor\n" ); - goto drop_free_descs;/* drop */ +return ICSSG_XDP_CONSUMED ;/* drop */ }if (page) {/* already DMA mapped by page_pool */
@@ -671,8 +671,10 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp, q_idx =smp_processor_id () % emac->tx_ch_num; result =emac_xmit_xdp_frame (emac, xdpf, page, q_idx); -if (result ==ICSSG_XDP_CONSUMED ) +if (result ==ICSSG_XDP_CONSUMED ) { + ndev->stats.tx_dropped++; goto drop; + }dev_sw_netstats_rx_add (ndev, xdpf->len);return result;
Signature · 1 line
2.43.0
Re: [PATCH net v3 1/3] net: ti: icssg-prueth: Fix kernel warning while bringing down network interface
In reply to Meghana MalladiQuoted 11 lines · Meghana Malladi
During network interface initialization, the NIC driver needs to register its Rx queue with the XDP, to ensure the incoming XDP buffer carries a pointer reference to this info and is stored inside
xdp_rxq_info.While this struct isn't tied to XDP prog, if there are any changes in Rx queue, the NIC driver needs to stop the Rx queue by unregistering with XDP before purging and reallocating memory. Drop
page_pooldestroy during Rx channel reset as this is already handled by XDP duringxdp_rxq_info_unreg(Rx queue unregister), failing to do will cause the following warning:
Quoted 5 lines
warning logs: https://gist.github.com/MeghanaMalladiTI/eb627e5dc8de24e42d7d46572c13e576
Fixes 46eeb90f03e0 ("net: ti: icssg-prueth: Use page_pool API for RX buffer allocation")Signed-off-by Meghana Malladi <[email protected]>Reviewed-by Simon Horman <[email protected]>
Re: [PATCH net v3 2/3] net: ti: icssg-prueth: Fix possible NULL pointer dereference inside emac_xmit_xdp_frame()
In reply to Meghana MalladiQuoted 10 lines · Meghana Malladi
There is an error check inside
emac_xmit_xdp_frame()function which is called when the driver wants to transmit XDP frame, to check if the allocated tx descriptor is NULL, if true to exit and returnICSSG_XDP_CONSUMEDimplying failure in transmission.In this case trying to free a descriptor which is NULL will result in kernel crash due to NULL pointer dereference. Fix this error handling and increase netdev
tx_droppedstats in the caller of this function if the function returnsICSSG_XDP_CONSUMED.
Quoted 5 lines
Fixes 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support")Reported-by Dan Carpenter <[email protected]>Signed-off-by Meghana Malladi <[email protected]>Reviewed-by Simon Horman <[email protected]>
Roger Quadros
reviewerRe: [PATCH net v3 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
In reply to Meghana MalladiMeghana,
Quoted 7 lines · Meghana Malladi
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled,
How? aren't we calling icss_iep_pps_enable(iep, false)? wouldn't this disable the IEP and clear the iep->pps_enabled flag?
And, what if you brought 2 interfaces of the same ICSS instances up but put only 1 interface down and up?
Quoted 34 lines
(
iep->pps_enabledis not cleared during interface bring down) and driver will just return true even though there is no signal. Fix this by setting pps and perout flags to false instead of disabling perout to avoid possible null pointer dereference.Fixes 9b115361248d ("net: ti: icssg-prueth: Fix clearing of IEP_CMP_CFG registers during iep_init")Reported-by Dan Carpenter <[email protected]>Signed-off-by Meghana Malladi <[email protected]>---
Changes from v2(v3-v2):
- Add Reported-by tag and link to the bug reported by Dan Carpenter <[email protected]>
- drop callingicss_iep_perout_enable()for disabling perout and set perout to false insteaddrivers/net/ethernet/ti/icssg/icss_iep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/ti/icssg/icss_iep.c +2
-2@@ -820,9 +820,9 @@ int icss_iep_exit(struct icss_iep *iep)icss_iep_disable (iep);if (iep->pps_enabled) -icss_iep_pps_enable (iep, false); + iep->pps_enabled = false;else if (iep->perout_enabled) -icss_iep_perout_enable (iep,NULL , false); + iep->perout_enabled = false;return 0 ; }
Signature · 2 lines
cheers, -roger
Re: [PATCH net v3 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
Quoted 8 lines · Roger Quadros
Meghana,
Quoted 5 lines · Meghana Malladi
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
Quoted 6 lines
Quoted 2 lines
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled,
How? aren't we calling
icss_iep_pps_enable(iep, false)? wouldn't this disable the IEP and clear theiep->pps_enabledflag?
The whole purpose of calling icss_iep_pps_enable(iep, false) is to clear iep->pps_enabled flag, because if this flag is not cleared it hinders generating new pps signal (with the newly loaded firmware) once any of the interfaces are up (check icss_iep_perout_enable()), so instead of calling icss_iep_pps_enable(iep, false) I am just clearing the iep->pps_enabled flag.
Quoted 3 lines
And, what if you brought 2 interfaces of the same ICSS instances up but put only 1 interface down and up?
Then the flag need not be disabled if only one interface is brought down because the IEP is still alive and all the IEP configuration (including pps/perout) is still valid.
please refer for more details: https://lore.kernel.org/all/[email protected]/
Quoted 35 lines
Quoted 34 lines
(
iep->pps_enabledis not cleared during interface bring down) and driver will just return true even though there is no signal. Fix this by setting pps and perout flags to false instead of disabling perout to avoid possible null pointer dereference.Fixes 9b115361248d ("net: ti: icssg-prueth: Fix clearing of IEP_CMP_CFG registers during iep_init")Reported-by Dan Carpenter <[email protected]>Signed-off-by Meghana Malladi <[email protected]>---
Changes from v2(v3-v2):
- Add Reported-by tag and link to the bug reported by Dan Carpenter <[email protected]>
- drop callingicss_iep_perout_enable()for disabling perout and set perout to false insteaddrivers/net/ethernet/ti/icssg/icss_iep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/ti/icssg/icss_iep.c +2
-2@@ -820,9 +820,9 @@ int icss_iep_exit(struct icss_iep *iep)icss_iep_disable (iep);if (iep->pps_enabled) -icss_iep_pps_enable (iep, false); + iep->pps_enabled = false;else if (iep->perout_enabled) -icss_iep_perout_enable (iep,NULL , false); + iep->perout_enabled = false;return 0 ; }
Paolo Abeni
maintainerRe: [PATCH net v3 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
Quoted 14 lines · Meghana
Quoted 6 lines · Roger Quadros
Quoted 5 lines · Meghana Malladi
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
Quoted 6 lines
Quoted 2 lines
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled,
How? aren't we calling
icss_iep_pps_enable(iep, false)? wouldn't this disable the IEP and clear theiep->pps_enabledflag?
Quoted 6 lines
The whole purpose of calling
icss_iep_pps_enable(iep, false)is to cleariep->pps_enabledflag, because if this flag is not cleared it hinders generating new pps signal (with the newly loaded firmware) once any of the interfaces are up (checkicss_iep_perout_enable()), so instead of callingicss_iep_pps_enable(iep, false)I am just clearing theiep->pps_enabledflag.
IDK what Roger thinks, but the above is not clear to me. I read it as you are stating that icss_iep_pps_enable() indeed clears the flag, so i don't see/follow the reasoning behind this change.
Skimmir over the code, icss_iep_pps_enable() could indeed avoid clearing the flag under some circumstances is that the reason?
Possibly a more describing commit message would help.
Quoted 7 lines
Quoted 3 lines
And, what if you brought 2 interfaces of the same ICSS instances up but put only 1 interface down and up?
Then the flag need not be disabled if only one interface is brought down because the IEP is still alive and all the IEP configuration (including pps/perout) is still valid.
I read the above as stating this fix is not correct in such scenario, leading to the wrong final state.
I think it would be better to either give a better reasoning about this change in the commit message or refactor it to handle even such scenario,
Thanks,
Paolo
Roger Quadros
reviewerRe: [PATCH net v3 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
Quoted 22 lines · Paolo Abeni
Quoted 14 lines · Meghana
Quoted 6 lines · Roger Quadros
Quoted 5 lines · Meghana Malladi
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
Quoted 6 lines
Quoted 2 lines
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled,
How? aren't we calling
icss_iep_pps_enable(iep, false)? wouldn't this disable the IEP and clear theiep->pps_enabledflag?Quoted 6 lines
The whole purpose of calling
icss_iep_pps_enable(iep, false)is to cleariep->pps_enabledflag, because if this flag is not cleared it hinders generating new pps signal (with the newly loaded firmware) once any of the interfaces are up (checkicss_iep_perout_enable()), so instead of callingicss_iep_pps_enable(iep, false)I am just clearing theiep->pps_enabledflag.
Quoted 8 lines
IDK what Roger thinks, but the above is not clear to me. I read it as you are stating that
icss_iep_pps_enable()indeed clears the flag, so i don't see/follow the reasoning behind this change.Skimmir over the code,
icss_iep_pps_enable()could indeed avoid clearing the flag under some circumstances is that the reason?Possibly a more describing commit message would help.
I would expect that modifying the xxx_enabled flag should be done only in the icss_iep_xxx_enable() function. Doing it anywhere else will be difficult to track/debug in the long term.
I don't see why the flag needs to be set anywhere else. Maye better to improve logic inside icss_iep_pps_enable() like Paolo suggests.
Quoted 19 lines
Quoted 8 lines
Quoted 4 lines
And, what if you brought 2 interfaces of the same ICSS instances up but put only 1 interface down and up?
Then the flag need not be disabled if only one interface is brought down because the IEP is still alive and all the IEP configuration (including pps/perout) is still valid.
I read the above as stating this fix is not correct in such scenario, leading to the wrong final state.
I think it would be better to either give a better reasoning about this change in the commit message or refactor it to handle even such scenario,
Thanks,
Paolo
Signature · 2 lines
cheers, -roger
Re: [EXTERNAL] Re: [PATCH net v3 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
In reply to Paolo AbeniQuoted 23 lines · Paolo Abeni
On 4/2/25 2: 37 PM, Malladi, Meghana wrote: > On 4/2/2025 5: 58 PM, Roger Quadros wrote: >> On 28/03/2025 12: 24, Meghana Malladi wrote: >>> ICSS IEP driver has flags to check if perout or pps has been enabled >>> at ZjQcmQRYFpfptBannerStart
This message was sent from outside of Texas Instruments.
Do not click links or open attachments unless you recognize the source of this email and know the content is safe.
Report Suspicious
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/G3vK! updqndalvOwRqgXOXDPJf9wy4vKojW68gavBCIsz5DlBLvSeawwT53qgFGcvIm0ULRBQkJv028AcR194Ei9ZDPp5ily-uAw$>
ZjQcmQRYFpfptBannerEndQuoted 14 lines · Meghana
Quoted 12 lines · Roger Quadros
Quoted 7 lines · Meghana Malladi
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled,
How? aren't we calling
icss_iep_pps_enable(iep, false)? wouldn't this disable the IEP and clear theiep->pps_enabledflag?
Quoted 6 lines
Quoted 1 line
The whole purpose of calling
icss_iep_pps_enable(iep, false)is to cleariep->pps_enabledflag, because if this flag is not cleared it hinders generating new pps signal (with the newly loaded firmware) once any of the interfaces are up (checkicss_iep_perout_enable()), so instead of callingicss_iep_pps_enable(iep, false)I am just clearing theiep->pps_enabledflag.IDK what Roger thinks, but the above is not clear to me. I read it as you are stating that
icss_iep_pps_enable()indeed clears the flag, so i don't see/follow the reasoning behind this change.
The reason behind this change is to fix the possible null pointer dereference which will occur when icss_iep_perout_enable(iep, NULL, false) is called during icss_iep_exit(), my bad for not mentioning it clearly in the commit message.
Quoted 3 lines
Skimmir over the code,
icss_iep_pps_enable()could indeed avoid clearing the flag under some circumstances is that the reason?
icss_iep_pps_enable() does indeed clear the flag, but icss_iep_perout_enable() doesn't due to the null pointer dereference. So instead of calling these functions for clearing the flag, we can simply just clear the flag directly.
Quoted 2 lines
Possibly a more describing commit message would help.
Yes agreed. I will update it for v4.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
And, what if you brought 2 interfaces of the same ICSS instances up but put only 1 interface down and up?
Then the flag need not be disabled if only one interface is brought down because the IEP is still alive and all the IEP configuration (including pps/perout) is still valid.
I read the above as stating this fix is not correct in such scenario, leading to the wrong final state.
No it is the correct scenario. When you bring down all the existing interfaces (be it one or two, when whatever is up goes down) you unload the existing firmware and clear the all the driver configuration (this flag also needs to be cleared) to ensure everything starts with a clean state.
Quoted 7 lines
I think it would be better to either give a better reasoning about this change in the commit message or refactor it to handle even such scenario,
Thanks,
Paolo
Re: [PATCH net v3 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
In reply to Roger QuadrosHi Roger,
Quoted 29 lines · Roger Quadros
Quoted 26 lines · Paolo Abeni
Quoted 14 lines · Meghana
Quoted 6 lines · Roger Quadros
Quoted 5 lines · Meghana Malladi
ICSS IEP driver has flags to check if perout or pps has been enabled at any given point of time. Whenever there is request to enable or disable the signal, the driver first checks its enabled or disabled and acts accordingly.
Quoted 6 lines
Quoted 2 lines
After bringing the interface down and up, calling PPS/perout enable doesn't work as the driver believes PPS is already enabled,
How? aren't we calling
icss_iep_pps_enable(iep, false)? wouldn't this disable the IEP and clear theiep->pps_enabledflag?Quoted 6 lines
The whole purpose of calling
icss_iep_pps_enable(iep, false)is to cleariep->pps_enabledflag, because if this flag is not cleared it hinders generating new pps signal (with the newly loaded firmware) once any of the interfaces are up (checkicss_iep_perout_enable()), so instead of callingicss_iep_pps_enable(iep, false)I am just clearing theiep->pps_enabledflag.IDK what Roger thinks, but the above is not clear to me. I read it as you are stating that
icss_iep_pps_enable()indeed clears the flag, so i don't see/follow the reasoning behind this change.
Quoted 9 lines
Quoted 4 lines
Skimmir over the code,
icss_iep_pps_enable()could indeed avoid clearing the flag under some circumstances is that the reason?Possibly a more describing commit message would help.
I would expect that modifying the
xxx_enabledflag should be done only in theicss_iep_xxx_enable()function. Doing it anywhere else will be difficult to track/debug in the long term.
There is no problem with calling icss_iep_pps_enable() for clearing the pps_enable flag. Problem comes with icss_iep_perout_enable(), causing null pointer dereference for the NULL perout request argument we are passing just for clearing the perout_enable flag.
Quoted 3 lines
I don't see why the flag needs to be set anywhere else. Maye better to improve logic inside
icss_iep_pps_enable()like Paolo suggests.
Ok, one thing I can do is create a ptp_perout_request to disable perout instead of passing NULL to icss_iep_perout_enable(). What are your thoughts on this ?
Quoted 20 lines
Quoted 19 lines
Quoted 8 lines
Quoted 4 lines
And, what if you brought 2 interfaces of the same ICSS instances up but put only 1 interface down and up?
Then the flag need not be disabled if only one interface is brought down because the IEP is still alive and all the IEP configuration (including pps/perout) is still valid.
I read the above as stating this fix is not correct in such scenario, leading to the wrong final state.
I think it would be better to either give a better reasoning about this change in the commit message or refactor it to handle even such scenario,
Thanks,
Paolo