Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2064378pxb; Mon, 12 Apr 2021 13:23:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGwRSHqdNlMUGCibo40MpfdOh6884qDiT8rJOjHNPtIugxQkYEQJp8VzWd/lv7u4V2yTsw X-Received: by 2002:a17:90a:4d86:: with SMTP id m6mr944373pjh.197.1618258980991; Mon, 12 Apr 2021 13:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618258980; cv=none; d=google.com; s=arc-20160816; b=sVJb0OmYEBn1Z9OPxDpfeDem/SuUhJpYVE8nJWw75lWpLXR+zAZaAsSGj31Y8e1pPi 87zfRs0Eso1izUQsc4/gP8zdlj+Gk9SAEIbh+//TIGQVr/hnYrt500uJBjpn0cuQ5vRO 1BmQAn0e2f+idUZuHhaOTS+MJsw2nNoAOuagP13bAJT0GEV0RHUk3Pspd1Mi+qTPb1/1 i+XV5RWbF10UUm8J2k+Kam7J1F7srB1GOXneVZImZoh2oPuACa7q7leaxWgKsyXTGuD9 4FujyzxEVNmrL0YATRnkWR0t6dgT8j2ZduMCyoBf0OpbO8PqhyJAPm+0poege/IREzxP tIZQ== 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=zH9iUnFsMFU9n6sAQAG9KtG9HUex3I5XxAgcozdrLaM=; b=037MRZhJzK6zVrzzCEyVA/ULO+YFh4GsBpF+GquzkkMD1WYiWSuuD6pi0pqwVkaUZu LtNg+aLDHlY+apM+AI+I17CZjdr7tA+9wG2rrtuV+LRF5xgnmGfGhSpr7bEKJ/4h6oZ7 cUQJinO2d7nGnal7iu8eSfjYD0ALDBgB8a25AswIm8gFQeAuAYI7PFGSEi772YCL3JBQ xcuqUJAqSZns290PTQSQv7meIOiORtULAi8jDBKEAen6aDi7FSLsjkW5HfRVQ3PWJQgh NGmqvTH/5YhfXxkUrIrAhzGT+BdoPa86VNwc8JdYvozr9BZ1jqeBmJoW3h6OIoQPRQAL LXEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gOJATA+k; 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 z22si16416569pfc.159.2021.04.12.13.22.47; Mon, 12 Apr 2021 13:23:00 -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=gOJATA+k; 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 S238757AbhDLI5P (ORCPT + 99 others); Mon, 12 Apr 2021 04:57:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:39950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238522AbhDLIuA (ORCPT ); Mon, 12 Apr 2021 04:50:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E764461279; Mon, 12 Apr 2021 08:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217371; bh=EWqIUxxDkyzXjQevNURrEMg8yft553HjbYT3cLHkkyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gOJATA+kGqQX4Pw0wDWbTZzqGPAbD8kzg3GEMffi/+y6DTba36cbs8pq153CxNKBc xQMEh+uiEH01pOja6HowqP4vwIio5fpHKg94OPpKHYZEBRnO5Buo0WOg4tEL68Nig3 smv8BfHYUw8aVHWjwEz/JZzheciWqrxHKEKiIC5E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , syzbot+9ec037722d2603a9f52e@syzkaller.appspotmail.com, Alexander Aring , Stefan Schmidt Subject: [PATCH 5.4 102/111] net: mac802154: Fix general protection fault Date: Mon, 12 Apr 2021 10:41:20 +0200 Message-Id: <20210412084007.649415643@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@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: Pavel Skripkin commit 1165affd484889d4986cf3b724318935a0b120d8 upstream. syzbot found general protection fault in crypto_destroy_tfm()[1]. It was caused by wrong clean up loop in llsec_key_alloc(). If one of the tfm array members is in IS_ERR() range it will cause general protection fault in clean up function [1]. Call Trace: crypto_free_aead include/crypto/aead.h:191 [inline] [1] llsec_key_alloc net/mac802154/llsec.c:156 [inline] mac802154_llsec_key_add+0x9e0/0xcc0 net/mac802154/llsec.c:249 ieee802154_add_llsec_key+0x56/0x80 net/mac802154/cfg.c:338 rdev_add_llsec_key net/ieee802154/rdev-ops.h:260 [inline] nl802154_add_llsec_key+0x3d3/0x560 net/ieee802154/nl802154.c:1584 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline] netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927 sock_sendmsg_nosec net/socket.c:654 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:674 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2350 ___sys_sendmsg+0xf3/0x170 net/socket.c:2404 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Pavel Skripkin Reported-by: syzbot+9ec037722d2603a9f52e@syzkaller.appspotmail.com Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20210304152125.1052825-1-paskripkin@gmail.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman --- net/mac802154/llsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/mac802154/llsec.c +++ b/net/mac802154/llsec.c @@ -152,7 +152,7 @@ err_tfm0: crypto_free_sync_skcipher(key->tfm0); err_tfm: for (i = 0; i < ARRAY_SIZE(key->tfm); i++) - if (key->tfm[i]) + if (!IS_ERR_OR_NULL(key->tfm[i])) crypto_free_aead(key->tfm[i]); kzfree(key);