From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jy09Q-00071w-3F for kexec@lists.infradead.org; Tue, 21 Jul 2020 21:50:18 +0000 Received: by mail-pl1-x641.google.com with SMTP id k4so10827889pld.12 for ; Tue, 21 Jul 2020 14:50:15 -0700 (PDT) Date: Tue, 21 Jul 2020 14:50:12 -0700 From: Kees Cook Subject: Re: [PATCH 06/13] fs/kernel_read_file: Remove redundant size argument Message-ID: <202007211449.E211351@keescook> References: <20200717174309.1164575-1-keescook@chromium.org> <20200717174309.1164575-7-keescook@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Scott Branden Cc: "Rafael J. Wysocki" , Peter Zijlstra , Stephen Boyd , Mimi Zohar , David Howells , Peter Jones , "Joel Fernandes (Google)" , linux-security-module@vger.kernel.org, Paul Moore , Mauro Carvalho Chehab , Matthew Garrett , James Morris , Matthew Wilcox , KP Singh , "Serge E. Hallyn" , selinux@vger.kernel.org, Jessica Yu , Hans de Goede , Alexander Viro , linux-integrity@vger.kernel.org, Greg Kroah-Hartman , Stephen Smalley , Randy Dunlap , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain , "Eric W. Biederman" , Dave Olsthoorn , Dmitry Kasatkin , Casey Schaufler , linux-fsdevel@vger.kernel.org, Andrew Morton On Tue, Jul 21, 2020 at 02:43:07PM -0700, Scott Branden wrote: > On 2020-07-17 10:43 a.m., Kees Cook wrote: > > In preparation for refactoring kernel_read_file*(), remove the redundant > > "size" argument which is not needed: it can be included in the return > > code, with callers adjusted. (VFS reads already cannot be larger than > > INT_MAX.) > > = > > Signed-off-by: Kees Cook > > --- > > drivers/base/firmware_loader/main.c | 8 ++++---- > > fs/kernel_read_file.c | 20 +++++++++----------- > > include/linux/kernel_read_file.h | 8 ++++---- > > kernel/kexec_file.c | 13 ++++++------- > > kernel/module.c | 7 +++---- > > security/integrity/digsig.c | 5 +++-- > > security/integrity/ima/ima_fs.c | 5 +++-- > > 7 files changed, 32 insertions(+), 34 deletions(-) > > = > > diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmwar= e_loader/main.c > > index d4a413ea48ce..ea419c7d3d34 100644 > > --- a/drivers/base/firmware_loader/main.c > > +++ b/drivers/base/firmware_loader/main.c > > @@ -462,7 +462,7 @@ fw_get_filesystem_firmware(struct device *device, s= truct fw_priv *fw_priv, > > size_t in_size, > > const void *in_buffer)) > > { > > - loff_t size; > > + size_t size; > > int i, len; > > int rc =3D -ENOENT; > > char *path; > > @@ -494,10 +494,9 @@ fw_get_filesystem_firmware(struct device *device, = struct fw_priv *fw_priv, > > fw_priv->size =3D 0; > > /* load firmware files from the mount namespace of init */ > > - rc =3D kernel_read_file_from_path_initns(path, &buffer, > > - &size, msize, > > + rc =3D kernel_read_file_from_path_initns(path, &buffer, msize, > > READING_FIRMWARE); > > - if (rc) { > > + if (rc < 0) { > > if (rc !=3D -ENOENT) > > dev_warn(device, "loading %s failed with error %d\n", > > path, rc); > > @@ -506,6 +505,7 @@ fw_get_filesystem_firmware(struct device *device, s= truct fw_priv *fw_priv, > > path); > > continue; > > } > > + size =3D rc; > Change fails to return 0.=A0 Need rc =3D 0; here. Oh nice; good catch! I'll fix this. -- = Kees Cook _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec