Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5450831imm; Tue, 16 Oct 2018 10:24:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV61IDyC1YMzevyf8ErsfqTn65gvjqZbXIj6sSNFMdcWCPDgS8POybOmDph0bTp4h0cQWnK+/ X-Received: by 2002:a63:4745:: with SMTP id w5-v6mr21528676pgk.377.1539710669291; Tue, 16 Oct 2018 10:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710669; cv=none; d=google.com; s=arc-20160816; b=d73T9NHfsOFe6F/qwhvm7gB45ePTVSQKrw67nGMYAKcZlMeYF5h4c2cN45ETH375+7 rZFY+au7dEpQI+iFIkx9U/iWpWGMdyFl9ZqnV9nkDCGBhHjCzMlKe8BO+HAtJiubxQll 4mxyatp2n6jVtBipahq02uuBR41McEHOm3HZNZbM0buKq9e+iRjMXCypAyP/4/iTV7Fu Nm/i4I6yVLPxWd4CgHexww7yXJ/wIOEAlv4n+bv+ZdnfgjzpZivk2oCfG72IabzCrS/Z /g91k4cOj0Xjr5j+pxKor5hMwVVH1Q39yYsS1ZkBkJzg5f/Qobv/q6kyo6WdUYR/l6Pq zOGA== 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=/D6rTAhM5aVxGIsgQaKcAJYrcM3L3UIWX7JuVjQaco4=; b=qlCjYgU64CYjIhlC3lD324H9Moi+ip2RQHvaF38WbdNUl2SEA8VDbi/Bzfm/HGZ0sH 37N4OblsLCFQlHokqrfkObjiimNrTZKj/gH+JnoGNTakJFxh15dknWnZc/HjjdzavMAw HIr1rpEpnZeGxGYa9CIheH1oH8ZcThpWqZOZCKXq0tK6UuWDZz0g6drhtaG6sP6wvjhr UVJc9XtmpDmAvDJiG0+EalVkVQALwsTnu5QWc7SimgC9OVzxIW45yQ2/FTp2z49dDElG +07K0kLPYT6UsqDK8FldHRO8asQtAEiWFrjZtgLWe/0oy7oNN637DpZNtQzuOVWFr01M iYBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ynitf3eL; 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 q143-v6si13538043pgq.483.2018.10.16.10.24.13; Tue, 16 Oct 2018 10:24:29 -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=Ynitf3eL; 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 S1731501AbeJQBPN (ORCPT + 99 others); Tue, 16 Oct 2018 21:15:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:33782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730396AbeJQBPM (ORCPT ); Tue, 16 Oct 2018 21:15:12 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 CDEFE20658; Tue, 16 Oct 2018 17:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710627; bh=mgZrUirQjVFxTZMrEg+s5A2pH/AUDLuonzqTGcBEu9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ynitf3eLB5Ad/gFNBMK7yJfLFYPCLsQ6HpXixPXSWAG+BxAo1ZUfcooUiDDvlwbMt ZhukztjICzP31ZIMViFpb6NilNUvGh2lP/PMT3KLzcwtcCIUDK8ksmB0mUUVDhM8H7 WZbECydPWSBIy7QvyJixQzcwVyFFNmTRqMhCW/lI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Tranchetti , "David S. Miller" Subject: [PATCH 4.9 32/71] netlabel: check for IPV4MASK in addrinfo_get Date: Tue, 16 Oct 2018 19:09:29 +0200 Message-Id: <20181016170541.006704919@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Tranchetti [ Upstream commit f88b4c01b97e09535505cf3c327fdbce55c27f00 ] netlbl_unlabel_addrinfo_get() assumes that if it finds the NLBL_UNLABEL_A_IPV4ADDR attribute, it must also have the NLBL_UNLABEL_A_IPV4MASK attribute as well. However, this is not necessarily the case as the current checks in netlbl_unlabel_staticadd() and friends are not sufficent to enforce this. If passed a netlink message with NLBL_UNLABEL_A_IPV4ADDR, NLBL_UNLABEL_A_IPV6ADDR, and NLBL_UNLABEL_A_IPV6MASK attributes, these functions will all call netlbl_unlabel_addrinfo_get() which will then attempt dereference NULL when fetching the non-existent NLBL_UNLABEL_A_IPV4MASK attribute: Unable to handle kernel NULL pointer dereference at virtual address 0 Process unlab (pid: 31762, stack limit = 0xffffff80502d8000) Call trace: netlbl_unlabel_addrinfo_get+0x44/0xd8 netlbl_unlabel_staticremovedef+0x98/0xe0 genl_rcv_msg+0x354/0x388 netlink_rcv_skb+0xac/0x118 genl_rcv+0x34/0x48 netlink_unicast+0x158/0x1f0 netlink_sendmsg+0x32c/0x338 sock_sendmsg+0x44/0x60 ___sys_sendmsg+0x1d0/0x2a8 __sys_sendmsg+0x64/0xb4 SyS_sendmsg+0x34/0x4c el0_svc_naked+0x34/0x38 Code: 51001149 7100113f 540000a0 f9401508 (79400108) ---[ end trace f6438a488e737143 ]--- Kernel panic - not syncing: Fatal exception Signed-off-by: Sean Tranchetti Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netlabel/netlabel_unlabeled.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/netlabel/netlabel_unlabeled.c +++ b/net/netlabel/netlabel_unlabeled.c @@ -787,7 +787,8 @@ static int netlbl_unlabel_addrinfo_get(s { u32 addr_len; - if (info->attrs[NLBL_UNLABEL_A_IPV4ADDR]) { + if (info->attrs[NLBL_UNLABEL_A_IPV4ADDR] && + info->attrs[NLBL_UNLABEL_A_IPV4MASK]) { addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); if (addr_len != sizeof(struct in_addr) && addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV4MASK]))