From patchwork Mon Apr 15 20:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1923920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VJKLN65Zlz1yb4 for ; Tue, 16 Apr 2024 06:59:55 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rwTQY-00069P-Ky; Mon, 15 Apr 2024 20:59:46 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rwTQV-00067Z-U2 for kernel-team@lists.ubuntu.com; Mon, 15 Apr 2024 20:59:43 +0000 Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A701E3F67B for ; Mon, 15 Apr 2024 20:59:43 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-7cf265b30e2so432893739f.1 for ; Mon, 15 Apr 2024 13:59:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713214782; x=1713819582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=meR5vdKeQKMycaE3FYTYxYRqLHHafNHdHMQFtYr+3p0=; b=JTzwGXC2Kg0trOSn86CuSMhhlKjSm16RIZkMEoxoTDaSMz8s5D0yQYjIcRRcGPMZfo Od53wghX469gaCjw9HJuu7TfNUb66R+61wW14TnwjURkP+5VxrvBDcqQpvzGf1jRrvkl ipSIFmhBLt9Kta3sMe+BtErzXcYIzvM6xM+FlHD3SFbf8+tI+x/8y4CWMOdPdJsHJq8f 3I7/dKf7Rmi47NcoY4D3w0XsKWNAYXW72G9pKejl4VsGh53+vkVH1TnXo6R1zgD/y2Ei shhDpjLb2IkOw5BKhEuln+MOJQHBYmR8QAJzjMGdK2MS8CEAdlV4tdnaLwzdZFZvBST9 ZeVg== X-Gm-Message-State: AOJu0Yzl5gE38U0n4ngz3hUDJNpfKRlTglbx7JLlmfdJF7McHn5eeX5r 4Dsa0oFeBzXFTGLFQzbyDWYD4lWvXPmaZYlpx3M94t18+JzPswEnzGr444THnLYxfGKgEJN39cg 9la9nn5n5CHhbDk4yWdS9Gnck1VMYX0/L+FOisG2TGc7YH8OpN/R7tL/Zxqd7HsLVwe4xDBYo++ 2IgaIEARkYeg== X-Received: by 2002:a05:6602:3d6:b0:7d5:e175:495d with SMTP id g22-20020a05660203d600b007d5e175495dmr15077113iov.21.1713214782393; Mon, 15 Apr 2024 13:59:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZygUeJxxDeXqruRR+Uz4PCEmGmzJyZeQItlF7eu+lFhF7NIEhEVhXADTIf9ikR+QmdTSlaQ== X-Received: by 2002:a05:6602:3d6:b0:7d5:e175:495d with SMTP id g22-20020a05660203d600b007d5e175495dmr15077105iov.21.1713214782073; Mon, 15 Apr 2024 13:59:42 -0700 (PDT) Received: from smtp.gmail.com (104-218-69-129.dynamic.lnk.ne.allofiber.net. [104.218.69.129]) by smtp.gmail.com with ESMTPSA id c35-20020a029626000000b004828f584db0sm3473435jai.80.2024.04.15.13.59.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 13:59:41 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 2/2] rcu-tasks: Provide rcu_trace_implies_rcu_gp() Date: Mon, 15 Apr 2024 15:59:39 -0500 Message-Id: <20240415205939.141814-3-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240415205939.141814-1-bethany.jamison@canonical.com> References: <20240415205939.141814-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Paul E. McKenney" As an accident of implementation, an RCU Tasks Trace grace period also acts as an RCU grace period. However, this could change at any time. This commit therefore creates an rcu_trace_implies_rcu_gp() that currently returns true to codify this accident. Code relying on this accident must call this function to verify that this accident is still happening. Reported-by: Hou Tao Signed-off-by: Paul E. McKenney Cc: Alexei Starovoitov Cc: Martin KaFai Lau Link: https://lore.kernel.org/r/20221014113946.965131-2-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov (cherry picked from commit e6c86c513f440bec5f1046539c7e3c6c653842da) CVE-2023-52447 Signed-off-by: Bethany Jamison --- include/linux/rcupdate.h | 12 ++++++++++++ kernel/rcu/tasks.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 13bddb841ceb1..e3b12de36e924 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -205,6 +205,18 @@ static inline void exit_tasks_rcu_stop(void) { } static inline void exit_tasks_rcu_finish(void) { } #endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */ +/** + * rcu_trace_implies_rcu_gp - does an RCU Tasks Trace grace period imply an RCU grace period? + * + * As an accident of implementation, an RCU Tasks Trace grace period also + * acts as an RCU grace period. However, this could change at any time. + * Code relying on this accident must call this function to verify that + * this accident is still happening. + * + * You have been warned! + */ +static inline bool rcu_trace_implies_rcu_gp(void) { return true; } + /** * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU * diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 96722dae824b5..3ebb0bbe8ede3 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1098,6 +1098,8 @@ static void rcu_tasks_trace_postscan(struct list_head *hop) // Wait for late-stage exiting tasks to finish exiting. // These might have passed the call to exit_tasks_rcu_finish(). + + // If you remove the following line, update rcu_trace_implies_rcu_gp()!!! synchronize_rcu(); // Any tasks that exit after this point will set ->trc_reader_checked. }