Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3478180rwb; Tue, 16 Aug 2022 03:56:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ONp5nQug+BPZOdcqE2EVRmiri17P4CblcrpimabxHTTaqnzwYf3kF8DW1Ex1MOkYymDAW X-Received: by 2002:a17:903:40cb:b0:16f:196a:2bb4 with SMTP id t11-20020a17090340cb00b0016f196a2bb4mr21567835pld.104.1660647390637; Tue, 16 Aug 2022 03:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660647390; cv=none; d=google.com; s=arc-20160816; b=v3Mkhh+A+683lPpa3D2RkynTa+GOnhUtFrPP1nLoDFJyCJF2GgiNvTU/1WVw/zI1rr 8ZePg1XwS73J3QysdoeSXZee0fSI5xwlI+QSUeeBEGr93Q6vwtbfydAL38xmmzhiXVeZ jQ+aqqs9Jyt2vM/8iDqGMEujJSO0/vTeMzoX5LvEDGb1TtGZPwDFu+s+9MMzfHdUbbCr 7xo3kRFU6N0Pk6WVOuTJpcOsgJYwVnGIx7I/3xlXDIjMGEQJj2KpZVdaHTYf7mpEC0+3 k5a7l74aZHywQEn81JhbIGWZIvD9yJwHpgUwjcqfM7WArsV1HFNZJPX8T/ZLtkYzJzm9 gu2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=j4mjIqkkcwa/XFqtbhXgUDvxwWJne070h2tC3J8JSw4=; b=PATdqMN/Bx3ktrQXJHzeacRPm4+5qU4PhSQdTJ+WeuomfPrAQpMat/OxNTBcNBKcZb XbQdM3y3DG8CM/IrsUUvTelurcT5eOWqxfhlNUaqN7yRCk12qkexvRFSuDtsrZi6KvJ0 w2tBTeWQ1rYgM+wYGeNoHcQokYhH2NebrnzXGlQyGxxG3SX9AlQM40QyR3NyRKtki+Rs C/bDVRJKgGSL9QxBHRG+b7J6iOE0IMqtMRNwjI/ZmQfmNSRpycRNJU7NxBmnqDW6I9z+ KJ69nK8PbRy5mJaFn5KNPEfHwvIuJwQ/Opljw9hrkC6htA4tk/K9gS5AHMFm0ddDnknT UgKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marcan.st header.s=default header.b=DaLeUy6i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k133-20020a636f8b000000b0041b67131e27si13167759pgc.309.2022.08.16.03.56.19; Tue, 16 Aug 2022 03:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@marcan.st header.s=default header.b=DaLeUy6i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232858AbiHPKQB (ORCPT + 99 others); Tue, 16 Aug 2022 06:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbiHPKO7 (ORCPT ); Tue, 16 Aug 2022 06:14:59 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 181FF5A2C4; Tue, 16 Aug 2022 01:01:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 8E23941A42; Tue, 16 Aug 2022 08:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1660636907; bh=hdO0VK1BgxthiOSTlr+e1eaO5dfWp+h7FMXRza4Hsq4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=DaLeUy6iahjaMjN9JrVNc57ZozIWEObhc79ETbuWH6F4g2xflaB0R2I9U12Ei7s5z c2ZH7+UHYhXpQJr/ul4lQrS49JpL1YF7DD9LwwdH4J5nC8ZbMlz2YlPqtjkybNBjIs NsSOqPqMrknOup3Ju2HGcGoQYJ2pptLHhZNC0aP439quZj3TRIADaHsix5DBPMXU53 ELmGSpq3U830ZMod7U3u/QdZK09aGS4ZGkyip3lnTzJPuVW6UtzLV26E3hyR39MfK1 RBnjaozfwBmzm+dzR+FXJ11o1uU1z/E9CG2t1asjvQoCksdVzIj+wetB8Lw79d7aAV eol3iUbS6rPYQ== Message-ID: <0c0ba856-a4ba-7133-e751-3a81c82311a9@marcan.st> Date: Tue, 16 Aug 2022 17:01:39 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] workqueue: Fix memory ordering race in queue_work*() Content-Language: en-US To: Herbert Xu Cc: Linus Torvalds , Will Deacon , Tejun Heo , peterz@infradead.org, jirislaby@kernel.org, maz@kernel.org, mark.rutland@arm.com, boqun.feng@gmail.com, catalin.marinas@arm.com, oneukum@suse.com, roman.penyaev@profitbricks.com, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <24c88c4f-aea5-1fb7-0ead-95c88629d72b@marcan.st> From: Hector Martin In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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-kernel@vger.kernel.org On 2022/08/16 16:48, Herbert Xu wrote: > On Tue, Aug 16, 2022 at 03:28:50PM +0900, Hector Martin wrote: >> >> This is the same reason I argued queue_work() itself needs to have a >> similar guarantee, even when it doesn't queue work (and I updated the >> doc to match). If test_and_set_bit() is used in this kind of context >> often in the kernel, clearly the current implementation/doc clashes with >> that. > > Kernel code all over the place rely on the fact that test_and_set_bit > provides a memory barrier. So this bug that you've discovered is > not at all isolated to the workqeueue system. It'll break the kernel > in lots of places in exactly the same way. Now I'm surprised this isn't failing all over the place, given that... these things are annoyingly subtle. Still would want Will & Peter to chime in, of course. >> As I said, I don't have any particular beef in this fight, but this is >> horribly broken on M1/2 right now, so I'll send a patch to change the >> bitops instead and you all can fight it out over which way is correct :) > > Please do. Already did, but I just realized I forgot to Cc you. Sorry about that, hope you can pick it up through the MLs: https://lore.kernel.org/asahi/20220816070311.89186-1-marcan@marcan.st/T/#u - Hector