Received: by 10.192.165.156 with SMTP id m28csp1094149imm; Wed, 11 Apr 2018 12:17:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx49VIMdoGL3ZY+GhHYKjGLiVGkgn5tgeSk8vT27XcngatzHiZoNwhm1ZOP6qT/7R1N9xt99V X-Received: by 2002:a17:902:33a5:: with SMTP id b34-v6mr6413611plc.232.1523474257009; Wed, 11 Apr 2018 12:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523474256; cv=none; d=google.com; s=arc-20160816; b=aJ7tzMgFzgriQlrlFwy45hE+Tzcx7LH+6mN3WI3Su7Iz/rFO8qWyToQ7c6EfeGQqru 3aWx4WNKjM2H/nGmNpyGzWF2QVRY1ELmtMVDAIxc9e/B7A02kywR4e+jBokqlbi1gQ+b 1Q4DFSeYcnY3BDx+QzRfgArOY8LSRAXem6Oq3LkmzXxZZGSB9hduzKvfJYWHqmMZFJ5b VxGemJ9OcYzsg/0npIyl/SV3ptD4qhyP8Kje0O7RT73lgqKhB69+4rHky6T6vOT38c/D ut1U0yDzJxv0BRc4tBKV3wMXqYoI5WkH3mHL59TRSHupfHwDSNphnFrm0a1Oz1tfizpx fUiQ== 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=O5knnmJ4/EB28KQtd2qdwDGEf7YTHdJGTO4WTix3++s=; b=qJ4deGJ7NHwKmGqHA31F9PCttCJ/QRKsdHc65c5Tj5BNw9SbnPSrhO53UkJvf8kcx4 xkmi0BDC8rRyIIXk8kE8I0eFpXltJSX1FlcKixLlF+AzeNo+/tXc3VgspT7nk4owzQ5D l/Ge7L0WX7A+Gg6L1T0qsTrKWyNCW+Piffr4t8pO7P2m/qkXas8fXWhz5sB3Ijsr/UI6 31NTXacus5xAOtNSpvau/7Iw55zoSaPY7Hh+0mudff9jMvTdMqva8i2IQ0VBHsUfe92L eiMP1CAuNfyyGAKtq/Wxl0znDSn8T8wBL1CKRwwU2NJjm+anWptiXyr0RHXNpNnLI35I kraQ== 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 h12-v6si1786012pll.431.2018.04.11.12.16.57; Wed, 11 Apr 2018 12:17:36 -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 S1753696AbeDKTMi (ORCPT + 99 others); Wed, 11 Apr 2018 15:12:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40690 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935146AbeDKTGG (ORCPT ); Wed, 11 Apr 2018 15:06:06 -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 DEFECBAC; Wed, 11 Apr 2018 19:06:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" Subject: [PATCH 4.9 295/310] ipv6: sit: better validate user provided tunnel names Date: Wed, 11 Apr 2018 20:37:14 +0200 Message-Id: <20180411183635.276682264@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit b95211e066fc3494b7c115060b2297b4ba21f025 ] Use dev_valid_name() to make sure user does not provide illegal device name. syzbot caught the following bug : BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300 [inline] BUG: KASAN: stack-out-of-bounds in ipip6_tunnel_locate+0x63b/0xaa0 net/ipv6/sit.c:254 Write of size 33 at addr ffff8801b64076d8 by task syzkaller932654/4453 CPU: 0 PID: 4453 Comm: syzkaller932654 Not tainted 4.16.0+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x1b9/0x29f lib/dump_stack.c:53 print_address_description+0x6c/0x20b mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.7+0xac/0x2f5 mm/kasan/report.c:412 check_memory_region_inline mm/kasan/kasan.c:260 [inline] check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267 memcpy+0x37/0x50 mm/kasan/kasan.c:303 strlcpy include/linux/string.h:300 [inline] ipip6_tunnel_locate+0x63b/0xaa0 net/ipv6/sit.c:254 ipip6_tunnel_ioctl+0xe71/0x241b net/ipv6/sit.c:1221 dev_ifsioc+0x43e/0xb90 net/core/dev_ioctl.c:334 dev_ioctl+0x69a/0xcc0 net/core/dev_ioctl.c:525 sock_ioctl+0x47e/0x680 net/socket.c:1015 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:500 [inline] do_vfs_ioctl+0x1cf/0x1650 fs/ioctl.c:684 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701 SYSC_ioctl fs/ioctl.c:708 [inline] SyS_ioctl+0x24/0x30 fs/ioctl.c:706 do_syscall_64+0x29e/0x9d0 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/sit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -244,11 +244,13 @@ static struct ip_tunnel *ipip6_tunnel_lo if (!create) goto failed; - if (parms->name[0]) + if (parms->name[0]) { + if (!dev_valid_name(parms->name)) + goto failed; strlcpy(name, parms->name, IFNAMSIZ); - else + } else { strcpy(name, "sit%d"); - + } dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, ipip6_tunnel_setup); if (!dev)