Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3017965rdg; Tue, 17 Oct 2023 01:51:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3iYPYpoQDu5CnHKcRZablkmg2Nc44ittaw34GDuTtw6TsIOIR/mQpAvuDt6elPtkT8gwJ X-Received: by 2002:a05:6359:5c13:b0:166:a6e3:d3d3 with SMTP id pu19-20020a0563595c1300b00166a6e3d3d3mr1868781rwb.8.1697532674830; Tue, 17 Oct 2023 01:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697532674; cv=none; d=google.com; s=arc-20160816; b=K8i6PRbrCcXuFrrR9MYF/s7rMaCEU9WRI12/5JLogwdplY+sBDY7FtR/QkU7dRdHS+ 2qdsStvNPv+vhIbREYUek+PxlTRebOlgbFHnLdNzjEMgKTGK+frg8mzoY8BsBFiK8KfG H762lmBz4AoNHL8AZKhcpdEWNh7l80GxC7JYY3mYixx9x1B5+wDqTfrmEpGDay7h8bmL 5j7056HCXvT1FHt71GfT0ODIUHE6dN6DRaS8FUAmnfsv3Hzr64vspThqzMxT0deuJgBq ebwvW3CIrMsSmZA78ksq9XtQmimMe/f9l+hLl4eyfz7DxukPLRWilI4W72chETE9bcf9 RUaA== 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:date :subject:to:from:message-id:dkim-signature; bh=9uFm1swz/WuySLvKGXHbXWNCQTdIg19qp5EJ/O34ajM=; fh=RUQVdVZH2FR18CrjX8PCifUFNIJLTj54dOHt1R32Ep4=; b=w47l0/n7+2NK6qimxH/f2rZfO3pAc2NA6jns35QaprR4MSJTJHclkbgzYbRCGOn1c2 vUNXl3S4P3NHAG8Te9tFPRt9aiKvRL2MtK6WOf7FJ6+CixiQR+/tHm0nO7GymBC9bqGC IizARSdPoARVQR+I5sYeX/uLCpEvbTIDqEw9aV0fHYRnCS70JFYyAGHOLaclR4pc+9HU 5GcZcda6vqJGU0uuDue/mhQmZS91iulA7pYz+34uJNuOL4n74kX+YugbD8wjGIf9as4A YTwbt0sNj3oSZM0f60wTFNNVHxCbXwo4bhy1pvNatDUj6Iwt2hcLan1egvvDBKRK3sBS y1QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=BKRcoewo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id b5-20020a637145000000b0059dc0902db3si1390805pgn.228.2023.10.17.01.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 01:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=BKRcoewo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 300BD806AFCD; Tue, 17 Oct 2023 01:51:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234680AbjJQIvF (ORCPT + 99 others); Tue, 17 Oct 2023 04:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234620AbjJQIvD (ORCPT ); Tue, 17 Oct 2023 04:51:03 -0400 Received: from out203-205-221-192.mail.qq.com (out203-205-221-192.mail.qq.com [203.205.221.192]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F50ED for ; Tue, 17 Oct 2023 01:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1697532658; bh=9uFm1swz/WuySLvKGXHbXWNCQTdIg19qp5EJ/O34ajM=; h=From:To:Subject:Date; b=BKRcoewoyh47KFeApgMNZ1G63acF/V+DNlaQ1/0h/GrGh2BprmZP3ySAX0eRrw9RR G/ZQNGAleU3e2LSg2llJx9JCSaIsDH8/W9n9xuvj2PRkz9xskTRSgWybxmc+iyogOg fosNjUDAnhV4jCxE/xdqQAf+OvEqBM6IRwT5Ku5I= Received: from RT-NUC.. ([39.156.73.12]) by newxmesmtplogicsvrszc5-0.qq.com (NewEsmtp) with SMTP id CB837072; Tue, 17 Oct 2023 16:50:56 +0800 X-QQ-mid: xmsmtpt1697532656ti2ncg7rd Message-ID: X-QQ-XMAILINFO: MyIXMys/8kCtt4y1uxNGwZpRB3usmzxHRUaiJ+PZ0Y6gfxbVLShGIS5D6Yyldu aWbS43+6OvJjA9YQ3nK4x8QBLmqvkx3a9iPvIBrXfO1WiQuzHq/WhTlqvLcIlk0pzk3o62bJ+3o9 wiXzBI0+i+L2t70AmnUW6C80wO6izz6Hwh6h0qscGqRJB5g7edjcE9h/7xJnlCOuBd5PWEv775jG Vq6eDiRRPZj81D63BiX5nEkF5dGUpNs6NYx0Cz86foBbQtHpk7aBCjXSF0h4lc8Oaw3byjJAi34y nNC+IpKFnVGFiKRFtGiDS3YdIq/0EktKed+lUfNcZ2mlJ3KtchAqnPDMFWOfDJ6XKRhmYQIDTqgc po5iHAawCC2DHvkquY+cj/swh2YNCVzC/DdvJIuRRDt7CPfFsFs5yNUS7D26CN6yO0NZ0eyiztqE 8ijyplOxawiTUgP6os1l+5Ry/zBsa+12D7r/AZFHaZJqoe/q9HEphNf8pOUQuLBxWKUKRaFoPIl9 Lyw/S94gFR9smyjBeVlAA6A44n0tBF/e0bzGqUBVTssmmL0CCzsTXryGMWFJAFTHFLz2prvoXIEI YUDnN/Q4iiIoDQSMkHHKi1f0pVUATWegwqF5LOn2WPrKHIb3mcMye5s31Fn1UCqsNevOLBarR492 oCa2t8i+B+NCLvIl2ZE2U4yiS8L6IJKIzIJTrA8rdVWrvd0xi1f0UgZF/DmrCjyecFxaaB18MPa4 4yg+x7jtDX2Fv6udOTcEHhkmo3nalpaE5xVJ6X9/GBL/7Y4l5cCpNCSL6yueGc0ji6InaMluL7jp sHOz1+5XzqY1qzlO2g9yljiQCbF1x+mz2j1ShTUu0BjoZXiuLYsY54satbG7AR+S2q8ADOOISM+I JW5PDwakYLPQO7HSScp3Jq4bEWjr948udXtSsoOioMuYcERKQduHreIoVY0DPWu/0TXhCR5n6LQq wyk9KRkNXlBq/W/oMu7Q== X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= From: Rong Tao To: mark.rutland@arm.com, elver@google.com, tglx@linutronix.de, peterz@infradead.org, Rong Tao , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] stop_machine: Avoid potential race behaviour of multi_stop_data::state Date: Tue, 17 Oct 2023 16:50:52 +0800 X-OQ-MSGID: <20231017085053.263070-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 17 Oct 2023 01:51:12 -0700 (PDT) From: Rong Tao In commit b1fc58333575 ("stop_machine: Avoid potential race behaviour") fix both multi_cpu_stop() and set_state() access multi_stop_data::state, We should ensure that multi_stop_data::state is accessed using the rwonce method. Signed-off-by: Rong Tao --- kernel/stop_machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index cedb17ba158a..73de9ab77132 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -191,7 +191,7 @@ static void set_state(struct multi_stop_data *msdata, static void ack_state(struct multi_stop_data *msdata) { if (atomic_dec_and_test(&msdata->thread_ack)) - set_state(msdata, msdata->state + 1); + set_state(msdata, READ_ONCE(msdata->state) + 1); } notrace void __weak stop_machine_yield(const struct cpumask *cpumask) -- 2.42.0