[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202007211449.E211351@keescook>
Date: Tue, 21 Jul 2020 14:50:12 -0700
From: Kees Cook <keescook@...omium.org>
To: Scott Branden <scott.branden@...adcom.com>
Cc: Mimi Zohar <zohar@...ux.ibm.com>,
Matthew Wilcox <willy@...radead.org>,
James Morris <jmorris@...ei.org>,
Luis Chamberlain <mcgrof@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Jessica Yu <jeyu@...nel.org>,
Dmitry Kasatkin <dmitry.kasatkin@...il.com>,
"Serge E. Hallyn" <serge@...lyn.com>,
Casey Schaufler <casey@...aufler-ca.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Peter Zijlstra <peterz@...radead.org>,
Matthew Garrett <matthewgarrett@...gle.com>,
David Howells <dhowells@...hat.com>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
"Joel Fernandes (Google)" <joel@...lfernandes.org>,
KP Singh <kpsingh@...gle.com>, Dave Olsthoorn <dave@...aar.me>,
Hans de Goede <hdegoede@...hat.com>,
Peter Jones <pjones@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Stephen Boyd <stephen.boyd@...aro.org>,
Paul Moore <paul@...l-moore.com>,
Stephen Smalley <stephen.smalley.work@...il.com>,
linux-security-module@...r.kernel.org,
linux-integrity@...r.kernel.org, selinux@...r.kernel.org,
linux-fsdevel@...r.kernel.org, kexec@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 06/13] fs/kernel_read_file: Remove redundant size argument
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 <keescook@...omium.org>
> > ---
> > 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/firmware_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, struct fw_priv *fw_priv,
> > size_t in_size,
> > const void *in_buffer))
> > {
> > - loff_t size;
> > + size_t size;
> > int i, len;
> > int rc = -ENOENT;
> > char *path;
> > @@ -494,10 +494,9 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv,
> > fw_priv->size = 0;
> > /* load firmware files from the mount namespace of init */
> > - rc = kernel_read_file_from_path_initns(path, &buffer,
> > - &size, msize,
> > + rc = kernel_read_file_from_path_initns(path, &buffer, msize,
> > READING_FIRMWARE);
> > - if (rc) {
> > + if (rc < 0) {
> > if (rc != -ENOENT)
> > dev_warn(device, "loading %s failed with error %d\n",
> > path, rc);
> > @@ -506,6 +505,7 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv,
> > path);
> > continue;
> > }
> > + size = rc;
> Change fails to return 0. Need rc = 0; here.
Oh nice; good catch! I'll fix this.
--
Kees Cook
Powered by blists - more mailing lists