Skip to contentSkip to conversation

addrconf: always initialize sysctl table data

PATCH In review Cong Wang 2 participants 2 messages Dec 21, 2015 – Dec 22, 2015

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 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")
---
 net/ipv6/addrconf.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
net/ipv6/addrconf.c +4 -7
index 17f8e7e..1f21087 100644
@@ -5369,13 +5369,10 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write,
 		goto out;
 	}
 
-	if (!write) {
-		err = snprintf(str, sizeof(str), "%pI6",
-			       &secret->secret);
-		if (err >= sizeof(str)) {
-			err = -EIO;
-			goto out;
-		}
+	err = snprintf(str, sizeof(str), "%pI6", &secret->secret);
+	if (err >= sizeof(str)) {
+		err = -EIO;
+		goto out;
 	}
 
 	err = proc_dostring(&lctl, write, buffer, lenp, ppos);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Mon, 21 Dec 2015 10:55:45 -0800

Quoted 9 lines

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")

Applied and queued up for -stable, thanks.