Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2234860imm; Thu, 18 Oct 2018 11:08:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Xg+3b0zFYHvuNehU8+00T9+aZdQSyqpyMarg5dit2Z8ujyYz1uavWk8L94u4z+ZH0hcHj X-Received: by 2002:a63:c044:: with SMTP id z4-v6mr29119495pgi.274.1539886107891; Thu, 18 Oct 2018 11:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886107; cv=none; d=google.com; s=arc-20160816; b=p8JBeEMDrTwECMujBDaQgGbSCPE7tBNMF5KLWplEURlh8txCODV/rTqepdZDkdDdNR 7wosBkYA2/dtVU45FUx8GF9kgP3H89W75oBJf3oxHZhi2QQ9YF2IBNL6jQzvbZ42vYnE AFfq0RXZSoCXBiluZ8vQoZaeJH5mAmDN9WwLnZUJT9gUUsSooFxquZjIEXEt5pl4wlyk Y2eHcXAt+7+jLLu8wUaJ0v0BlV/KZTajKqunzT4lGB4Z8qpXu+eHVEtHoZ7wpkGv1Bid F0aWXxMiCjIgLMP6+/8d1l5JLMMlJPjAgrgneTPnvTT9kXKP9iP70pXbSDZtd/yRD4Uh +XnQ== 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=uERDa7jNwyGV7evGOm2cMuAXy8Bb/S8vgnEBNMI0kUo=; b=d2QfEvttHr2zQf+H+L06VwDXXb4IpMQFXUVCixRsi3lvCkcZAlLOtgpp5XxWy1OWKx Szx+BWeCR5VL8fzqzrOR8P6quJvA5t+h0R4AKPbiYMJp8Z/njlDMxXkwv64nI4ZXKV6Z RyICk9CBPoA69DFJVx4nSBwR4xnJj1j2w8rN3a4xGQkycbj7OyfRUkBPeCbRNADIE35o A+MImyyCv+2CDVp3+yOyZ9tadz7cjrqvASKF2MaX0g5xX6RyzOn5JpQVy94Dd6fB+ppM k+CnLIM7tRxZpx1mU3OHevgvgCWgY5Gk4k6HzNaCaulONAqVOsH+z6L8fQbx5tBV8aTn ZMQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vwGOkGc+; 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 w8-v6si21057606pgj.584.2018.10.18.11.08.12; Thu, 18 Oct 2018 11:08:27 -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=vwGOkGc+; 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 S1730340AbeJSCHu (ORCPT + 99 others); Thu, 18 Oct 2018 22:07:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:56646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbeJSCHt (ORCPT ); Thu, 18 Oct 2018 22:07:49 -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 6FFFD20658; Thu, 18 Oct 2018 18:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885942; bh=sDqckhy2F6+cPZrBWEuL6I8b23pbOqy6Mo89LlsIH+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vwGOkGc+BspUx1Aipq26XPKqCo7JzKm1do1pRb8QHPtHSh2j/DlfYq8OSWjTCYn5D EHhQCTjdOJyxGCvIeNgd3GKD8bQ4WEElsIjzA8G72g2ooupE7W9fAGt2MINlPh6yGT Mes14Ctil8CLN7R6FclH3jtRanoUpuYU4YK+aXKg= 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.4 24/48] netlabel: check for IPV4MASK in addrinfo_get Date: Thu, 18 Oct 2018 19:54:59 +0200 Message-Id: <20181018175429.297640938@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@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.4-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]))