diff mbox series

[net] netfilter: nf_log: fix uninit read in nf_log_proc_dostring

Message ID 20180620163345.212776-1-jannh@google.com
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show
Series [net] netfilter: nf_log: fix uninit read in nf_log_proc_dostring | expand

Commit Message

Jann Horn June 20, 2018, 4:33 p.m. UTC
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 [...]")
Signed-off-by: Jann Horn <jannh@google.com>
---
 net/netfilter/nf_log.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Pablo Neira Ayuso June 26, 2018, 4:05 p.m. UTC | #1
On Wed, Jun 20, 2018 at 06:33:45PM +0200, Jann Horn wrote:
> 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.
diff mbox series

Patch

diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index 426457047578..2c47f9ec3511 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -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)