Skip to contentSkip to conversation

netfilter: nf_log: fix uninit read in nf_log_proc_dostring

PATCH Applied Jann Horn 2 participants 2 messages Jun 20, 2018 – Jun 26, 2018

Subsystems (3)
lore
Share & tools
lore

Jann Horn

author
#0 lore raw

PATCH 1/1 netfilter: nf_log: fix uninit read in nf_log_proc_dostring

When proc_dostring() is called with a non-zero offset in strict mode, it doesn't just write to the ->data buffer, it also reads. Make sure it doesn't read uninitialized data.

Fixes c6ac37d8d884 ("netfilter: nf_log: fix error on write NONE to [...]")
---
 net/netfilter/nf_log.c | 4 ++++
 1 file changed, 4 insertions(+)
net/netfilter/nf_log.c +4 -0
index 426457047578..2c47f9ec3511 100644
@@ -424,6 +424,10 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
 	if (write) {
 		struct ctl_table tmp = *table;
 
+		/* proc_dostring() can append to existing strings, so we need to
+		 * initialize it as an empty string.
+		 */
+		buf[0] = '\0';
 		tmp.data = buf;
 		r = proc_dostring(&tmp, write, buffer, lenp, ppos);
 		if (r)
Signature · 1 line
2.18.0.rc1.244.gcf134e6275-goog
maintainer Applied
#1 lore raw
Quoted 3 lines · Jann Horn

When proc_dostring() is called with a non-zero offset in strict mode, it doesn't just write to the ->data buffer, it also reads. Make sure it doesn't read uninitialized data.

Applied, thanks.