From patchwork Fri Jan 20 07:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 46189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp65547wrn; Thu, 19 Jan 2023 23:44:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXt3yHsbwPPhrZdoHi0+lBSaXovoLTEfsdwHdzP/ZZMkEwOAcEJX3356yNcLt6/XKqnF9fgz X-Received: by 2002:a05:6a00:bef:b0:58b:ca6e:af26 with SMTP id x47-20020a056a000bef00b0058bca6eaf26mr13410544pfu.23.1674200689893; Thu, 19 Jan 2023 23:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674200689; cv=none; d=google.com; s=arc-20160816; b=qk3zrpGFq4xEUZ4OByjV/4qfwSzRFeJMzmGzWaDKxaNQ/Pf0oqS6ZwpS9MjVBoPprU GkMMVtDe65P8NNygp/HL5uM2rFyNUMZlyiwgnb4pc2YB7UlslauMvp/wgquD5pr78ajk /sqfid8qM4qbMvrfkWuxuZW2xyeKtVQTsKFeVedW+V0UDymyd3NYSiiV51eH+aUcgFjy ePRQBBc5ZG9pXCwbH86cyIVnVH+eIi+kXDMgdxDdpVVWyp8on/vootyceGixWa5AFPTq QreVs9XGMDvPRptFkPclBrX5oqA+RB/0oSJfsVu0pyUx3ATLRc0kTfkjmD7J3G9c+85p tyyQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NuXtRi+sNxhe/sIBYKY/0XKqxvWUK0NbODRPNhFZ7Jc=; b=W+Mh6au5duRZ5260Claj88oKK8+ii5tlDP8711B3K9YanlmFojtHi01B5f686FNLDv K5XPFe/O2cx0gHI1/+Hkx8Jzcu/CJC5fskxRkrl6IBBPmFTRnRo4AmOYumcLAH8ChtNF dvygJ1wRPLjZaqJJEBqg1kuQTbI2jyxwlsKcyyv1VWKECpiorYoEfQ54kGi1hdhq2s40 kRKbvFNyGPHMmNvy5OY7+MM84NpO2L7nE/BlPDJfVKL2Lf7WRj0oc6ZL8thn40mrY6vY g+Y0V8lGip5KV5oLQKXpdgS4g8Bh6jDwAWAgcF2dqQ7loJSBX4UOZla6RGRE4iUVRq/p VarQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=SHk+KIBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020a056a000a9600b00547d55a4d3bsi42769672pfl.285.2023.01.19.23.44.36; Thu, 19 Jan 2023 23:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=SHk+KIBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230451AbjATHoT (ORCPT + 99 others); Fri, 20 Jan 2023 02:44:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbjATHnv (ORCPT ); Fri, 20 Jan 2023 02:43:51 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07C6819A5; Thu, 19 Jan 2023 23:43:48 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30K7FTRe019108; Fri, 20 Jan 2023 07:43:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=NuXtRi+sNxhe/sIBYKY/0XKqxvWUK0NbODRPNhFZ7Jc=; b=SHk+KIBMviNwYI6Wd9HHa9/YjqyIIg8scfL78gcjFYZEHqPJjsAVKWnClZgefDoAE99O CBYwQxxImWbT43/LrZcUZrCRRJsrh0uf6Jqe84vZov2KyW5OM8NJJkoQ3ujwlbOCyark 6+SNpNocuPAHSoHVj3qAv579ojx4TQEec6p0Z4m4DN0Z55C5qWySMvzda6IR6KUMb1Ix c4T0/FoZB5BqJskB1P7XpRuM5nAsZG4BzIH8zx0HgAVJB9qsh2KfJMChPReDXGGymodc MN2Hmhrl40DD/FiYoLVLN7QvZ62GAJxbPHS2ZCZuWyxE/Jm4afoRx8HGmwSyeANlTIBz 9A== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n7pdkrhv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 07:43:39 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30JH5NIp006282; Fri, 20 Jan 2023 07:43:37 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3n3knfqpaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 07:43:37 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30K7hZJV30212390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Jan 2023 07:43:35 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38CB52005A; Fri, 20 Jan 2023 07:43:35 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC7952004B; Fri, 20 Jan 2023 07:43:34 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 20 Jan 2023 07:43:34 +0000 (GMT) Received: from jarvis-ozlabs-ibm-com.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id F264160953; Fri, 20 Jan 2023 18:43:29 +1100 (AEDT) From: Andrew Donnellan To: linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org Cc: gregkh@linuxfoundation.org, gcwilson@linux.ibm.com, linux-kernel@vger.kernel.org, nayna@linux.ibm.com, ruscur@russell.cc, zohar@linux.ibm.com, mpe@ellerman.id.au, gjoyce@linux.ibm.com, sudhakar@linux.ibm.com, bgray@linux.ibm.com, erichte@linux.ibm.com, joel@jms.id.au Subject: [PATCH v4 11/24] powerpc/secvar: Warn when PAGE_SIZE is smaller than max object size Date: Fri, 20 Jan 2023 18:42:53 +1100 Message-Id: <20230120074306.1326298-12-ajd@linux.ibm.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120074306.1326298-1-ajd@linux.ibm.com> References: <20230120074306.1326298-1-ajd@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1gBG9Pl-n7gmN5Xgvd4U_8W0XJOlMpvw X-Proofpoint-ORIG-GUID: 1gBG9Pl-n7gmN5Xgvd4U_8W0XJOlMpvw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-20_04,2023-01-19_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 adultscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301200070 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755526662630860654?= X-GMAIL-MSGID: =?utf-8?q?1755526662630860654?= Due to sysfs constraints, when writing to a variable, we can only handle writes of up to PAGE_SIZE. It's possible that the maximum object size is larger than PAGE_SIZE, in which case, print a warning on boot so that the user is aware. Signed-off-by: Andrew Donnellan Signed-off-by: Russell Currey --- v3: New patch (ajd) --- arch/powerpc/kernel/secvar-sysfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c index e1d4c70dd327..6dd9b4f6f87c 100644 --- a/arch/powerpc/kernel/secvar-sysfs.c +++ b/arch/powerpc/kernel/secvar-sysfs.c @@ -221,6 +221,7 @@ static int secvar_sysfs_load_static(void) static int secvar_sysfs_init(void) { + u64 max_size; int rc; if (!secvar_ops) { @@ -270,6 +271,14 @@ static int secvar_sysfs_init(void) goto err; } + // Due to sysfs limitations, we will only ever get a write buffer of + // up to 1 page in size. Print a warning if this is potentially going + // to cause problems, so that the user is aware. + secvar_ops->max_size(&max_size); + if (max_size > PAGE_SIZE) + pr_warn_ratelimited("PAGE_SIZE (%lu) is smaller than maximum object size (%llu), writes are limited to PAGE_SIZE\n", + PAGE_SIZE, max_size); + return 0; err: kobject_put(secvar_kobj);