Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2281929rwb; Fri, 20 Jan 2023 00:22:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXsUgSGuO2FszQxkk+oHlwGAwNhbVFu7u5J77doKIOKijm4ISi3LxI67yWE45ZT/771AqB3V X-Received: by 2002:a62:838d:0:b0:587:102b:edb6 with SMTP id h135-20020a62838d000000b00587102bedb6mr16265157pfe.17.1674202926408; Fri, 20 Jan 2023 00:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674202926; cv=none; d=google.com; s=arc-20160816; b=p2XGsx36HuIqzjonL2KE7/caaTNg6Vrp2KqgYOpuDjBGuM38V39FMnr0ZPuwgkY54n ElGuRWQKUt6zigjZx6/lzFVDu89qJYpU8/R3Sra8S16yalFqW+tptLDY4TK9ZHVNOoM5 YLWfiZYQNBRuT0+S1dh3MhFC/wspnGahdp/X4AX5UuFvRDjWwZ+/lfsU5UNAMNWa+pnl o6m+13/nqiCqD4yfFBwHRLRZw3QqQvUvujX4YXQp+xFrWiRfvwGOUHzdmnsQ1IEz5T0Z o/GLN7KrzgcnBCusAWmqQOzjfDSlKwrKvCba5E2Dg6z0iIHguP1GgJNTl2TIcFAz1XW7 ZMIA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020aa78205000000b0058dbe627fc2si11838516pfi.336.2023.01.20.00.22.00; Fri, 20 Jan 2023 00:22:06 -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 + 48 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 Content-Transfer-Encoding: 8bit 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 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); -- 2.39.0