From: Joe Perches <joe@perches.com>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Ryan Mallon <rmallon@gmail.com>, Jiri Kosina <jkosina@suse.cz>,
Al Viro <viro@zeniv.linux.org.uk>,
Olof Johansson <olof@lixom.net>,
Stepan Moskovchenko <stepanm@codeaurora.org>,
Daniel Borkmann <dborkman@redhat.com>
Subject: Re: [PATCH] vsprintf: ignore arguments to %n
Date: Mon, 27 Jan 2014 16:59:54 -0800 [thread overview]
Message-ID: <1390870794.20150.75.camel@joe-AO722> (raw)
In-Reply-To: <20140128003927.GA27319@www.outflux.net>
On Mon, 2014-01-27 at 16:39 -0800, Kees Cook wrote:
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]
> @@ -1735,14 +1735,10 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
> case FORMAT_TYPE_NRCHARS: {
> /*
> * Since %n poses a greater security risk than
> - * utility, ignore %n and skip its argument.
> + * utility, it should not be implemented. Instead,
> + * when encountering %n, ignore the arguments.
> */
> - void *skip_arg;
> -
> - WARN_ONCE(1, "Please remove ignored %%n in '%s'\n",
> - old_fmt);
> -
> - skip_arg = va_arg(args, void *);
> + WARN_ONCE(1, "Ignored %%n in '%s'\n", old_fmt);
> break;
> }
I don't think this is better either.
Why not tell people to fix the code?
checkpatch isn't run on quite a lot of patches.
anyway, here's a possible checkpatch test too.
---
scripts/checkpatch.pl | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1dbd6d1..95c3264 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4069,6 +4069,15 @@ sub process {
}
}
+# check for unsupported uses of %n in what appear to be formats
+ if ($sline =~ /\b$logFunctions\s*\(.*"/) {
+ my $fmt = get_quoted_string($line, $rawline);
+ if ($fmt ne "" && $fmt =~ /[^\%]\%n/) {
+ WARN("PRINTF_CONTROL_N",
+ "printf style use of \%n is not supported\n" . $herecurr);
+ }
+ }
+
# Check for misused memsets
if ($^V && $^V ge 5.10.0 &&
defined $stat &&
next prev parent reply other threads:[~2014-01-28 1:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-28 0:39 Kees Cook
2014-01-28 0:59 ` Joe Perches [this message]
2014-01-28 1:02 ` Ryan Mallon
2014-01-28 20:51 ` Kees Cook
2014-01-28 18:54 ` Ryan Mallon
2014-01-28 21:16 ` Kees Cook
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=1390870794.20150.75.camel@joe-AO722 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=dborkman@redhat.com \
--cc=jkosina@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rmallon@gmail.com \
--cc=stepanm@codeaurora.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®