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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5A86C4332F for ; Wed, 16 Nov 2022 22:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233407AbiKPWbE (ORCPT ); Wed, 16 Nov 2022 17:31:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234604AbiKPWa6 (ORCPT ); Wed, 16 Nov 2022 17:30:58 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D2758BFB for ; Wed, 16 Nov 2022 14:30:56 -0800 (PST) Received: from zn.tnic (p200300ea9733e7de329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7de: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 8ECBB1EC053B; Wed, 16 Nov 2022 23:30:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1668637854; 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=cmRq9uXHaI9jSFnBZ3j6pMF3NRCi9BKeLHo9UftAF6Y=; b=YhdklwLDKCfJQFKUOidYM/oQ4yGzZsSlm5zSm9lgqzqPA1ZMEs+Lm1U9uIbOEcFq55Bt2d h2WvqvfpG/dYYDBtPWNDpkn4GHwJNvKjG9K6GxzxGMAgW/71wiwwuYvOyssP4L5XkoXKkp 1ZwEFpSFbl3faaveBFcq1g5bpYIKiQ8= Date: Wed, 16 Nov 2022 23:30:50 +0100 From: Borislav Petkov To: Ravi Bangoria Cc: Peter Zijlstra , nslusarek@gmx.net, Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf: Fix sys_perf_event_open() race against self Message-ID: References: <20220520183806.GV2578@worktop.programming.kicks-ass.net> <700710fc-1ac1-1b39-0e63-eb86adb4b984@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <700710fc-1ac1-1b39-0e63-eb86adb4b984@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 23, 2022 at 04:03:29PM +0530, Ravi Bangoria wrote: > On 21-May-22 12:08 AM, Peter Zijlstra wrote: > > > > Norbert reported that it's possible to race sys_perf_event_open() such > > that the looser ends up in another context from the group leader, > > triggering many WARNs. > > > > The move_group case checks for races against itself, but the > > !move_group case doesn't, seemingly relying on the previous > > group_leader->ctx == ctx check. However, that check is racy due to not > > holding any locks at that time. > > > > Therefore, re-check the result after acquiring locks and bailing > > if they no longer match. > > > > Additionally, clarify the not_move_group case from the > > move_group-vs-move_group race. > > Tested-by: Ravi Bangoria > > Below is a quick test to reproduce the issue. It triggers WARN_ON() > as normal user. No warnings with the patch. Shouldn't this test be in tools/perf/tests/ or so? If that hasn't happened yet, I mean. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette