Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp8488107ioo; Sat, 4 Jun 2022 09:33:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhfeTGhbuEq6rH6pN4FQEnL1fTkvmyOclJnEE4tyZHzzSDdLKDmpNaP/4Zle587kbsFRDc X-Received: by 2002:a17:907:da1:b0:6fe:a1a5:36b9 with SMTP id go33-20020a1709070da100b006fea1a536b9mr13726506ejc.728.1654360429915; Sat, 04 Jun 2022 09:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654360429; cv=none; d=google.com; s=arc-20160816; b=ku+JkDDlWGY0s+L1NVhsvgFD8FN9OTm2rwXk18H2rZ8zChBAmYR7sFFH+XNb+eGSLI cvcV4wVxh51YPIZSVC0bJJBRAG07/Kr0exwMO90a0UocNSQIw0Kl9S5PrqLsOi7KGtIY 9OM6NtPBDAu3BFrxwrL5hQDBcY+i5BDJr3ML+oGrI9Yq/8+bRr/Gq1c79U+8TysANyzB 1oNfYtGJmZxHX882xbty9djq8O9Wot0yypwibHK+BM9I0z30242rsPLtf9b9kb1L6/wN CBO1Q7K7qP59KyemNF6wICNcbw5oPOj3QTSknTsiFWrbJrn5mecp7qUh/rUvpiMlvC9j QTrw== 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 :feedback-id:references:in-reply-to:message-id:subject:reply-to:cc :from:to:dkim-signature:date; bh=CaIKHW9IpR3uwvvAJ5S/+qjR5x5LFqm3na/+pKJ115E=; b=W5wtOnk8oaPGxbQx1V5fjV9yvRwO4AdL88RZuKc/kC2llCUBql8ODnX0VK+8W7BoWQ 2Qb++A7saX2DOQ3LmyAT98ByLz6u/bJAxluZrI/IBltVuV90laUEoMeCoO7MEkySJXjR TFsDMiAY1yc4+6Wkks/3pJ3diEWR/SFYudQANLPMCxKRqBCPox9Zj3qy/oP3eQW3so9D 7Cbxveto24N+0CmdtYJm+2GtNV9LpzDPO/McqGo90QFtmJvyfzj3VMBsQ6q+mnBjdG48 umiv3pZfSZNmIv6/vNGpFpImOLQnn06pd8OdN7Lxzui7SC+D+ruu2jU69SzYs3TR/JMR qNuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dannyvanheumen.nl header.s=protonmail2 header.b=aTyyeJcK; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dannyvanheumen.nl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bn7-20020a170906c0c700b006fdeef08e53si2052581ejb.380.2022.06.04.09.33.12; Sat, 04 Jun 2022 09:33:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dannyvanheumen.nl header.s=protonmail2 header.b=aTyyeJcK; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dannyvanheumen.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237102AbiFDPAV (ORCPT + 67 others); Sat, 4 Jun 2022 11:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237689AbiFDPAI (ORCPT ); Sat, 4 Jun 2022 11:00:08 -0400 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26B52EA13 for ; Sat, 4 Jun 2022 08:00:06 -0700 (PDT) Date: Sat, 04 Jun 2022 14:59:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dannyvanheumen.nl; s=protonmail2; t=1654354801; x=1654614001; bh=CaIKHW9IpR3uwvvAJ5S/+qjR5x5LFqm3na/+pKJ115E=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=aTyyeJcKu1oPqdvCPOnJomyr3SHlfPHmDrVcMijMhjcCG1aJtOkAl6pvQ/IZt+c6q Iz9UgiDlXhLYGcaWdH1IpNCHV+deSFbfXHNiijYmZ6uFTpkSBzx6whhzcoVXvD+jo2 genab3WIeRQm0aNp1vzMuNjXz0VHDYRl78wQo6DUYfBGuwfhx6r1QZjyZsjnFZtBNC uGYTLaK9OHrxNa3SB8RJcbJl6RRPhWfSmCC5sJmPUzCZxPDY0W8JizAwSlvNeTfU+a 8NI1zRkYuAbhLrlOq0XHkgkw/ZDXewvc5YuWMT4RggNCxKtD2pHLTTtka/2RTdAcbF LjiM/Kwihn3kw== To: Franky Lin From: Danny van Heumen Cc: Arend van Spriel , Hante Meuleman , "linux-wireless@vger.kernel.org" , "brcm80211-dev-list.pdl@broadcom.com" , "SHA-cyfmac-dev-list@infineon.com" Reply-To: Danny van Heumen Subject: Re: [PATCH] work-in-progress: double-free after hardware reset due to firmware-crash Message-ID: In-Reply-To: <51CC1C7B-400C-4A7A-A5D3-EB457DC6862F@broadcom.com> References: <51CC1C7B-400C-4A7A-A5D3-EB457DC6862F@broadcom.com> Feedback-ID: 15073070:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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-wireless@vger.kernel.org Hi Franky, ------- Original Message ------- On Saturday, June 4th, 2022 at 00:58, Franky Lin = wrote: > Hi Danny, > > [..] > > Thanks for reporting and sending out a patch to fix this. > > If the problem is double freeing the freezer buffer, it should be address= ed from the root by setting pointer to NULL. Same thing might need to be do= ne for sg table as well. Sorry I don=E2=80=99t have any sdio module to repr= oduce and test. Please see if the below change fixes the problem. Your suggestion to set the freeze buffer address to zero was also my first = proposal. I have since revised, because there are a few things I considered, although I am not sur= e: - does zero-ing the address prevent future detection of double-frees with t= he hardened memory allocator? (If so, I would prefer to avoid doing this.) - IIUC correctly, 'sdio_set_block_size' does not do any meaningful "activat= ion" or "allocation". Therefore would not need to be *undone*. (repeated probes would override = previous calls) - Starting with the call 'sdio_enable_func', I guess/suspect more elaborate= "cleanup" is necessary therefore, leaving the 'goto out' from that point on. I would assume (for= lack of evidence to the contrary) that the logic at 'goto out' provides proper clean-up. So, returning immediately with the errorcode seemed more appropriate. Regar= dless, I have only incidental knowledge from checking the code just for this particular proble= m. In the end my goal is to have the issues addressed so that I am not forced to reboot my system= to get it back in working order. As for your remark about sg-table: I had not considered that, but if my not= es above check out, maybe this does not need to be treated conditionally at all. Kind regards, Danny > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/= drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c > index ac02244a6fdf..e9bad7197ba9 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c > @@ -802,6 +802,7 @@ static void brcmf_sdiod_freezer_detach(struct brcmf_s= dio_dev *sdiodev) > if (sdiodev->freezer) { > > WARN_ON(atomic_read(&sdiodev->freezer->freezing)); > > kfree(sdiodev->freezer); > > + sdiodev->freezer =3D NULL; > > } > } > > @@ -885,7 +886,11 @@ int brcmf_sdiod_remove(struct brcmf_sdio_dev *sdiode= v) > sdio_disable_func(sdiodev->func1); > > sdio_release_host(sdiodev->func1); > > > - sg_free_table(&sdiodev->sgtable); > > + if (sdiodev->sgtable) { > > + sg_free_table(&sdiodev->sgtable); > > + sdiodev->sgtable =3D NULL; > > + } > + > sdiodev->sbwad =3D 0; > > > pm_runtime_allow(sdiodev->func1->card->host->parent); > > > As for submitting patch to linux-wireless, please follow the guideline. [= 1] > > Thanks, > - Franky > > [1] https://wireless.wiki.kernel.org/en/developers/documentation/submitti= ngpatches > > > > -- > This electronic communication and the information and any files transmitt= ed > with it, or attached to it, are confidential and are intended solely for > the use of the individual or entity to whom it is addressed and may conta= in > information that is confidential, legally privileged, protected by privac= y > laws, or otherwise restricted from disclosure to anyone else. If you are > not the intended recipient or the person responsible for delivering the > e-mail to the intended recipient, you are hereby notified that any use, > copying, distributing, dissemination, forwarding, printing, or copying of > this e-mail is strictly prohibited. If you received this e-mail in error, > please return the e-mail to the sender, delete it from your computer, and > destroy any printed copy of it.