Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2352848pxb; Mon, 20 Sep 2021 19:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6NZZIJrG3CWXCKIBZGFie3aiXz72n9odCKbSXfIScsLzgr2ZbsoLPcjrUpa7zyTv73aRK X-Received: by 2002:a05:6e02:ef4:: with SMTP id j20mr20537617ilk.294.1632192623262; Mon, 20 Sep 2021 19:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192623; cv=none; d=google.com; s=arc-20160816; b=vDqGOijRvIJoKis2MThTEGGVWzkBpdIBNWqLvju5pQ7hLfLLpjfud5Y2LN5vYXviKz hap/fCLXfNMphWXXduSNtd8pzO6VRQuopzfWvTEPFerUNsXhBDa+4J7MF6fQ0xEIqbIL v9rp3pD3ZsPQ1XpLN9RGQZMtpN76VO53fEV/67/DBdhr+0U1WgGshSBPGbXAMdD2pJSQ lzVmKJmW1BA96w9IstMCdZahmsj2587oLEbfeLpPfk0x4VrtBu43+JBQvtZjMe5gfLy7 6SD6/TRHTkwW9zWtO7z1JQVQotxokYW8MXDdDAZrieC8QnXMJpymnlB3pCslt6YPt7Rl U6HQ== 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=ZVMw5/Jxq/uFhf9vuRArVU/Pyon9kLJ1Krcx1Jbzp8M=; b=0wLLd15hISB6H0RlAn/EAO1Zc0D3+CR8Lpdx3BBpRMEa5HBcVqbyOowqne7zxwYZT7 93/r8slKTjsBufKbiWWYdtR33l6aqtrX7CqbFOzotRb9ZgGnPOCrMhhUSoT3sUvy362P aWOzIpvhKVUyn3yrFaBFew9kTPmUyDvkPIvGot+tCrSsUH/33xTuDpp3fWAZDcC2dfUF yciypGWE7Lfj5dX1dDuaWk8WfCkVFHhVKdPfVJvNtb3d+K6XqbbS+e6sePdQSa4hvSXd J1OQDg7yPxQ8wJW+xdG4ZR0qftKUQAotxf0Xb0JV0jHsVijExEoZ9P0sEPTN2nFepuYk CzyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pWUDfWlD; 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 18si10718599jak.85.2021.09.20.19.50.12; Mon, 20 Sep 2021 19:50:23 -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=pWUDfWlD; 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 S1383525AbhITSoj (ORCPT + 99 others); Mon, 20 Sep 2021 14:44:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:56446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382299AbhITSkR (ORCPT ); Mon, 20 Sep 2021 14:40:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F48663336; Mon, 20 Sep 2021 17:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159061; bh=2GJuYlt5+/+RNZzlYfYMWvApPEszUcLLoEHpH35uNAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWUDfWlDB53nf7c5j000sQIWOK8v0pq+LcUaluoJwdXXt4TOGm9YiplWPyviHuGYs uHVtoJ0TG6zHLjyuwZB8mOaeho0YRmbpKnbYoSSgCtYUycQulTXCOS4BO+MTErJHJK /ui3NH5oWBq1KNHc8r7dj/Yd2XFvr9nW1Kdc9vVw= 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.14 057/168] events: Reuse value read using READ_ONCE instead of re-reading it Date: Mon, 20 Sep 2021 18:43:15 +0200 Message-Id: <20210920163923.518240867@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@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 @@ -10192,7 +10192,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;