Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2037309pxb; Mon, 12 Apr 2021 12:37:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypAbtWKtFxXsw6fnTFemZubXy3JfCEjXHfEazEe7wrTitBoV6URMqQhHC+laFq8ZyHTU5j X-Received: by 2002:a05:6402:40ca:: with SMTP id z10mr26304421edb.215.1618256239819; 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=mr0s8E0FVN1oD8Ig14ip6CDkClCceeH1r9COU/vCH2/gaOdxHzfm3OfqucD7tMZ97N JHx1aE12uNn09Xm7jRsiq2gatbmjc0Dj/9F2EBAhh3WMEQlTFssmrJZu9KnvWeEA7CJ3 Z2GD7wZ/JAxKgVvaDQsi6mSTbxZgyh2OhoYkDuP3KJjmrKotUgvGlem1Jh7zMv5RhByJ b0hCtCLzNqzR9zMFRJJSbmPlbZO1X17XWPGcCigNHebz7SKlJxJpAkzmetrerW6nLlU+ PyQ4kOHlF/DGJgEgF9OvlBLia09WhA4Q7kJKU+da6cztE0AnArbzdfXU5rq9tCXQ24Ga mSQw== 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=ecZFBmsL7ABx3XQ1yNARS9sQj10SoZjTeK2uwPqQazc=; b=dvFvU16k3gQevFZ8oFHUH1GRWIh5pgLB5CP30V6ytBYkMOQ1yIqYitKQvxcFyOe+E7 1Fp6Ld/vVs+BCWK3+Gfha/HDCCjse4KMlFeinSmZkLqyiBMGnlXeEYmvdpeiNPeCRGJT 8RXQ9qnQ9xnZmuEPtyWAw5oIKqQfS90h4PGOZSr+d9GnDFdT7t8vSLnppDIAEmGOVhFw 4+FsWXbdUMNdfVhWEyzLOBU05xJp41PcAR4vBzvYWzwz9ukmwimQtcwG3Ltpx87oA9wH isaQxNpf+xcigXLTdm3vymla2HSEl7KSfip4M5wIaqWr4JWGsaXIyzPdbSSPWXtb4AbN i3jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JNDH1ZMk; 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 ce15si7997914ejb.649.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=JNDH1ZMk; 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 S237689AbhDLIpo (ORCPT + 99 others); Mon, 12 Apr 2021 04:45:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:36452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237694AbhDLIoo (ORCPT ); Mon, 12 Apr 2021 04:44:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA79B611F0; Mon, 12 Apr 2021 08:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217066; bh=K2psyady3pG725dtChyP5Ahyyx2aXQl70cRYFZTIMPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNDH1ZMkF8gF9wS5NeiRglfNztj9iThf5WCINIfQbWBsZK53YCHmPPmGDXfNjs+Ol HRxjDLFZZ8LvnKdvf2sDH73mAKwHVlNxdwiiV3iYEI6r6CSBU9u3CG2Q6xVnI4WIPV Tlb2LERF8NP4LQt4/jUM5bXk6/s2FSHfF/lAYsPc= 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 4.19 57/66] net: mac802154: Fix general protection fault Date: Mon, 12 Apr 2021 10:41:03 +0200 Message-Id: <20210412083959.968930776@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: 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 @@ -160,7 +160,7 @@ err_tfm0: crypto_free_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);