Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp622637pxj; Thu, 20 May 2021 18:11:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNkn1bRQSqiL0EKSu3BOiKctNBLnMoPNbILiX5Ffz7fDj7YCC7rMInVUINQjqiTWS+trFp X-Received: by 2002:aa7:d9c8:: with SMTP id v8mr7883193eds.186.1621559502024; Thu, 20 May 2021 18:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559502; cv=none; d=google.com; s=arc-20160816; b=eOUMLb5kmxujZaubCzlZZoq2csrsnqrpfOxyokmeKOELHqJ1HgAl46yoHc6CcRCiAp JR7vE5/4shH3BRWyAA3D3mwS6Wjzx9NT8jaXwaDevtfGygdH9IxQNN82Dh6hzrhy3ylV H/wqxDimo3W9OJf8y32a1+xx0hFulzRwaZnG6cYg5h48opIubk6Q34qpInPm6KEknR18 68w8wrJEWt4Le+T+tcri+aiVvcwbGXLqorm5+J1aB+OWxQi59XeC1nSc/qeGb/TRk/7/ wv9cD/ICxbuWToPIn3UMtNBKXyG5aMLWNo25PBFbklBfmSL2Q8KvmK/cBUtzoTETNZJ4 /BiA== 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=Bz+ihbwsLGxXxSMsHevnhyCqwiotga5QE6kjzKuZS5A=; b=bKiSw5TX8NRkISI60l1qNRwk+LZ271dNX2d3NaVz3VfSghWrd98BqVN74LDC2esdLH 44zeYtGM+zQKgybZDp/EGiE6V16BS6nlWYH6DQE913uUtONyHBNttib1X+hMPUZo5Z5F WUSGRq/VLDr9JDF0PfhGVfiHhZszSbslltx5WGLkgw/waSP5Il5K67WYhkKRqQucwiiA fWgdHbjbaOpidQ5+wSMeZTHpL6dt5Fr5WvnQ/sWdyrL1Ll1Xd/R7Zv4KJFMjSWrFvAmW zeziQETamF8kVGw+M7aa83krsZ9/UQBFRYztAapPAUGjlLPLhvVLfCAEqF3Y1isEkQVp 03eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dFDRYEKM; 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 b5si3526697edf.3.2021.05.20.18.11.17; Thu, 20 May 2021 18:11:42 -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=dFDRYEKM; 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 S242572AbhETLkF (ORCPT + 99 others); Thu, 20 May 2021 07:40:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:39588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240387AbhETLSg (ORCPT ); Thu, 20 May 2021 07:18:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50A2661958; Thu, 20 May 2021 10:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505399; bh=9L0kefZA+evGsUfkvgKvlf7KaRvK5E+FIY1nVBxSgyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFDRYEKMCMOPImaRYgalZDckXgzjzAGODZ1fkoTi9OqzoGujT5/xY0sLmZj6yU52G o5HPkHOyEmWoOC1hxQCMHfQXKELgFZXVTxXFESTmiQPBxkAHk0XfP7VJxyOpx4fYED dWOBcAMUD/w3luSW7lpS2r947huljKe5ndLA6rVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 4.4 110/190] x86/events/amd/iommu: Fix sysfs type mismatch Date: Thu, 20 May 2021 11:22:54 +0200 Message-Id: <20210520092105.834249893@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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: Nathan Chancellor [ Upstream commit de5bc7b425d4c27ae5faa00ea7eb6b9780b9a355 ] dev_attr_show() calls _iommu_event_show() via an indirect call but _iommu_event_show()'s type does not currently match the type of the show() member in 'struct device_attribute', resulting in a Control Flow Integrity violation. $ cat /sys/devices/amd_iommu_1/events/mem_dte_hit csource=0x0a $ dmesg | grep "CFI failure" [ 3526.735140] CFI failure (target: _iommu_event_show...): Change _iommu_event_show() and 'struct amd_iommu_event_desc' to 'struct device_attribute' so that there is no more CFI violation. Fixes: 7be6296fdd75 ("perf/x86/amd: AMD IOMMU Performance Counter PERF uncore PMU implementation") Signed-off-by: Nathan Chancellor Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20210415001112.3024673-1-nathan@kernel.org Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/perf_event_amd_iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c index 97242a9242bd..ec0bfbab7265 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c @@ -80,12 +80,12 @@ static struct attribute_group amd_iommu_format_group = { * sysfs events attributes *---------------------------------------------*/ struct amd_iommu_event_desc { - struct kobj_attribute attr; + struct device_attribute attr; const char *event; }; -static ssize_t _iommu_event_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t _iommu_event_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct amd_iommu_event_desc *event = container_of(attr, struct amd_iommu_event_desc, attr); -- 2.30.2