From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA025ECE587 for ; Mon, 14 Oct 2019 17:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8C9320873 for ; Mon, 14 Oct 2019 17:53:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="PwG15lss" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730723AbfJNRxb (ORCPT ); Mon, 14 Oct 2019 13:53:31 -0400 Received: from mail.skyhub.de ([5.9.137.197]:57130 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728941AbfJNRxb (ORCPT ); Mon, 14 Oct 2019 13:53:31 -0400 Received: from zn.tnic (p200300EC2F065800329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2f06:5800:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6901D1EC0C81; Mon, 14 Oct 2019 19:53:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1571075609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=FRnrE36V97yr2XOoiWhH71sP1a5VryRZPc2CnW5w4ps=; b=PwG15lssyWuknhNOgr5mQ89PPSlPUlWHTsdSVJA3ATJGrU3rEkyasLCnAQjx9ivE5Kg1WZ xdQ5KGFyM6pmCyYqa0Zq/cm+V4Vw4wadZmJfs4a4RUjgNfl8ly5p3fi7fhKbIzG0AM8Bdg lgaDGcsVGendS0gHLwAr+oO8TtEPhns= Date: Mon, 14 Oct 2019 19:53:19 +0200 From: Borislav Petkov To: James Morse Cc: linux-edac@vger.kernel.org, Mauro Carvalho Chehab , Tony Luck , Robert Richter , John Garry Subject: Re: [PATCH 0/2] EDAC, ghes: Fix use after free and add reference Message-ID: <20191014175319.GH4715@zn.tnic> References: <20191014171919.85044-1-james.morse@arm.com> <20191014173006.GG4715@zn.tnic> <86ba3fcf-d29c-1d6a-d8c3-2a03cb11263e@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <86ba3fcf-d29c-1d6a-d8c3-2a03cb11263e@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org On Mon, Oct 14, 2019 at 06:40:33PM +0100, James Morse wrote: > Keeping both avoids the !pvt check in ghes_edac_report_mem_error() going wrong, but I'm > not entirely sure what that is trying to stop... It must've been some sanity-check in f04c62a7036a ("ghes_edac: add support for reporting errors via EDAC") > The possibility of races between notifications and unregister only occurred to me after > testing the first patch, so they ended up as different things in my head: I thought it > deserved its own commit log as its unrelated to the KASAN splat. To me they fix two different aspects of the missing counting on unreg. > I think you need some kind of reference count to know how many more GHES.x there are out > there that may call unregister, otherwise you race with notifications. Provided unregister cannot be called concurrently, the if (!ghes_pvt) return; in ghes_edac_unregister() should suffice. But just to be on the safe side, it could get an "instance_mutex" or so under which ghes_pvt is set and cleared and then that silly counter can simply go away. Thoughts? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette