Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5435985imm; Tue, 16 Oct 2018 10:11:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fvfV/WoSsqjeQ6LXCUcE26lAvUqBhv31uySwtUDNkF1A2e3tkTXhH3KGudw622ZOGNMPc X-Received: by 2002:a62:1985:: with SMTP id 127-v6mr22312722pfz.51.1539709890555; Tue, 16 Oct 2018 10:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539709890; cv=none; d=google.com; s=arc-20160816; b=SPz8g337mq9vZHC5uB6DXtHUez+3RoyGrt1NEFuiciBo8IF3/FU+wwYkIxcGzCinQI 5UugGpPMS9tmHX4zEIqvSQexkW2nOz9/BujNFlVt2r8dNx05wGghdWyYPEEWm8ss2Uh3 m+0B/o00rP++xuqei0X6QBuWa8+O+0xhwLsR3sDTX3j/sHaLFgfEZFKL1FgU4Shr4Hqr JVgBuaYz09Z7AfYRWm37VfzAIK/cvQytVhQuqCkaypvSaYbw7LS+yWDJLUmfC7oT5qGu uruXISuU0YXWVZdSfE3eJfTkzU0/z3WanRtBvW6KrkFrQCnuFb7ImoioDZftYnsX1m/J Jj3g== 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=ZSErR4krYjo/xnClugWcNE8ZCohRD0N3IDm8ix+Naa4=; b=iD4e2LM8I+z4GGzhKzYaAsUkcfaipF7XHeDykytZJ+2uIEU3TWqs/KwX8Apoahr5xi gRNgwdmOSxdL9XjxE0hzJ+96DKpJChAww4S4NSBQ/o+h2+qtNaFYrFCV4Qt9JgvnINpA O90CCHDUpEG6W9fCalV89SKXQm01lbrtTSU3L6cc8OTobODIh53/g4wCzfz6zumd3Jui /GqhwlOSwjElACxjtuVOnPP9Do/zRDu9FtV0Bcq6jHv6eN2xQ3OmZ3NMZNN4E+Vv0yNI gHtEVWFypKcokdKKGpVG7xOjvhuVfIpd5gizPgYGioNdjjEBknIeqlLJVvqEL1GnfEYt mUkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b9aBSaMY; 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 t141-v6si14463998pgb.64.2018.10.16.10.11.14; Tue, 16 Oct 2018 10:11: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=b9aBSaMY; 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 S1727649AbeJQBBz (ORCPT + 99 others); Tue, 16 Oct 2018 21:01:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbeJQBBy (ORCPT ); Tue, 16 Oct 2018 21:01:54 -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 B02A820866; Tue, 16 Oct 2018 17:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539709832; bh=MR/SRZFGCExWoGGbd5jxfLCi66yxMimSSCe53j19oMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b9aBSaMYhpOKJ90QKmIxsWBl11WlzxuTCEV6vlbM9Pf9xksAmxRqEvQo+kbtf+W1k VbOyyu/Dq8aeeJGuXZ1bBz+vb3hefPGgKwaozrC4i4fUtlHi32pKc2DWvjiyJPGwzW DQixeXN8dtk1z0zwJC5JiSssGuj3IqPkJDo1h2YI= 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.18 012/135] netlabel: check for IPV4MASK in addrinfo_get Date: Tue, 16 Oct 2018 19:04:02 +0200 Message-Id: <20181016170516.282782128@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170515.447235311@linuxfoundation.org> References: <20181016170515.447235311@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.18-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 @@ -781,7 +781,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]))