* [PATCH net/ipv6] net/ipv6: avoid possible dead locking on addr_gen_mode sysctl
@ 2017-02-26 23:41 Felix Jia
2017-03-01 18:24 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Felix Jia @ 2017-02-26 23:41 UTC (permalink / raw)
To: David S . Miller; +Cc: Felix Jia, netdev
The addr_gen_mode variable can be accessed by both sysctl and netlink.
Repleacd rtnl_lock() with rtnl_trylock() protect the sysctl operation to
avoid the possbile dead lock.`
Signed-off-by: Felix Jia <felix.jia@alliedtelesis.co.nz>
---
net/ipv6/addrconf.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 3a2025f5bf2c..cfc485a8e1c0 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5692,13 +5692,18 @@ static int addrconf_sysctl_addr_gen_mode(struct ctl_table *ctl, int write,
struct inet6_dev *idev = (struct inet6_dev *)ctl->extra1;
struct net *net = (struct net *)ctl->extra2;
+ if (!rtnl_trylock())
+ return restart_syscall();
+
ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
if (write) {
new_val = *((int *)ctl->data);
- if (check_addr_gen_mode(new_val) < 0)
- return -EINVAL;
+ if (check_addr_gen_mode(new_val) < 0) {
+ ret = -EINVAL;
+ goto out;
+ }
/* request for default */
if (&net->ipv6.devconf_dflt->addr_gen_mode == ctl->data) {
@@ -5707,20 +5712,23 @@ static int addrconf_sysctl_addr_gen_mode(struct ctl_table *ctl, int write,
/* request for individual net device */
} else {
if (!idev)
- return ret;
+ goto out;
- if (check_stable_privacy(idev, net, new_val) < 0)
- return -EINVAL;
+ if (check_stable_privacy(idev, net, new_val) < 0) {
+ ret = -EINVAL;
+ goto out;
+ }
if (idev->cnf.addr_gen_mode != new_val) {
idev->cnf.addr_gen_mode = new_val;
- rtnl_lock();
addrconf_dev_config(idev->dev);
- rtnl_unlock();
}
}
}
+out:
+ rtnl_unlock();
+
return ret;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net/ipv6] net/ipv6: avoid possible dead locking on addr_gen_mode sysctl
2017-02-26 23:41 [PATCH net/ipv6] net/ipv6: avoid possible dead locking on addr_gen_mode sysctl Felix Jia
@ 2017-03-01 18:24 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-03-01 18:24 UTC (permalink / raw)
To: felix.jia; +Cc: netdev
From: Felix Jia <felix.jia@alliedtelesis.co.nz>
Date: Mon, 27 Feb 2017 12:41:23 +1300
> The addr_gen_mode variable can be accessed by both sysctl and netlink.
> Repleacd rtnl_lock() with rtnl_trylock() protect the sysctl operation to
> avoid the possbile dead lock.`
>
> Signed-off-by: Felix Jia <felix.jia@alliedtelesis.co.nz>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-01 18:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-26 23:41 [PATCH net/ipv6] net/ipv6: avoid possible dead locking on addr_gen_mode sysctl Felix Jia
2017-03-01 18:24 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).