Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4617794pxj; Wed, 12 May 2021 09:20:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+L3FTxk+67V8q6V6oQ0VCLR05PYtjLU+nry6yTCnWw5OybjgbX3StUUJF8WWl6rTfNjW9 X-Received: by 2002:a17:906:d184:: with SMTP id c4mr5772096ejz.83.1620836424653; Wed, 12 May 2021 09:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836424; cv=none; d=google.com; s=arc-20160816; b=GQzpKumv55yiHmff86AAi8XVXi1zU5c+gXp2Lt/r6rG7n/wfzG7kuMcPMv3Sx8WEro Xa9+gIme7FNKYew47J/wx+MhzR3rz2nXW8DcBT8fPiKo8UmamTC8+7DyCzUSO/ejTY6J slTR3PN+deqbsGXCmezcAcVHnDjdJ87RLrStnvK1zYsJXzh5yNCdvvO9c4nV2HdiDdRb jha6simLDZFt27T3K5ZQx/FTvHo5BsxBl8vN0yvqDoBxIN+SOuD3ttwMwyFtP89g+lTt n/Mv6glBr4gFZM4zCJMoM++kj3qXfe1etOQnMZxiwULExIrwnpJtnJqAxBbOz2IVDrGQ 0AOA== 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=QgZvWTs55EX3WicUgKHMjTEcPQrp0aXQ4Yy7pD0KnVg=; b=YiUGGaPkrhCIUH464X4XO4vKfK5Ko9jZwzkixXZOH190n0M7qMCxm1OJuQzj0eJErC pen0Q2vao1XxXuMZtdBA2q7FNWZuMQdhe/23K6V/B3gdwgpI0rRP+Yyk4vpypbwMe2bQ EV6tlwOHJr5L62AgW+sHOQxzqQK7KOwF0CK8RN1MB84iJvrRBgXGA3YkJbzuzi5g2m3b WTmtAFW5Wx58/XpqmO4VdZr9V02Dk/8Bmz0MeaWxoP4ozqOvx9wnF7rFXxZ7oki1Sj4B /li2/x229+0XLYZRIHy4MOrteZ0X/i1j9yGTSWFL/LNhv0pC99B/Q7goSZxngYQSWkIz 0cCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lGwQqMwE; 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 nc2si355214ejc.593.2021.05.12.09.20.00; Wed, 12 May 2021 09:20: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=lGwQqMwE; 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 S238654AbhELQPO (ORCPT + 99 others); Wed, 12 May 2021 12:15:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:50090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233978AbhELPby (ORCPT ); Wed, 12 May 2021 11:31:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51DF561950; Wed, 12 May 2021 15:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832588; bh=DrqMZi4nokZn0/DxIwSbci06QRoDDiDNmpuUd/ZCHrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGwQqMwEssyf682P4j1DR8a7rrji5cZWdi0IYAZEYux7vuCsl3thwHLg9m+Wt8Cvb lvvsNjprixLnL4qdLf8QZnEUW7/hCOxc+CVCMfifmHATeDJRDvfHiUjiKLauFRhy1X xf5WTDn6DIYF0COgq2xTEHFaePxeao6TzBjLhyS0= 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 5.10 342/530] x86/events/amd/iommu: Fix sysfs type mismatch Date: Wed, 12 May 2021 16:47:32 +0200 Message-Id: <20210512144831.032728105@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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/events/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c index be50ef8572cc..6a98a7651621 100644 --- a/arch/x86/events/amd/iommu.c +++ b/arch/x86/events/amd/iommu.c @@ -81,12 +81,12 @@ static struct attribute_group amd_iommu_events_group = { }; 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