Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2352470pxb; Mon, 20 Sep 2021 19:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYORnIgEw5PewRnqq8jW3X3+MxB+A9QfjO9PfEl0k+NzQVAGxrACjn2LQio1xkFgvtECXk X-Received: by 2002:a17:906:3882:: with SMTP id q2mr32763035ejd.396.1632192579346; Mon, 20 Sep 2021 19:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192579; cv=none; d=google.com; s=arc-20160816; b=iQZ7fBHIlvtEN3YFVaWLbB95xRSb94cgzQ4efD3llLZHrjGB6GuQFNHz5kUXsz+mPl /z6Wy2Zo5/ZahVFg/rj0eW6ENuvok3fJhsnwaIpFEUM6hbx5DJ8yu0xrRNYgJSiGHVMp RD2whKoL1OdUL1hlJSoV1WDpxH2Nlscr6KG0RqfrPpTQ3c0MJYSnlI4KLovLy+u2kC5x bCmj+zJ8sT5DOeb/Ipock7miPTdRvZR1+At/0j1OGozU/uZj8kF521sGiqrETLTBDlU1 zdgpzE4q7J56Il9BYErc2cKwQ8+p1zxFenIFle1T2UGXO+/OfyfyV6aHboGbWC1e3Di6 4TAQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Tn1d1QSbNegsALg9oHWWLZ/JUYhFWcLdvQkKU3j1DXQ=; b=CKGvyVgrOtZRJ0quzEtXJN7D2UI3kS9/0Y7c9pvyTbVoc4oiYYrJfrCKXNUqfWGAWT 2zEUw+mI1FRDlqlxeqQ4yMgenvXBZEfRjNShkSlGhd9goMntEpXXAvYFb4udEewMQEm/ PSxnLiDtGKR8NIl2fSmD8V7tdkyx28dbvU0ERqY+RwNcU9djO+g76PiG73oYJN3Uj+ni EJzW4WXDi0kcnWkDrievtny2r83ckVn0R1jEZjmK3/sUWwZ0yx6v89b2O8swC3jJiYgF 8cSFh3a12fEXuH/lN82ZDXdgqJc++Ub7oCWE5TIj9zF8HBsv3kJFa2k8pEqaLk0YXguX B8Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KkKBX3gU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si3888410ejk.388.2021.09.20.19.49.16; Mon, 20 Sep 2021 19:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KkKBX3gU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380044AbhITScI (ORCPT + 99 others); Mon, 20 Sep 2021 14:32:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:44429 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378767AbhITS0W (ORCPT ); Mon, 20 Sep 2021 14:26:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 870B5632D8; Mon, 20 Sep 2021 17:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158741; bh=D4VPni84wF61EId2NBulzn8VIIU1JAIKWC1+gu20/mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KkKBX3gUX3vX20dTOpIAH8m0knAlw08MTRutkLLJf6PC5qrhczipdvdvil9jyUmJZ dTtZc64kF6D8w1zi43WSEj+lZudRrz61PgbKWo+PoNxnwkK58/64Z1in5K6K+kJdd5 5OSMSldLDv2ygRh+Rww+s0Cx5iFu8gsa8micJUrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baptiste Lepers , "Peter Zijlstra (Intel)" Subject: [PATCH 5.10 035/122] events: Reuse value read using READ_ONCE instead of re-reading it Date: Mon, 20 Sep 2021 18:43:27 +0200 Message-Id: <20210920163916.946304990@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163915.757887582@linuxfoundation.org> References: <20210920163915.757887582@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baptiste Lepers commit b89a05b21f46150ac10a962aa50109250b56b03b upstream. In perf_event_addr_filters_apply, the task associated with the event (event->ctx->task) is read using READ_ONCE at the beginning of the function, checked, and then re-read from event->ctx->task, voiding all guarantees of the checks. Reuse the value that was read by READ_ONCE to ensure the consistency of the task struct throughout the function. Fixes: 375637bc52495 ("perf/core: Introduce address range filtering") Signed-off-by: Baptiste Lepers Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20210906015310.12802-1-baptiste.lepers@gmail.com Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9973,7 +9973,7 @@ static void perf_event_addr_filters_appl return; if (ifh->nr_file_filters) { - mm = get_task_mm(event->ctx->task); + mm = get_task_mm(task); if (!mm) goto restart;