Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4440187pxb; Mon, 21 Feb 2022 21:41:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuLrzL6vjOWGZxR1Xy9f4yoKaUoMXuJ+Je5sg8ypmUmrdVx4V56xxKU7JeZODpGH9ct/q2 X-Received: by 2002:a17:902:8491:b0:14e:dad4:5ce5 with SMTP id c17-20020a170902849100b0014edad45ce5mr21577963plo.76.1645508462897; Mon, 21 Feb 2022 21:41:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645508462; cv=none; d=google.com; s=arc-20160816; b=fkZ8rxgQoe6tzl8gsEAITJnMQBDO5o2KTjTF9TXY4CKaw57YLfC3aQPPwu0n+nj68Q lXDX/64enQahjcJMQzQSl0wYZ0XUabW2m+Mi4ROBYXTpN7VZOqJn4GDrb1vJM/KKGiN2 7yN4/IYPidarxlari6BAOEwTOD1kPDlbZZTdt/k2Fg+87sTzUHTwBAzlaPDFQ0WaUWx2 6YLNN4pv4BzaCFFFDlLDLe4pfjO9+8Q/BbneDfaoDAka1uc5403QbN6fkQT8B9yKBuwU JR2NrYFubwZIfVSay9wHbcBbew3u3E35mcMgyVnWkuBTzgeDmjx/YLj8SRl5g56hkgZp awhg== 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=sIIEmEcBLKCfu1BrjbPPdX4AzldfpM4X6cXNNS4cf8o=; b=qGVxVcTs6MVARXWtZi84RD6olGmAF6iIRE3id+M1rVDXLbMg8nkdbWchKCsqJre0j4 BWoc/4N0ZoXGVthKEBYIzX28nKkxvc9kiib0iWZ+DzrKejwsFheQwUOaEL583428SV/x p1e54WU/FTKezIhj3tJKbE03UIsPivYR8+nsU9PidR54xqK8B6E/3S1+qb3OhqdehZAO 66CbPBzmw454h1uir/olj7cV9Izkhmh5ee5ljoPPBWg4l7nToH8dMYLEMfdnlVcvYZYV EH9KMJEtBsr9jRhACda+Xn/VVH/emKfEdOwOFAZ8E6cWN1A8niDC3+ZBLygLtD+M02cR tfVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lu2LV/ZN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mt24-20020a17090b231800b001bc6b79704fsi1113943pjb.79.2022.02.21.21.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:41:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lu2LV/ZN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 67CEF12CC13; Mon, 21 Feb 2022 21:07:21 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347582AbiBUJIi (ORCPT + 99 others); Mon, 21 Feb 2022 04:08:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347088AbiBUJD2 (ORCPT ); Mon, 21 Feb 2022 04:03:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BCE2D1ED; Mon, 21 Feb 2022 00:58:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 29EB5B80EB7; Mon, 21 Feb 2022 08:58:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68031C340E9; Mon, 21 Feb 2022 08:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645433910; bh=S9gZPcdScvRNbdzVA9eIvwHOVONnGM7IUeu6UrDlv2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lu2LV/ZNPcqMnUs8U4FR9uhRAAQRoNrTSlNqjDFkvudZ4Atl0yIXNBOgSlufN9AMW NtSexv7QiJH7IIBkTX/ydIgxtln5exS+s0WhIJt7PC29l6mOWUlzD/AEfwnZRFjsyZ JPqgPta8Pn1LSItPCmDt9OY+97pt2rIivJNsMp6s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Agner , Wolfgang Walter , Jason Self , Dominik Behr , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Johannes Berg , Kalle Valo Subject: [PATCH 5.4 27/80] iwlwifi: fix use-after-free Date: Mon, 21 Feb 2022 09:49:07 +0100 Message-Id: <20220221084916.473428932@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit bea2662e7818e15d7607d17d57912ac984275d94 upstream. If no firmware was present at all (or, presumably, all of the firmware files failed to parse), we end up unbinding by calling device_release_driver(), which calls remove(), which then in iwlwifi calls iwl_drv_stop(), freeing the 'drv' struct. However the new code I added will still erroneously access it after it was freed. Set 'failure=false' in this case to avoid the access, all data was already freed anyway. Cc: stable@vger.kernel.org Reported-by: Stefan Agner Reported-by: Wolfgang Walter Reported-by: Jason Self Reported-by: Dominik Behr Reported-by: Marek Marczykowski-Górecki Fixes: ab07506b0454 ("iwlwifi: fix leaks/bad data after failed firmware load") Signed-off-by: Johannes Berg Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220208114728.e6b514cf4c85.Iffb575ca2a623d7859b542c33b2a507d01554251@changeid Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c @@ -1616,6 +1616,8 @@ static void iwl_req_fw_callback(const st out_unbind: complete(&drv->request_firmware_complete); device_release_driver(drv->trans->dev); + /* drv has just been freed by the release */ + failure = false; free: if (failure) iwl_dealloc_ucode(drv);