Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3376734ybp; Sun, 6 Oct 2019 10:34:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrA+v4ejVoggCZWVDyUx5JhRNNnBBd2jcm+a6M9pjn5euDdO75vZuRcZxT5ONmfbdTucS+ X-Received: by 2002:a17:906:f74e:: with SMTP id jp14mr12771591ejb.323.1570383299749; Sun, 06 Oct 2019 10:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570383299; cv=none; d=google.com; s=arc-20160816; b=zvNcHWtCw7QV+aM0a5hFfiFvjGjBEkZr2Qk2Dz3UsH74+FW6FqhLemVrLf0AMZAVyF WjOvgHGo/sGLLVrrmnhaoSQQrtqhQh3fWFsLfvgJgvml0g+zCLiPYhB2Zhv/VSOv9ZKf hhINsdEgAwaqOXXQ39WuHm2bieBXdxRTVO96aAQJRmkD+VyfrAopZF0hAA/qVcYYSf+g 1kKelFVLt21OPlIxb4p3j4KwqQ4VpcrUyOamnmvx7eQdqaUNndFop183XCy8MGPCotPb yArHJvw+75cZZ3sltNbuSS/Nf+0dw+Wb9wTfepZ2qSk33xXhIhi5GaCmsPOL6z5xlm05 pObw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=puoFIyEe/SD7z7rgxiDPaVqzVAlRsS4aZG+e3joBzZY=; b=z+5alto9/fLSZOq7tCd0ZNKJUR1AxS+MiviidjfImd8+xNC1WEzarF4goQw/cdJLdS mxoKvt6vLX3WEPksry8/l+gqhQ/kc4UDO06mD/1zz6f04FDB5hGUWDq6kGroyNbLE303 gwWQl9qhDhcyjLlU/VSAnfJidAHQeNgyHlNhvS0DoGmpEPk4Ad7rGcU5INWoo9DBr69J lqMxZuyy4XvqTDzA6gPAygs04qQa/hYnn0TsUwTU7t4kuq0wKK6RPr0HIFziD9Xsa/t1 wRUVqyBuTSTAP23v+xQlokWJlR1ALf5NWX2u7ZKfs3VqbzKBPzW9wMEaRRqLL0x8D0Hq 7EjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ndeklQOU; 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 oq3si6063264ejb.220.2019.10.06.10.34.36; Sun, 06 Oct 2019 10:34:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ndeklQOU; 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 S1729673AbfJFRcz (ORCPT + 99 others); Sun, 6 Oct 2019 13:32:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:59470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727680AbfJFRcy (ORCPT ); Sun, 6 Oct 2019 13:32:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C13692080F; Sun, 6 Oct 2019 17:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383173; bh=YObjyu4dg2oNKw8aD2FnpyBOuVLnwL6K6CQg8iywsis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ndeklQOU0+yoi7P4hbbYO1w+zqnZImgplmIC08Cos3GATHJsUnRp+L6JiSvkvqK2e 6udPdohSX2tmAK/Zm7i9ZnB1V5DYkCkpEJbGqx6iwtUvL00KMVaDhm7wx9k4fs8gpv vrNL8+gS5DsKwi1g8NaWj9d1hG8Ykb0unC6cx0e4= 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.19 091/106] sch_dsmark: fix potential NULL deref in dsmark_init() Date: Sun, 6 Oct 2019 19:21:37 +0200 Message-Id: <20191006171200.275441258@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 474f0813a3002cb299bb73a5a93aa1f537a80ca8 ] Make sure TCA_DSMARK_INDICES was provided by the user. syzbot reported : kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] PREEMPT SMP KASAN CPU: 1 PID: 8799 Comm: syz-executor235 Not tainted 5.3.0+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:nla_get_u16 include/net/netlink.h:1501 [inline] RIP: 0010:dsmark_init net/sched/sch_dsmark.c:364 [inline] RIP: 0010:dsmark_init+0x193/0x640 net/sched/sch_dsmark.c:339 Code: 85 db 58 0f 88 7d 03 00 00 e8 e9 1a ac fb 48 8b 9d 70 ff ff ff 48 b8 00 00 00 00 00 fc ff df 48 8d 7b 04 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 ca RSP: 0018:ffff88809426f3b8 EFLAGS: 00010247 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff85c6eb09 RDX: 0000000000000000 RSI: ffffffff85c6eb17 RDI: 0000000000000004 RBP: ffff88809426f4b0 R08: ffff88808c4085c0 R09: ffffed1015d26159 R10: ffffed1015d26158 R11: ffff8880ae930ac7 R12: ffff8880a7e96940 R13: dffffc0000000000 R14: ffff88809426f8c0 R15: 0000000000000000 FS: 0000000001292880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000080 CR3: 000000008ca1b000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: qdisc_create+0x4ee/0x1210 net/sched/sch_api.c:1237 tc_modify_qdisc+0x524/0x1c50 net/sched/sch_api.c:1653 rtnetlink_rcv_msg+0x463/0xb00 net/core/rtnetlink.c:5223 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5241 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:637 [inline] sock_sendmsg+0xd7/0x130 net/socket.c:657 ___sys_sendmsg+0x803/0x920 net/socket.c:2311 __sys_sendmsg+0x105/0x1d0 net/socket.c:2356 __do_sys_sendmsg net/socket.c:2365 [inline] __se_sys_sendmsg net/socket.c:2363 [inline] __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x440369 Fixes: 758cc43c6d73 ("[PKT_SCHED]: Fix dsmark to apply changes consistent") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_dsmark.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -357,6 +357,8 @@ static int dsmark_init(struct Qdisc *sch goto errout; err = -EINVAL; + if (!tb[TCA_DSMARK_INDICES]) + goto errout; indices = nla_get_u16(tb[TCA_DSMARK_INDICES]); if (hweight32(indices) != 1)