Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4680832pxj; Wed, 12 May 2021 10:44:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmqPnm4dNGwA79R3it7FCPDcJl1OIZW4X1Bea3WT3jS1RtrXu0siwrKe3dCM6kS7L+XRoo X-Received: by 2002:a17:906:170f:: with SMTP id c15mr38352431eje.358.1620841391617; Wed, 12 May 2021 10:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620841391; cv=none; d=google.com; s=arc-20160816; b=Plr6U67EFiIvZWrA+VykIeR4iFlsTGUrxaZdy3fYsBn1EepUumtrOp9dUlsEdDfUSO 0mkElGTwSUMB02nZiCCSpPcrEQT0iCiSFB0+j6U7hFkJNMJOh8PfhfD7jDAQ5Hg10Ca4 pshtkFM9xMiZBvhLW50/fF7ifrHijdGWeFYhCIs2kO2cMy00vAU9TaoXE38RW0c1eqW4 QootZ2VijfuOfgxh8j831taF+ZdM3VCm8OI7Qpe23DvErayZ79tl4QVFIWePzJNwVswG YLRMitM96twmKvvx31Cc9UMFcahRhLrsgEYxmfsn9TKyIhmKNeLHV+4pV4lBDCwkjmgi 4IiA== 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=927HhjyHJ6niFqnBgbNEjzm+1v47IsVnV9NF/2Z39os=; b=PnOYVSdAHnlU3IevKWeMGXTf/YrvTKSQbELIHxFo+G9VLwujXpDoOAgnG6mxb94kjH +F6Z7ZuwlrUzbxqJ9c2yUGKnRPY8fkFkqicNdWlrhUuv4SesWxrfhnoqKELWM/mYr48F TZhJieFnSoO4XavayhcxiPf396K5ZtDSlapk6t4POroYGIReG1ZwE5fx/iATBKziTimq be37AXrbdNzVbiJeThn9bai7eer4Hc3KxWV+cXevsuod/Rip/ZIcEG+Nw0Q39E9gdeQw ijUbAzJNtP/Pq2IVqrDmlmT3XWXzWVyUq3ktpDg8MSs3Wvthb/7+SfILeI3FOikHraxn Ihsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0hkFnAyA; 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 de20si259817edb.211.2021.05.12.10.42.44; Wed, 12 May 2021 10:43:11 -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=0hkFnAyA; 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 S1348964AbhELRjw (ORCPT + 99 others); Wed, 12 May 2021 13:39:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239652AbhELQKe (ORCPT ); Wed, 12 May 2021 12:10:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8CD7461C71; Wed, 12 May 2021 15:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620834026; bh=8jYJUo+MJWKNPzGWeVdRxkFpv2loBomQp5NniyhTeX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0hkFnAyA5gz8IrJg3pt7z8x8VMNCMX56LSod3QOL19SSk1G7JviCBBCQCqd0JmEhf SoSzTBeP8OZ+V0pl4f/PZ3AQDR8TK5ed17SdbzMYw3M/8WzjygaRnWGFHNv9ODZajP uBQgV2iZYHvV3wHOidZB1yMxTqwFKu5t6jHQG04c= 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.11 381/601] perf/amd/uncore: Fix sysfs type mismatch Date: Wed, 12 May 2021 16:47:38 +0200 Message-Id: <20210512144840.341040327@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@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 5deac80d4571dffb51f452f0027979d72259a1b9 ] dev_attr_show() calls the __uncore_*_show() functions via an indirect call but their 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_l3/format/umask config:8-15 $ dmesg | grep "CFI failure" [ 1258.174653] CFI failure (target: __uncore_umask_show...): Update the type in the DEFINE_UNCORE_FORMAT_ATTR macro to match 'struct device_attribute' so that there is no more CFI violation. Fixes: 06f2c24584f3 ("perf/amd/uncore: Prepare to scale for more attributes that vary per family") Signed-off-by: Nathan Chancellor Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20210415001112.3024673-2-nathan@kernel.org Signed-off-by: Sasha Levin --- arch/x86/events/amd/uncore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 7f014d450bc2..582c0ffb5e98 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -275,14 +275,14 @@ static struct attribute_group amd_uncore_attr_group = { }; #define DEFINE_UNCORE_FORMAT_ATTR(_var, _name, _format) \ -static ssize_t __uncore_##_var##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, \ +static ssize_t __uncore_##_var##_show(struct device *dev, \ + struct device_attribute *attr, \ char *page) \ { \ BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \ return sprintf(page, _format "\n"); \ } \ -static struct kobj_attribute format_attr_##_var = \ +static struct device_attribute format_attr_##_var = \ __ATTR(_name, 0444, __uncore_##_var##_show, NULL) DEFINE_UNCORE_FORMAT_ATTR(event12, event, "config:0-7,32-35"); -- 2.30.2