Received: by 10.192.165.156 with SMTP id m28csp79272imm; Tue, 10 Apr 2018 16:51:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx48c34IAgECbegW3Ub8UjZEvzt4ZIwBLbXCtfumP1pH6XINqUr3WhTiEc/UO7CCgQMoJgV8b X-Received: by 2002:a17:902:590e:: with SMTP id o14-v6mr2485229pli.229.1523404303321; Tue, 10 Apr 2018 16:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404303; cv=none; d=google.com; s=arc-20160816; b=uY+lhZZIsoz3CIA0a1uaNWewWfk6ZZB4uKxFFEbM0WozYDb7fp++/CpWie+I/N2vN0 YAMQ5d+N8aCOphFrA3Qxoouu+2FIELiDbrPT9epuRN9SInI3nhIOpvTlx0bSF04E7giG +GfvcDzlrVgA1wDnWiN33MWoxlU2vFmFW3w4VqmFDFjqY2k/OYrb2cKShD9jxYKhgl7R a6VZZbnQDiwqZUUa8L7An6Gf9oia/2gdZdWcn0890u64Qrpbfj5i7VnOXQwwGSpwLFvG 89mtbZus3pp/LJ7G6gtbGa+rKE1KvM1yGOoZXzsomLondCwCZkz37GCwmCGc/v4NFJVB j4EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VVEXSbCJLs+A+xn6z8FjdXvgcUQtjayvYD5btt7e9Nw=; b=c4/gWL8ktJ/21pw6KcwW/Bo3miTEFU4XEIdmfiJvPIj1F3996yRlAHt3seOkDux0l0 IrYqgOLSC10rdbeLE2QkrAw8bSgcfZjq0Bxtpnj9NQiD0Cigbe7Kz8Ssx/CkcnFDC8q0 kJrguBRVfhMF4XjXrnZ5qTxdekSxP7px0Fe19x5GiSP/gCcVI5Z6OkMZdQnBwgYc4LDJ /YPp58v4wx8/ugIVZAAvWX2O1adjnqpfApBmttqQw2VO/IkOQOipIDBKRTCCKxaCDAoC BDnPtJx5bAx/pk6pJHTkPX2yllbflz5BTb9ZrohRl4LlpGpU7mNHGLJI8MAX1lIUbx4f tmBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8-v6si3894363plk.550.2018.04.10.16.51.07; Tue, 10 Apr 2018 16:51:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752436AbeDJWY2 (ORCPT + 99 others); Tue, 10 Apr 2018 18:24:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36736 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbeDJWY0 (ORCPT ); Tue, 10 Apr 2018 18:24:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3FC8BCFF; Tue, 10 Apr 2018 22:24:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.16 15/18] ip6_tunnel: better validate user provided tunnel names Date: Wed, 11 Apr 2018 00:23:50 +0200 Message-Id: <20180410212759.384487900@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212758.564682823@linuxfoundation.org> References: <20180410212758.564682823@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit db7a65e3ab78e5b1c4b17c0870ebee35a4ee3257 ] Use valid_name() to make sure user does not provide illegal device name. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_tunnel.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -297,13 +297,16 @@ static struct ip6_tnl *ip6_tnl_create(st struct net_device *dev; struct ip6_tnl *t; char name[IFNAMSIZ]; - int err = -ENOMEM; + int err = -E2BIG; - if (p->name[0]) + if (p->name[0]) { + if (!dev_valid_name(p->name)) + goto failed; strlcpy(name, p->name, IFNAMSIZ); - else + } else { sprintf(name, "ip6tnl%%d"); - + } + err = -ENOMEM; dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, ip6_tnl_dev_setup); if (!dev)