Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3769952pxv; Mon, 19 Jul 2021 08:20:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLzqpu0ZyiwwfDV2mg1qowdTGAZSZxWGGOqAXQjnEICaBXNwqHILs+nlpQGUdPQge+Sb7E X-Received: by 2002:a05:6402:13c6:: with SMTP id a6mr35381434edx.213.1626708030457; Mon, 19 Jul 2021 08:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708030; cv=none; d=google.com; s=arc-20160816; b=pKiaWhdAoqA+2Kqiw6ZWeAX/GuPu+m/AfGFKY3fmtyZbvgYP4cT6aCNAorFduy6p+A r2lrr6qO0MA1drly/PxSXA+7m4RHHbO17QLs6EXwJ7BP2qq1HD/nLIRyZFDCKPI3MwJJ 2FPBpJS1PsBTesRbLPvUj9Ugcg1TMhQsnCM1ptxdlJs8FnxyfnEFHw+ybG2BffN+sMbc nn2LNeJcsOzrvulwKg2BZ5yn+xCGhsZSo1J8jeF0gREzGokdB6MNQGusJVaLTCxL6fgH cMPAaY/InFWyju1H5+6g+SGsOLT5vU8J2PfSpssFfIXSk7UOnVLStGR8VhI872Ws7LU9 t4sQ== 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=BYCb92ZE7lL2dA+maDSU0K/i175fsMXmJQtf15thAx0=; b=Hf6aOq2dFnXxUlcR8+URu8g2l1QnnrGnJWMjuF+wo4yCX8RzqOQtJhbm/MlixzQWmU D/u6cTAUXtOXLCKX9GtPsDsRGazbIiHdvUyVtjrEmxctJ4nuUzPUdkdH3j6Ppr2eMRM/ N8jBiVac1GZBT2Kry2gGRC4tChdaCEaevYEaBVsTlcDYvEVcXpsbv3CifqNtyVUHVcUW G0h5CvIITv88mpnPVGPtG4nu3zXU53bI5JJDGeYO5ZrdH1T6WEYDUn97QXTai59jOEhS 99JPb8CkzYy+VdpB59FQAWTVqfXB6wNOl+UjMUOOnzUyAQcrYr/tXneW8kFCRDOewPwx bgwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ORX4MrkM; 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 w7si519511edd.27.2021.07.19.08.20.08; Mon, 19 Jul 2021 08:20:30 -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=ORX4MrkM; 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 S244878AbhGSOgy (ORCPT + 99 others); Mon, 19 Jul 2021 10:36:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:39738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244938AbhGSOaJ (ORCPT ); Mon, 19 Jul 2021 10:30:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68B7A60249; Mon, 19 Jul 2021 15:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707448; bh=KL0d6ZCdD2YA4yfMePipnWW6srLjmIpJE1UENmQilug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORX4MrkM4w3GEPDWlhwFFSV5R0tZ16s5su9vkCHU+HIUDHyv+tfQNEccDmkaNyLBJ +852jyddOx/9Bd3aoDJ74vLvNU9ocbMBy50hMz2ilh1Dk21iHU5uhVCqP3G+DiZ44P Ytn8M7GmMW2SKovRaWB7jrYm8m3Ef+wyJ8lpHZds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Sami Tolvanen , Sedat Dilek , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kees Cook Subject: [PATCH 4.9 167/245] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute Date: Mon, 19 Jul 2021 16:51:49 +0200 Message-Id: <20210719144945.805200557@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 commit fca41af18e10318e4de090db47d9fa7169e1bf2f upstream. fw_cfg_showrev() is called by an indirect call in kobj_attr_show(), which violates clang's CFI checking because fw_cfg_showrev()'s second parameter is 'struct attribute', whereas the ->show() member of 'struct kobj_structure' expects the second parameter to be of type 'struct kobj_attribute'. $ cat /sys/firmware/qemu_fw_cfg/rev 3 $ dmesg | grep "CFI failure" [ 26.016832] CFI failure (target: fw_cfg_showrev+0x0/0x8): Fix this by converting fw_cfg_rev_attr to 'struct kobj_attribute' where this would have been caught automatically by the incompatible pointer types compiler warning. Update fw_cfg_showrev() accordingly. Fixes: 75f3e8e47f38 ("firmware: introduce sysfs driver for QEMU's fw_cfg device") Link: https://github.com/ClangBuiltLinux/linux/issues/1299 Signed-off-by: Nathan Chancellor Reviewed-by: Sami Tolvanen Tested-by: Sedat Dilek Reviewed-by: Sami Tolvanen Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Kees Cook Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210211194258.4137998-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/qemu_fw_cfg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -192,15 +192,13 @@ static int fw_cfg_do_platform_probe(stru /* fw_cfg revision attribute, in /sys/firmware/qemu_fw_cfg top-level dir. */ static u32 fw_cfg_rev; -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf) +static ssize_t fw_cfg_showrev(struct kobject *k, struct kobj_attribute *a, + char *buf) { return sprintf(buf, "%u\n", fw_cfg_rev); } -static const struct { - struct attribute attr; - ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf); -} fw_cfg_rev_attr = { +static const struct kobj_attribute fw_cfg_rev_attr = { .attr = { .name = "rev", .mode = S_IRUSR }, .show = fw_cfg_showrev, };