From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwVib-0007G1-Ce for kexec@lists.infradead.org; Fri, 17 Jul 2020 19:08:26 +0000 Received: by mail-wm1-x344.google.com with SMTP id a6so7738662wmm.0 for ; Fri, 17 Jul 2020 12:08:25 -0700 (PDT) Subject: Re: [PATCH 01/13] firmware_loader: EFI firmware loader must handle pre-allocated buffer References: <20200717174309.1164575-1-keescook@chromium.org> <20200717174309.1164575-2-keescook@chromium.org> From: Scott Branden Message-ID: Date: Fri, 17 Jul 2020 12:08:14 -0700 MIME-Version: 1.0 In-Reply-To: <20200717174309.1164575-2-keescook@chromium.org> Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Kees Cook 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, stable@vger.kernel.org, Luis Chamberlain , "Eric W. Biederman" , Dave Olsthoorn , Dmitry Kasatkin , Casey Schaufler , linux-fsdevel@vger.kernel.org, Andrew Morton On 2020-07-17 10:42 a.m., Kees Cook wrote: > The EFI platform firmware fallback would clobber any pre-allocated > buffers. Instead, correctly refuse to reallocate when too small (as > already done in the sysfs fallback), or perform allocation normally > when needed. > > Fixes: e4c2c0ff00ec ("firmware: Add new platform fallback mechanism and firm ware_request_platform()") > Cc: stable@vger.kernel.org > Signed-off-by: Kees Cook Acked-by: Scott Branden > --- > To aid in backporting, this change is made before moving > kernel_read_file() to separate header/source files. > --- > drivers/base/firmware_loader/fallback_platform.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/firmware_loader/fallback_platform.c b/drivers/base/firmware_loader/fallback_platform.c > index cdd2c9a9f38a..685edb7dd05a 100644 > --- a/drivers/base/firmware_loader/fallback_platform.c > +++ b/drivers/base/firmware_loader/fallback_platform.c > @@ -25,7 +25,10 @@ int firmware_fallback_platform(struct fw_priv *fw_priv, u32 opt_flags) > if (rc) > return rc; /* rc == -ENOENT when the fw was not found */ > > - fw_priv->data = vmalloc(size); > + if (fw_priv->data && size > fw_priv->allocated_size) > + return -ENOMEM; > + if (!fw_priv->data) > + fw_priv->data = vmalloc(size); > if (!fw_priv->data) > return -ENOMEM; > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec