Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2351389pxb; Mon, 20 Sep 2021 19:47:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycvoGyVAy+HFz0i4MDda6fXBnNYFvO1rS8qVKw2qZUgfqnkWnbIVpOcnqIWNcRFs7Tx06U X-Received: by 2002:aa7:d490:: with SMTP id b16mr33628167edr.189.1632192444430; Mon, 20 Sep 2021 19:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192444; cv=none; d=google.com; s=arc-20160816; b=pfTwEw4j/UgcC83FidxcmVdYrmpnrVWZ/66j6u1B0zJs/A5yo+XuGd2JBOb8XTD82y aIBw9opCW2zaJW8rtA6q0wedhd3RIIT/hrN2HliJPwSNvjEfP0ouRg+AaqoL114yA3UM 4Ve4ffpBpzorNo79p19FnthIWFTWx17v4g7czWEz/MxNUDvga+ALo4Wdt0fchCc0Ie6a ycXkkRA8vlz4xEsROpyaKM+TcXCdhCNH/ufCElFYsdVQDHzf1PlyOGzv3j89Hq7DBbv+ 5xUU8ZyHYiqIY2BX0SJR46KrVytuI8D8mh2iRQcMiDBAE/1JUwOenpc83GqZPbXLfyxj G0Lw== 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=ejTxtry/CJrxPWeHj5vUuMOzFpyZwaIV2unDR591Nbo=; b=bb3CC8hJ6O0dhIbFKV1gpVMB1O50A90LD7xmtFCiD3eMHl1MVrVr9kT/dd60AUyqkM xOMJXDGwsYz9QID96oh4tlgB1AbUPxYSJg+f+RQUAVMUjhcP9XXHQHafkw/NgPRiHTY4 G3Pgq9rrQxQI0xOE2YE3V1tb0JkoqPR4l4v79jh9kirGawxIIVHbru+nKPpT+OJYQQ3T nlon1H/0aHryTwZMDBJUuQVZH8fQp8oQnBczxsbRyh4ilRxEqFgb4bN4xY5hTCYJgoWQ 1UhYHC3iJDgS4siPoQkRrUuRKJ4CiYwqzJXJaGWUhtmOP/FcfUR6lNZSZZslRSC1MZ4c ar1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tWLSkSkE; 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 1si14760958ejg.330.2021.09.20.19.47.00; Mon, 20 Sep 2021 19:47:24 -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=tWLSkSkE; 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 S1378647AbhITSZ3 (ORCPT + 99 others); Mon, 20 Sep 2021 14:25:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:40568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377344AbhITSSY (ORCPT ); Mon, 20 Sep 2021 14:18:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F20D61A71; Mon, 20 Sep 2021 17:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158577; bh=o3UecA5NoXInC+2F7XnJOOzYfdBMDOub+0YzEM8KmZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tWLSkSkEeqtRA7ZD16wM3L8kZPz+UFDzP6HWjLy/50SitS3AaKIoomJo54GCw/l+z HzrrjHXNsQFmSQdL181Zq8i6vSaZh8Z4WVw60KpxdAIlfU/Vy/aJy1x7jwNefBzQJu 5Fhm7Pt+jTT59SSX5Itb4FU+4gkr0h3r01UDIooc= 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.4 219/260] events: Reuse value read using READ_ONCE instead of re-reading it Date: Mon, 20 Sep 2021 18:43:57 +0200 Message-Id: <20210920163938.552568331@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -9259,7 +9259,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;