Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1123535ybe; Fri, 13 Sep 2019 11:23:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPIJ7N5/nRMjl2yPHlKHMjA3IaBjkoNOyPPHyesQefIPyiP/twYUJm26ZbkUfZs90hfETT X-Received: by 2002:a17:906:c738:: with SMTP id fj24mr41354424ejb.255.1568399010391; Fri, 13 Sep 2019 11:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568399010; cv=none; d=google.com; s=arc-20160816; b=xtGkb6xIlbJYDggP3ldQIezVA71x+VldIvHWTXrEklYvafTRFRiSGjL7G8Gn1vZeCR 5vvlUqnnScZZw9QNejQ7lTpFX/nzfd5kcEx1iLsP1BVdxyM+EE9Kj7DtIgGFaYe5lDy2 sD1SN919Ri/3ei+5X86FUIZm4hJyRSogwBv8Rd5qLs0iQfK3vDwaQ6ldMPmX43tjFcUH 2IL+tS9yhnDTbLY9BaZcKroYXHmEBh37XgDlNmlmzIr5s7TbX+eundctOiJ7zKL9Vlr/ L2kiaQfXXG5uOBOLkrBgSGtTw3Y52RcQCvSi4usjiFgLhDFZJMlnSwq50lzCazkhHO+V Pr4w== 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=NJTf6Q+AqMgkw96E04ojWYEhrKTkoxRJhr+3hLW7vgE=; b=PERoThe+J5lRm97TpPce2QVHnVZYX+VMOwdWvybWfmDwOCp0l24Vnm4ckgaUmSgNXy DVUgzwzy0A+a6OrsJrv6reZz7X7lgIsYVRdx2HC+SYh6Yj8LdnEpMm3SbCwTyTYggL7g I2+jZtfdg4Q2wS75nO2OEAAX+qo37ZNjZw2nUGBjQJ94Q7t8t7stDBHAyFhOdZi0xNeK HeJEoyQ2KfnkyIDBp/OvBoJbGP6NS0ReLyVn3mLwCsn3yncT1XyGp+CbrsdzYZ6A1sMA UQtf281n6D+QwZmZwWRM0OwwygI/O/zF2EKh8PdgEB/iyxXZvmWQRxLGy/9e5ny1yh9z rcCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GuqzhQo7; 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 j9si9625598edq.304.2019.09.13.11.23.07; Fri, 13 Sep 2019 11:23:30 -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=GuqzhQo7; 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 S2390754AbfIMNVJ (ORCPT + 99 others); Fri, 13 Sep 2019 09:21:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:50562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390744AbfIMNVI (ORCPT ); Fri, 13 Sep 2019 09:21:08 -0400 Received: from localhost (unknown [104.132.45.99]) (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 CCAEB214AE; Fri, 13 Sep 2019 13:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380867; bh=Ff2GSNVrxgxqu4nz2TJSyI8jgqHK9DS8WU37o7j5Ehk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GuqzhQo7NR5N8q/HIBq5amGfb2Xa3kvAW4glBMSV/cT307DE4M1K4zOSXVM2WVqd4 tnMakrMkgRCQCmsKrllkmw0DCDxA3bJNlW7mt23Pd5p4by6b7ENEA3R/LHwv5FfhFO QSSDQhZQBJDY/PvmxLUGwO5lueGEgGPjJQdLM8zk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Sven Eckelmann , Simon Wunderlich Subject: [PATCH 5.2 16/37] batman-adv: fix uninit-value in batadv_netlink_get_ifindex() Date: Fri, 13 Sep 2019 14:07:21 +0100 Message-Id: <20190913130517.403593738@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130510.727515099@linuxfoundation.org> References: <20190913130510.727515099@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 commit 3ee1bb7aae97324ec9078da1f00cb2176919563f upstream. batadv_netlink_get_ifindex() needs to make sure user passed a correct u32 attribute. syzbot reported : BUG: KMSAN: uninit-value in batadv_netlink_dump_hardif+0x70d/0x880 net/batman-adv/netlink.c:968 CPU: 1 PID: 11705 Comm: syz-executor888 Not tainted 5.1.0+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x191/0x1f0 lib/dump_stack.c:113 kmsan_report+0x130/0x2a0 mm/kmsan/kmsan.c:622 __msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:310 batadv_netlink_dump_hardif+0x70d/0x880 net/batman-adv/netlink.c:968 genl_lock_dumpit+0xc6/0x130 net/netlink/genetlink.c:482 netlink_dump+0xa84/0x1ab0 net/netlink/af_netlink.c:2253 __netlink_dump_start+0xa3a/0xb30 net/netlink/af_netlink.c:2361 genl_family_rcv_msg net/netlink/genetlink.c:550 [inline] genl_rcv_msg+0xfc1/0x1a40 net/netlink/genetlink.c:627 netlink_rcv_skb+0x431/0x620 net/netlink/af_netlink.c:2486 genl_rcv+0x63/0x80 net/netlink/genetlink.c:638 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline] netlink_unicast+0xf3e/0x1020 net/netlink/af_netlink.c:1337 netlink_sendmsg+0x127e/0x12f0 net/netlink/af_netlink.c:1926 sock_sendmsg_nosec net/socket.c:651 [inline] sock_sendmsg net/socket.c:661 [inline] ___sys_sendmsg+0xcc6/0x1200 net/socket.c:2260 __sys_sendmsg net/socket.c:2298 [inline] __do_sys_sendmsg net/socket.c:2307 [inline] __se_sys_sendmsg+0x305/0x460 net/socket.c:2305 __x64_sys_sendmsg+0x4a/0x70 net/socket.c:2305 do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291 entry_SYSCALL_64_after_hwframe+0x63/0xe7 RIP: 0033:0x440209 Fixes: b60620cf567b ("batman-adv: netlink: hardif query") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -164,7 +164,7 @@ batadv_netlink_get_ifindex(const struct { struct nlattr *attr = nlmsg_find_attr(nlh, GENL_HDRLEN, attrtype); - return attr ? nla_get_u32(attr) : 0; + return (attr && nla_len(attr) == sizeof(u32)) ? nla_get_u32(attr) : 0; } /**