From: Eric Dumazet <eric.dumazet@gmail.com>
To: Chen Gang <gang.chen@asianux.com>
Cc: David Miller <davem@davemloft.net>, netdev <netdev@vger.kernel.org>
Subject: [PATCH] net: ipmr: limit MRT_TABLE identifiers
Date: Sun, 25 Nov 2012 11:44:29 -0800 [thread overview]
Message-ID: <1353872669.30446.863.camel@edumazet-glaptop> (raw)
In-Reply-To: <50AC9CF6.2020501@asianux.com>
From: Eric Dumazet <edumazet@google.com>
Name of pimreg devices are built from following format :
char name[IFNAMSIZ]; // IFNAMSIZ == 16
sprintf(name, "pimreg%u", mrt->id);
We must therefore limit mrt->id to 9 decimal digits
or risk a buffer overflow and a crash.
Restrict table identifiers in [0 ... 999999999] interval.
Reported-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/ipmr.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 6168c4d..3eab2b2 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1318,6 +1318,10 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi
if (get_user(v, (u32 __user *)optval))
return -EFAULT;
+ /* "pimreg%u" should not exceed 16 bytes (IFNAMSIZ) */
+ if (v != RT_TABLE_DEFAULT && v >= 1000000000)
+ return -EINVAL;
+
rtnl_lock();
ret = 0;
if (sk == rtnl_dereference(mrt->mroute_sk)) {
next prev parent reply other threads:[~2012-11-25 19:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 9:20 [Suggestion] net/ipv4: sprintf, use "pimreg%.9u" instead of "pimreg%u" Chen Gang
2012-11-25 19:44 ` Eric Dumazet [this message]
2012-11-26 1:22 ` [PATCH] net: ipmr: limit MRT_TABLE identifiers Chen Gang
2012-11-26 1:34 ` Chen Gang
2012-11-26 2:19 ` Eric Dumazet
2012-11-26 2:30 ` Chen Gang
2012-11-26 2:55 ` Eric Dumazet
2012-11-26 3:13 ` Chen Gang
2012-11-26 22:37 ` David Miller
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=1353872669.30446.863.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=gang.chen@asianux.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox