All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martynas Pumputis <m@lambda.lt>
To: netdev@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, m@lambda.lt
Subject: [PATCH] bpf: fix check of allowed specifiers in bpf_trace_printk
Date: Thu, 22 Nov 2018 17:00:30 +0100	[thread overview]
Message-ID: <20181122160030.15954-1-m@lambda.lt> (raw)

A format string consisting of "%p" or "%s" followed by an invalid
specifier (e.g. "%p%\n" or "%s%") could pass the check which
would make format_decode (lib/vsprintf.c) to warn.

Reported-by: syzbot+1ec5c5ec949c4adaa0c4@syzkaller.appspotmail.com
Signed-off-by: Martynas Pumputis <m@lambda.lt>
---
 kernel/trace/bpf_trace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 08fcfe440c63..9ab05736e1a1 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -225,6 +225,8 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
 						    (void *) (long) unsafe_addr,
 						    sizeof(buf));
 			}
+			if (fmt[i] == '%')
+				i--;
 			continue;
 		}
 
-- 
2.19.1

             reply	other threads:[~2018-11-23  2:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 16:00 Martynas Pumputis [this message]
2018-11-22 21:31 ` [PATCH] bpf: fix check of allowed specifiers in bpf_trace_printk Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181122160030.15954-1-m@lambda.lt \
    --to=m@lambda.lt \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.