Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3397330rwb; Tue, 16 Aug 2022 02:09:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR5e6V51Rs0E4EsBKTO0HbJsmjVDs4Pw46+VDpfgT2SaNvHKsXWUq2umBqQkKBGcYukrR83N X-Received: by 2002:a17:907:7637:b0:730:6a9b:148f with SMTP id jy23-20020a170907763700b007306a9b148fmr13164769ejc.273.1660640963030; Tue, 16 Aug 2022 02:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660640963; cv=none; d=google.com; s=arc-20160816; b=yw1phMLakGZ5wtpSFs86vRa25wWgS//5F23NAOIMoeMAlXarkEgRRU/CINbqVF3I0A 4I0gML5A8N4K7pjq6QPLzrGggpesgrJ6/0dnfJ7Z3rll0l1H7yFQ7PHY/nQGr4GWxhJT fXzoUDR+gfYSLIO4crhma7Lx6k5LRF5kd/e89GRvItYnoO5ZkMsSHmMZZgz3qEL8tfBK /wtgfkEC+ygwJdwzdi44drwBWzacHcsJsYY6ttEzJNHJWrd8UbHu+1csxu07LhX4XaN/ 6NKvpE4s9nBmR6/C/A/hGj9V5V/9YLSxiD0JzmiWQ/0v9TmbC2AbwLrA/eIX+RlbvO1e MEAw== 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=3psW2d7cqoBy6E2iwtp8b2hQepltYWekk3B9gvFOXFA=; b=Yp4MqpKuLU81r31yF/zdnm4z7mkRyN9UeCAEZ4fdZ+jr36IIs7K+in0MAtZbe7ToDB M6DZdtMa8gBHunv+zPV3sfZhx+qRsZ6OK7kEr/LNyNOuR+7cDCMf0UN02tqvpSpFA0Mm LZ0mQv33WBusF1InSA/cAIQKLGzl3W12Ss77GV7NhHpcKk2M4g/PYXUeHZqGUCYOSdRT GFRldUFaK+AREa5Ua7PmtrtNMON07ipG7KBqE8H2bn9Cg+zULb9b8dK11jl7TAZ1vSja 1hSSo9A2BFSoQCLdrD50K3vrGU63UJn4TzUxWoYz5TNM36hBMv1KBI8MCfTMpvXkOg4d 4jJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marcan.st header.s=default header.b=UYrY0eQv; 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 sa7-20020a1709076d0700b0073094ce02casi10612498ejc.791.2022.08.16.02.08.57; Tue, 16 Aug 2022 02:09:23 -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=UYrY0eQv; 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 S232511AbiHPIRN (ORCPT + 99 others); Tue, 16 Aug 2022 04:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbiHPIQd (ORCPT ); Tue, 16 Aug 2022 04:16:33 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 826004B493; Mon, 15 Aug 2022 22:37:40 -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)) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 8F51B447D8; Tue, 16 Aug 2022 05:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1660628259; bh=klFJScQtPdSGYcjCrTuLd0vmp+BxBQY7IprafXE1WXI=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=UYrY0eQvg03ffFpSW8MPibeWDmSlQ/yIUpjNy0a6r8M5yYDkXuuY2mgbvXGRIvUKV GKz0u6P8fP347aqNjdqhKCYZ0hFw97bxhf4/fNsEOEsk0hKwi3mcerFSmxESOJtObT ehE5TDjXiRASB0Tulir8a5ysB6oWfFiNPMGbPFaEHIkqpw3cbHaGwhpgxXXTL8zzPZ Rk7YU9AniJOpzHeMzqoGsi2OYvQ/6Rcogj3a4cY18e2p+OdyQYoMJRUkxaqMCUj3Q8 sR2f1ZuFZuhOHeN4Zq5QAjXQLlzT+m6x0uN6nV8Fbd17jp7/ETXkceDCDFThJLdMRQ HVN0NlTWFLFlw== Message-ID: <923f9638-d443-cb8e-104f-41a7f34fa25c@marcan.st> Date: Tue, 16 Aug 2022 14:37:33 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] workqueue: Fix memory ordering race in queue_work*() Content-Language: es-ES To: Herbert Xu , Linus Torvalds Cc: tj@kernel.org, will@kernel.org, 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: 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 16/08/2022 13.14, Herbert Xu wrote: > Hector Martin wrote: >> >> This has been broken since the dawn of time, and it was incompletely >> fixed by 346c09f80459, which added the necessary barriers in the work >> execution path but failed to account for the missing barrier in the >> test_and_set_bit() failure case. Fix it by switching to >> atomic_long_fetch_or(), which does have unconditional barrier semantics >> regardless of whether the bit was already set or not (this is actually >> just test_and_set_bit() minus the early exit path). > > test_and_set_bit is supposed to contain a full memory barrier. > If it doesn't then your arch is broken and needs to be fixed. > > Changing this one spot is pointless because such assumptions > are all over the kernel. Documentation/atomic_bitops.txt and the asm-generic implementaton disagree with you, so this isn't quite as simple as "your arch is broken" :-) - Hector