Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2037308pxb; Mon, 12 Apr 2021 12:37:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCbOuZ0c/Ho1dcAsW2b6T6/zs5SaImHysqVS1CtS/avxNwZyIIMUvo7NnVy5DLINqAo925 X-Received: by 2002:a17:906:4a90:: with SMTP id x16mr8257877eju.44.1618256239769; Mon, 12 Apr 2021 12:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618256239; cv=none; d=google.com; s=arc-20160816; b=R43Pith7ZiRKp/lASV0VkRiakc5Lzc7Ca2h9UjWchaduy0P30MHsKyf7FLRXegDaXA 3f6dj+McVOffiD6B6nuvpvHTE4wHaH2kNhCq7WrMIB8baX7YB9mSj3dtpnptWer0BPVB oI7iXBTf4xFLep/w/en1LpuCtihScaRkM9mbSjuToWHauAXk/Uy3LonVG4E+X7LUakIv GilX41c5GTMT+ewxbGOmJVzDItgscxKZ9/EJsDj3BgqIBZ2eIaNNCOOwn9oR5eKip37c ssw4zT4CvDoYaDQbCVTK1zyX5I7HuDoYeUrr2E08uuK1ueW0sfS2QK9F9WNMCyGcbmED vy/w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BAveEmg6ENH+Io2T0Y4S4LpiGr7lBImO5y6KHbwUTtI=; b=eEiQNUZhX85ZTGyPHRosvrhhG0PBfyhPbQBhXJoezj4/Pe0CgadhYIDks1dgOQM/ob zHZ0WyYDB3I0TpVCH3lRojuYT9sbOKYfjOfecfakbNJIbj23nXF0DyZjDTPkjXPuj95n CgS4UqN/0SlhtL+687JEKdCRZJ73ENXuVnPjdewwYVDIdCa0FKFaNUI/dXhxh5BC9ysd 7qiOzUj6NgvJPOebwItxUhfpC4iRNxxWbaMt6PtZJHWtr/iBLql3UIOx9Z15k/6RuVRt Zs0qLtCjMKOGyQl8zkCAgXcdRvJiAc/wAZ4HpvSB5JRJ6Dm2HF8VxIYZSSqT3DCax3ri E4TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w2R2JKZ7; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jl15si4302611ejc.18.2021.04.12.12.36.56; Mon, 12 Apr 2021 12:37: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=@linuxfoundation.org header.s=korg header.b=w2R2JKZ7; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237596AbhDLIpt (ORCPT + 99 others); Mon, 12 Apr 2021 04:45:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:36968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237706AbhDLIoq (ORCPT ); Mon, 12 Apr 2021 04:44:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E0386109E; Mon, 12 Apr 2021 08:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217069; bh=clS3TK94RoVp/7AJ9nUNT+La7QmdmF6hnBsBhzjIJjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w2R2JKZ7C96YlMAyLIfqJp6pcHVW9rBOiFn/uv4AAtb9DPhGReKFRFzVERvAvbHCG GkKk6HEgBx6YD80Pk+P8+TR//Yo4keAo7Px8adzd+5XLb/Z5BsW/+uA8yz6x+M5MCA cG2vlMMDiqximRFoCIkzwtk8YuV/0km0kkDQO8s8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d4c07de0144f6f63be3a@syzkaller.appspotmail.com, Alexander Aring , Stefan Schmidt Subject: [PATCH 4.19 58/66] net: ieee802154: nl-mac: fix check on panid Date: Mon, 12 Apr 2021 10:41:04 +0200 Message-Id: <20210412083959.999943252@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Aring commit 6f7f657f24405f426212c09260bf7fe8a52cef33 upstream. This patch fixes a null pointer derefence for panid handle by move the check for the netlink variable directly before accessing them. Reported-by: syzbot+d4c07de0144f6f63be3a@syzkaller.appspotmail.com Signed-off-by: Alexander Aring Link: https://lore.kernel.org/r/20210228151817.95700-4-aahringo@redhat.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman --- net/ieee802154/nl-mac.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/net/ieee802154/nl-mac.c +++ b/net/ieee802154/nl-mac.c @@ -559,9 +559,7 @@ ieee802154_llsec_parse_key_id(struct gen desc->mode = nla_get_u8(info->attrs[IEEE802154_ATTR_LLSEC_KEY_MODE]); if (desc->mode == IEEE802154_SCF_KEY_IMPLICIT) { - if (!info->attrs[IEEE802154_ATTR_PAN_ID] && - !(info->attrs[IEEE802154_ATTR_SHORT_ADDR] || - info->attrs[IEEE802154_ATTR_HW_ADDR])) + if (!info->attrs[IEEE802154_ATTR_PAN_ID]) return -EINVAL; desc->device_addr.pan_id = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_PAN_ID]); @@ -570,6 +568,9 @@ ieee802154_llsec_parse_key_id(struct gen desc->device_addr.mode = IEEE802154_ADDR_SHORT; desc->device_addr.short_addr = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_SHORT_ADDR]); } else { + if (!info->attrs[IEEE802154_ATTR_HW_ADDR]) + return -EINVAL; + desc->device_addr.mode = IEEE802154_ADDR_LONG; desc->device_addr.extended_addr = nla_get_hwaddr(info->attrs[IEEE802154_ATTR_HW_ADDR]); }