leds: trigger: netdev: Fix kernel panic on interface rename trig notify
Subsystems (2)
PATCH 1/1 leds: trigger: netdev: Fix kernel panic on interface rename trig notify
Commit d5e01266e7f5 ("leds: trigger: netdev: add additional specific link speed mode") in the various changes, reworked the way to set the LINKUP mode in commit cee4bd16c319 ("leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename") and moved it to a generic function.
This changed the logic where, in the previous implementation the dev from the trigger event was used to check if the carrier was ok, but in the new implementation with the generic function, the dev in trigger_data is used instead.
This is problematic and cause a possible kernel panic due to the fact that the dev in the trigger_data still reference the old one as the new one (passed from the trigger event) still has to be hold and saved in the trigger_data struct (done in the NETDEV_REGISTER case).
On calling of get_device_state(), an invalid net_dev is used and this cause a kernel panic.
To handle this correctly, move the call to get_device_state() after the new net_dev is correctly set in trigger_data (in the NETDEV_REGISTER case) and correctly parse the new dev.
--- drivers/leds/trigger/ledtrig-netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/trigger/ledtrig-netdev.c +2 -2
@@ -504,12 +504,12 @@ static int netdev_trig_notify(struct notifier_block *nb, trigger_data->duplex =DUPLEX_UNKNOWN ;switch (evt) {case NETDEV_CHANGENAME : -get_device_state (trigger_data); - fallthrough;case NETDEV_REGISTER :dev_put (trigger_data->net_dev);dev_hold (dev); trigger_data->net_dev = dev; +if (evt ==NETDEV_CHANGENAME ) +get_device_state (trigger_data);break ;case NETDEV_UNREGISTER :dev_put (trigger_data->net_dev);
Signature · 1 line
2.43.0
Quoted 18 lines · Christian Marangi
Commit
d5e01266e7f5("leds: trigger: netdev: add additional specific link speed mode") in the various changes, reworked the way to set the LINKUP mode in commitcee4bd16c319("leds: trigger: netdev: RecheckNETDEV_LED_MODE_LINKUPon dev rename") and moved it to a generic function.This changed the logic where, in the previous implementation the dev from the trigger event was used to check if the carrier was ok, but in the new implementation with the generic function, the dev in
trigger_datais used instead.This is problematic and cause a possible kernel panic due to the fact that the dev in the
trigger_datastill reference the old one as the new one (passed from the trigger event) still has to be hold and saved in thetrigger_datastruct (done in theNETDEV_REGISTERcase).On calling of
get_device_state(), an invalidnet_devis used and this cause a kernel panic.
Quoted 7 lines
To handle this correctly, move the call to
get_device_state()after the newnet_devis correctly set intrigger_data(in theNETDEV_REGISTERcase) and correctly parse the new dev.Fixes d5e01266e7f5 ("leds: trigger: netdev: add additional specific link speed mode")Signed-off-by Christian Marangi <[email protected]>
This should have 'net' in the subject line, to indicate which tree its for.
Otherwise:
Andrew
Lee Jones
maintainerQuoted 23 lines · Andrew Lunn
Quoted 22 lines · Christian Marangi
Commit
d5e01266e7f5("leds: trigger: netdev: add additional specific link speed mode") in the various changes, reworked the way to set the LINKUP mode in commitcee4bd16c319("leds: trigger: netdev: RecheckNETDEV_LED_MODE_LINKUPon dev rename") and moved it to a generic function.This changed the logic where, in the previous implementation the dev from the trigger event was used to check if the carrier was ok, but in the new implementation with the generic function, the dev in
trigger_datais used instead.This is problematic and cause a possible kernel panic due to the fact that the dev in the
trigger_datastill reference the old one as the new one (passed from the trigger event) still has to be hold and saved in thetrigger_datastruct (done in theNETDEV_REGISTERcase).On calling of
get_device_state(), an invalidnet_devis used and this cause a kernel panic.To handle this correctly, move the call to
get_device_state()after the newnet_devis correctly set intrigger_data(in theNETDEV_REGISTERcase) and correctly parse the new dev.
Quoted 6 lines
Quoted 3 lines
Fixes d5e01266e7f5 ("leds: trigger: netdev: add additional specific link speed mode")Signed-off-by Christian Marangi <[email protected]>This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Contributors aren't obliged to know anything about merging strategies.
Why does this need to go in via net?
Quoted 3 lines
Otherwise:
Reviewed-by Andrew Lunn <[email protected]>
Thanks. Always very useful.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 6 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
Andrew
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Quoted 8 lines
Quoted 1 line
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
I'm always a bit confused when I have to send patch to mixed subsystem (not the case but for net trigger it's almost that). Sorry for the confusion/noise.
Quoted 5 lines
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
This is strictly a fix, no dependency or anything like that. Maybe using net as target would make this faster to merge (since net is for fix only and this has to be backported) than using leds-next?
Again if needed I can send v2 with the correct tag for net subsystem if better.
Signature · 1 line
Ansuel
Lee Jones
maintainerQuoted 15 lines · Christian Marangi
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Quoted 8 lines
Quoted 1 line
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
Quoted 3 lines
I'm always a bit confused when I have to send patch to mixed subsystem (not the case but for net trigger it's almost that). Sorry for the confusion/noise.
When you have a truly cross-subsystem patch, it's up to you.
- Mention both e.g. leds/net:
- Mention neither e.g. <device>:
- Mention the one that is most relevant
An example of the last option might be when the lion's share of the changes occur in one subsystem and only header files are changed in the other.
In an ideal world i.e. when there are no build-time/runtime deps between them, changes should be separated out into their own commits.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
This is strictly a fix, no dependency or anything like that. Maybe using net as target would make this faster to merge (since net is for fix only and this has to be backported) than using leds-next?
We have leds-fixes for that.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 27 lines · Lee Jones
Quoted 15 lines · Christian Marangi
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Quoted 8 lines
Quoted 1 line
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
Quoted 3 lines
I'm always a bit confused when I have to send patch to mixed subsystem (not the case but for net trigger it's almost that). Sorry for the confusion/noise.
When you have a truly cross-subsystem patch, it's up to you.
- Mention both e.g. leds/net:
- Mention neither e.g. <device>:
- Mention the one that is most relevant
Quoted 7 lines
An example of the last option might be when the lion's share of the changes occur in one subsystem and only header files are changed in the other.
In an ideal world i.e. when there are no build-time/runtime deps between them, changes should be separated out into their own commits.
Thanks a lot for the explaination and the examples!
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
Quoted 6 lines
Quoted 3 lines
This is strictly a fix, no dependency or anything like that. Maybe using net as target would make this faster to merge (since net is for fix only and this has to be backported) than using leds-next?
We have leds-fixes for that.
Oh! No idea, should I add a tag to the patch to target that branch specifically?
Anyway Since we have leds-fixes and this is leds related I think it's ok to use that and don't disturb net subsystem.
(again IT IS a kernel panic but happens only on some specific situation so it's not that critical)
Signature · 1 line
Ansuel
Lee Jones
maintainerQuoted 48 lines · Christian Marangi
Quoted 27 lines · Lee Jones
Quoted 15 lines · Christian Marangi
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Quoted 8 lines
Quoted 1 line
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
Quoted 3 lines
I'm always a bit confused when I have to send patch to mixed subsystem (not the case but for net trigger it's almost that). Sorry for the confusion/noise.
When you have a truly cross-subsystem patch, it's up to you.
- Mention both e.g. leds/net:
- Mention neither e.g. <device>:
- Mention the one that is most relevantQuoted 7 lines
An example of the last option might be when the lion's share of the changes occur in one subsystem and only header files are changed in the other.
In an ideal world i.e. when there are no build-time/runtime deps between them, changes should be separated out into their own commits.
Thanks a lot for the explaination and the examples!
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
This is strictly a fix, no dependency or anything like that. Maybe using net as target would make this faster to merge (since net is for fix only and this has to be backported) than using leds-next?
Quoted 5 lines
Quoted 2 lines
We have leds-fixes for that.
Oh! No idea, should I add a tag to the patch to target that branch specifically?
You don't need to do anything special.
The Fixes: tag is enough to let us know that this is a fix.
If the commit mentioned in Fixes: was accepted as part of the last merge-window, it'll be sent to the -rcs in good time. If it fixes a commit which was introduced in a previous cycle, it'll be submitted during the next merge-window.
Quoted 2 lines
Anyway Since we have leds-fixes and this is leds related I think it's ok to use that and don't disturb net subsystem.
There is no reason why this should be merged via netdev.
Quoted 2 lines
(again IT IS a kernel panic but happens only on some specific situation so it's not that critical)
Signature · 1 line
Lee Jones [李琼斯]
Lee Jones
maintainerQuoted 56 lines · Lee Jones
Quoted 48 lines · Christian Marangi
Quoted 27 lines · Lee Jones
Quoted 15 lines · Christian Marangi
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Quoted 8 lines
Quoted 1 line
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
Quoted 3 lines
I'm always a bit confused when I have to send patch to mixed subsystem (not the case but for net trigger it's almost that). Sorry for the confusion/noise.
When you have a truly cross-subsystem patch, it's up to you.
- Mention both e.g. leds/net:
- Mention neither e.g. <device>:
- Mention the one that is most relevantQuoted 7 lines
An example of the last option might be when the lion's share of the changes occur in one subsystem and only header files are changed in the other.
In an ideal world i.e. when there are no build-time/runtime deps between them, changes should be separated out into their own commits.
Thanks a lot for the explaination and the examples!
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
This is strictly a fix, no dependency or anything like that. Maybe using net as target would make this faster to merge (since net is for fix only and this has to be backported) than using leds-next?
Quoted 5 lines
Quoted 2 lines
We have leds-fixes for that.
Oh! No idea, should I add a tag to the patch to target that branch specifically?
Quoted 8 lines
You don't need to do anything special.
The Fixes: tag is enough to let us know that this is a fix.
If the commit mentioned in Fixes: was accepted as part of the last merge-window, it'll be sent to the -rcs in good time. If it fixes a commit which was introduced in a previous cycle, it'll be submitted during the next merge-window.
Since this patch fixes an issue that was incorporated into v6.4, we shall not be submitting this for the v6.8-rcs. Instead it's heading for the v6.9 merge-window and will be backported to v6.6.y accordingly.
Signature · 1 line
Lee Jones [李琼斯]
Lee Jones
maintainerQuoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
This should have 'net' in the subject line, to indicate which tree its for.
No, it shouldn't.
Quoted 7 lines
Quoted 1 line
Contributors aren't obliged to know anything about merging strategies.
With netdev, we tend to assume they do, or at least can contribute to the discussion. They often know about any dependencies etc which could influence the decision. When there are multiple subsystem maintainers involved, i tend to use To: to indicate the maintainer i think should merge the patch, and Cc: for the rest.
This isn't a netdev patch. :)
We make no such stipulation for any of the subsystems I maintain.
The subject line should indicate which subsystem the commit pertains to, not which maintainer will merge it or which tree it's merged via. In this case, it's drivers/leds, so "leds: " is fine.
Quoted 4 lines
Quoted 1 line
Why does this need to go in via net?
It does not, as far as i'm aware. Christian, do you know of any reason?
It's pretty early in the cycle and there are no cross-subsystem deps yet, as far as I'm aware.
Signature · 1 line
Lee Jones [李琼斯]
Re: (subset) [PATCH] leds: trigger: netdev: Fix kernel panic on interface rename trig notify
In reply to Christian MarangiQuoted 11 lines · Christian Marangi
Commit
d5e01266e7f5("leds: trigger: netdev: add additional specific link speed mode") in the various changes, reworked the way to set the LINKUP mode in commitcee4bd16c319("leds: trigger: netdev: RecheckNETDEV_LED_MODE_LINKUPon dev rename") and moved it to a generic function.This changed the logic where, in the previous implementation the dev from the trigger event was used to check if the carrier was ok, but in the new implementation with the generic function, the dev in
trigger_datais used instead.[...]
Applied, thanks!
[1/1] leds: trigger: netdev: Fix kernel panic on interface rename trig notify
commit: db36d7d45d191879ec4dd1535fbf04ee4ac28711
--
Lee Jones [李琼斯]