From: Joe Perches <joe@perches.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: "David S. Miller" <davem@davemloft.net>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] vsprintf: Prevent NULL dereference using %pNF
Date: Tue, 17 Jan 2012 10:37:13 -0800 [thread overview]
Message-ID: <1326825433.17202.6.camel@joe2Laptop> (raw)
Passing NULL to %pNF is done in skb_gso_segment
which could be dereferenced.
Add noinline_for_stack to function.
Make pointer argument the actual type.
Check pointer for NULL and use 0 when so.
Signed-off-by: Joe Perches <joe@perches.com>
---
lib/vsprintf.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 8e75003..0f1dfd9 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -777,16 +777,24 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
return string(buf, end, uuid, spec);
}
-static
-char *netdev_feature_string(char *buf, char *end, const u8 *addr,
- struct printf_spec spec)
+static noinline_for_stack
+char *netdev_feature_string(char *buf, char *end,
+ const netdev_features_t *features,
+ struct printf_spec spec)
{
+ unsigned long long num;
+
+ if (features)
+ num = (unsigned long long)*features;
+ else
+ num = 0;
+
spec.flags |= SPECIAL | SMALL | ZEROPAD;
if (spec.field_width == -1)
spec.field_width = 2 + 2 * sizeof(netdev_features_t);
spec.base = 16;
- return number(buf, end, *(const netdev_features_t *)addr, spec);
+ return number(buf, end, num, spec);
}
int kptr_restrict __read_mostly;
next reply other threads:[~2012-01-17 18:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-17 18:37 Joe Perches [this message]
2012-01-17 18:46 ` [PATCH] vsprintf: Prevent NULL dereference using %pNF David Miller
2012-01-17 18:51 ` Joe Perches
2012-01-17 18:52 ` David Miller
2012-01-17 18:54 ` Joe Perches
2012-01-17 18:59 ` David Miller
2012-01-17 19:39 ` Michał Mirosław
2012-01-17 19:43 ` Joe Perches
2012-01-17 21:12 ` Michał Mirosław
2012-01-18 2:43 ` Joe Perches
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=1326825433.17202.6.camel@joe2Laptop \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
/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