summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-04-05 15:16:15 -0400
committerDavid S. Miller <davem@davemloft.net>2018-04-05 15:16:15 -0400
commitd68a19f89bcfa53cc2aaa3153d7243226df08456 (patch)
treedcd4df322c786cfd954ed1dd9e6de1d73b95e66d /net/ipv4
parent06dd3dfeea60e2a6457a6aedf97afc8e6d2ba497 (diff)
parent537b361fbcbcc3cd6fe2bb47069fd292b9256d16 (diff)
downloadlinux-d68a19f89bcfa53cc2aaa3153d7243226df08456.tar.bz2
Merge branch 'net-tunnel-name-validate'
Eric Dumazet says: ==================== net: better validate user provided tunnel names This series changes dev_valid_name() to not attempt reading a possibly too long user-provided device name, then use this helper in five different tunnel providers. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/ip_tunnel.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index de6d94482fe7..6b0e362cc99b 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -253,13 +253,14 @@ static struct net_device *__ip_tunnel_create(struct net *net,
struct net_device *dev;
char name[IFNAMSIZ];
- if (parms->name[0])
+ err = -E2BIG;
+ if (parms->name[0]) {
+ if (!dev_valid_name(parms->name))
+ goto failed;
strlcpy(name, parms->name, IFNAMSIZ);
- else {
- if (strlen(ops->kind) > (IFNAMSIZ - 3)) {
- err = -E2BIG;
+ } else {
+ if (strlen(ops->kind) > (IFNAMSIZ - 3))
goto failed;
- }
strlcpy(name, ops->kind, IFNAMSIZ);
strncat(name, "%d", 2);
}