net: dsa: avoid potential use-after-free error
Subsystems (3)
PATCH v2 1/1 net: dsa: avoid potential use-after-free error
If dsa_switch_ops::port_txtstamp() returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.
---
Changes since v1:
- Fixed "Fixes:" tag (and configured my GIT)
- Adjusted commit description
net/dsa/slave.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/dsa/slave.c +3 -3
@@ -522,10 +522,10 @@ static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p,if (!clone)return ; -DSA_SKB_CB (skb)->clone = clone; - -if (ds->ops->port_txtstamp (ds, p->dp->index, clone, type)) +if (ds->ops->port_txtstamp (ds, p->dp->index, clone, type)) { +DSA_SKB_CB (skb)->clone = clone;return ; + }kfree_skb (clone); }
Signature · 8 lines
Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
Quoted 6 lines · Christian Eggers
If
dsa_switch_ops::port_txtstamp()returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.Signed-off-by Christian Eggers <[email protected]>Fixes 146d442c2357 ("net: dsa: Keep a pointer to the skb clone for TX timestamping")---
IMO this is one of the cases to which the following from Documentation/process/stable-kernel-rules.rst does not apply:
- It must fix a real bug that bothers people (not a, "This could be a problem..." type thing).
Therefore, specifying "net-next" as the target tree here as opposed to "net" is the correct choice.
Jakub Kicinski
maintainerQuoted 8 lines · On Fri, 20 Nov 2020 20:01:49 +0200 Vladimir Oltean wrote:
Quoted 6 lines · Christian Eggers
If
dsa_switch_ops::port_txtstamp()returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.Signed-off-by Christian Eggers <[email protected]>Fixes 146d442c2357 ("net: dsa: Keep a pointer to the skb clone for TX timestamping")---
Quoted 8 lines
IMO this is one of the cases to which the following from
Documentation/process/stable-kernel-rules.rstdoes not apply:- It must fix a real bug that bothers people (not a, "This could be a problem..." type thing).
Therefore, specifying "net-next" as the target tree here as opposed to "net" is the correct choice.
The commit message doesn't really explain what happens after.
Is the dangling pointer ever accessed?
Vladimir Oltean
maintainerQuoted 15 lines · Jakub Kicinski
Quoted 14 lines · On Fri, 20 Nov 2020 20:01:49 +0200 Vladimir Oltean wrote:
Quoted 6 lines · Christian Eggers
If
dsa_switch_ops::port_txtstamp()returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.Signed-off-by Christian Eggers <[email protected]>Fixes 146d442c2357 ("net: dsa: Keep a pointer to the skb clone for TX timestamping")---
IMO this is one of the cases to which the following from
Documentation/process/stable-kernel-rules.rstdoes not apply:- It must fix a real bug that bothers people (not a, "This could be a problem..." type thing).
Quoted 6 lines
Quoted 2 lines
Therefore, specifying "net-next" as the target tree here as opposed to "net" is the correct choice.
The commit message doesn't really explain what happens after.
Is the dangling pointer ever accessed?
Nothing happens afterwards. He explained that he accessed it once while working on his ksz9477 PTP series. There's no code affected by this in mainline.
Jakub Kicinski
maintainerQuoted 19 lines · On Fri, 20 Nov 2020 23:04:36 +0200 Vladimir Oltean wrote:
Quoted 18 lines · Jakub Kicinski
Quoted 16 lines · On Fri, 20 Nov 2020 20:01:49 +0200 Vladimir Oltean wrote:
Quoted 6 lines · Christian Eggers
If
dsa_switch_ops::port_txtstamp()returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.Signed-off-by Christian Eggers <[email protected]>Fixes 146d442c2357 ("net: dsa: Keep a pointer to the skb clone for TX timestamping")---
IMO this is one of the cases to which the following from
Documentation/process/stable-kernel-rules.rstdoes not apply:- It must fix a real bug that bothers people (not a, "This could be a problem..." type thing).
Therefore, specifying "net-next" as the target tree here as opposed to "net" is the correct choice.
Quoted 7 lines
Quoted 3 lines
The commit message doesn't really explain what happens after.
Is the dangling pointer ever accessed?
Nothing happens afterwards. He explained that he accessed it once while working on his ksz9477 PTP series. There's no code affected by this in mainline.
Ah, great, I'll drop the Fixes tag altogether then.
Quoted 5 lines · Christian Eggers
If
dsa_switch_ops::port_txtstamp()returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.Signed-off-by Christian Eggers <[email protected]>Fixes 146d442c2357 ("net: dsa: Keep a pointer to the skb clone for TX timestamping")
Signature · 1 line
Florian
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Thu, 19 Nov 2020 12:09:06 +0100 you wrote:
If
dsa_switch_ops::port_txtstamp()returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory.Signed-off-by Christian Eggers <[email protected]>Fixes 146d442c2357 ("net: dsa: Keep a pointer to the skb clone for TX timestamping")---
Changes since v1:
- Fixed "Fixes:" tag (and configured my GIT)
- Adjusted commit description[...]
Here is the summary with links:
- [net-next,v2] net: dsa: avoid potential use-after-free error
https://git.kernel.org/netdev/net-next/c/30abc9cd9c6b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html