Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3593746pxv; Mon, 28 Jun 2021 08:10:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+VPZodqsyGTUreigLYNu+W3p4XzU7aipW+mFCzAYQyQo0dxdL/AZaTOLUccX6H+WQMhgi X-Received: by 2002:aa7:c9d8:: with SMTP id i24mr33837825edt.79.1624893019685; Mon, 28 Jun 2021 08:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624893019; cv=none; d=google.com; s=arc-20160816; b=Hm1HVgCTXfV5gC9dgMG0ZrkwWVCqUz+aRT0skXOqib9oFxfe77jfJKFPSQW8Xe4hUX gebJZ/ubPTgIveicpQ0bm55pbgrzLAszPgu1uwzJfXu1hit71VxuTFRo0mtuTO+B4bsz thBeUE9esk2VY2l2WdOjnH+uwWIWclpig7DeHRUedAuSp8dF8RaI35JZADGC8x1Reiq/ Y3aQLpfvU2rzVuOXVG8B87AKuDsFcIW155R49hVYrQceORtWdbpf+OS/5b39QGCaefK/ zmmbMZBbGtSDk2mSCKKWDdodny4s/3ZjHrJmWFvIoyqwYxtlviBwai7Q/YU99U3zjNK8 fzxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0K5rIPNi4XEpwEfVWND5cqKd/TwNqywi3/dRlg4BkZI=; b=m+m09/LBIt+4TB4IVSlwb/WARBXbMguzh4uxo2zs0D3uIf+rFJS4m4/vb2xTnzVvC/ 7nYEHeskhm0SxPHe7NV0pfmvP3QNSqeqIOWAvl3f/I0nb8QEduHuNK0mrVfd6wpX3r3s VYByUQsk29ln8ia4gPziAGnY3u3mZEHiTgbd7PyVEQ+P3yyAq5JXsN1stIUNWbciy8IS uXluogjT5WAdagTNNvcRilBLj9Ri6tRMH124v1vnLaHr58vmtUGBiRUoB/BzDOCAUrGx BmvyMyxEOTKcqBl/WrPvP189xTuS+vf6CIwNPR42ZTAszbSmO5lNaJdd2bljvCq5FQOB 3diA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lUow4VpR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si11506900edt.206.2021.06.28.08.09.54; Mon, 28 Jun 2021 08:10:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lUow4VpR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234840AbhF1PGl (ORCPT + 99 others); Mon, 28 Jun 2021 11:06:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236304AbhF1OrN (ORCPT ); Mon, 28 Jun 2021 10:47:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5950061C9E; Mon, 28 Jun 2021 14:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624890992; bh=jJYjTdoHxHUi8n/6g8UQTWTBJcpkxStl1jXbNNZZ7Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUow4VpR2xpNz4jRyP1cZZV0QcbWl3FStXVzjc++NlulUZN9EtS+CcfJT62LUf4Bz Q35zP9kAbb3++2CE9Ge6/Drn5o5LMTZXpSkpE6JZal3ehp/uENp32aqc4vk/sU+o8r WE4/s4smSlGYGeAgpKpGsqYmyclJK449buWvgxsaDk2hTPW0z4Akbl8S9JEITnfSC+ nLJM4BDFJL2LySV2DuQIXUU4BEx0ThS4JLtiNGhykb3/wlkSya60Jl9Z6KBP4H23DP 7xiFP5c/IT7dFf5ZYYweVuSICDGZ0m4q+9SthBeX/PBK0J6n/qod7GCoLgG4mGxSTn NGJ4hfN9LLhSg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Robertson , Alexander Aring , Stefan Schmidt , Sasha Levin Subject: [PATCH 4.14 01/88] net: ieee802154: fix null deref in parse dev addr Date: Mon, 28 Jun 2021 10:35:01 -0400 Message-Id: <20210628143628.33342-2-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Robertson [ Upstream commit 9fdd04918a452980631ecc499317881c1d120b70 ] Fix a logic error that could result in a null deref if the user sets the mode incorrectly for the given addr type. Signed-off-by: Dan Robertson Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20210423040214.15438-2-dan@dlrobertson.com Signed-off-by: Stefan Schmidt Signed-off-by: Sasha Levin --- net/ieee802154/nl802154.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index b1c55db73764..6d4c71a52b6b 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -1315,19 +1315,20 @@ ieee802154_llsec_parse_dev_addr(struct nlattr *nla, nl802154_dev_addr_policy, NULL)) return -EINVAL; - if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || - !attrs[NL802154_DEV_ADDR_ATTR_MODE] || - !(attrs[NL802154_DEV_ADDR_ATTR_SHORT] || - attrs[NL802154_DEV_ADDR_ATTR_EXTENDED])) + if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || !attrs[NL802154_DEV_ADDR_ATTR_MODE]) return -EINVAL; addr->pan_id = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_PAN_ID]); addr->mode = nla_get_u32(attrs[NL802154_DEV_ADDR_ATTR_MODE]); switch (addr->mode) { case NL802154_DEV_ADDR_SHORT: + if (!attrs[NL802154_DEV_ADDR_ATTR_SHORT]) + return -EINVAL; addr->short_addr = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_SHORT]); break; case NL802154_DEV_ADDR_EXTENDED: + if (!attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]) + return -EINVAL; addr->extended_addr = nla_get_le64(attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]); break; default: -- 2.30.2