diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2015-12-21 13:55:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-12-22 17:00:58 -0500 |
commit | 5449a5ca9bc27dd51a462de7ca0b1cd861cd2bd0 (patch) | |
tree | d45c413133a77f12c74950961286367daca26a61 | |
parent | 024f35c55233fb6041e2b31165271f5b941802e6 (diff) |
addrconf: always initialize sysctl table data
When sysctl performs restrict writes, it allows to write from
a middle position of a sysctl file, which requires us to initialize
the table data before calling proc_dostring() for the write case.
Fixes: 3d1bec99320d ("ipv6: introduce secret_stable to ipv6_devconf")
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/addrconf.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 17f8e7ea133b..1f21087accab 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -5369,13 +5369,10 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write, | |||
5369 | goto out; | 5369 | goto out; |
5370 | } | 5370 | } |
5371 | 5371 | ||
5372 | if (!write) { | 5372 | err = snprintf(str, sizeof(str), "%pI6", &secret->secret); |
5373 | err = snprintf(str, sizeof(str), "%pI6", | 5373 | if (err >= sizeof(str)) { |
5374 | &secret->secret); | 5374 | err = -EIO; |
5375 | if (err >= sizeof(str)) { | 5375 | goto out; |
5376 | err = -EIO; | ||
5377 | goto out; | ||
5378 | } | ||
5379 | } | 5376 | } |
5380 | 5377 | ||
5381 | err = proc_dostring(&lctl, write, buffer, lenp, ppos); | 5378 | err = proc_dostring(&lctl, write, buffer, lenp, ppos); |