Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935717Ab3IEKNF (ORCPT ); Thu, 5 Sep 2013 06:13:05 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:47911 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935552Ab3IEKNA (ORCPT ); Thu, 5 Sep 2013 06:13:00 -0400 Subject: Re: [PATCH 11/18] Hibernate: introduced RSA key-pair to verify signature of snapshot From: joeyli To: Matt Fleming Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, linux-pm@vger.kernel.org, linux-crypto@vger.kernel.org, opensuse-kernel@opensuse.org, David Howells , "Rafael J. Wysocki" , Matthew Garrett , Len Brown , Pavel Machek , Josh Boyer , Vojtech Pavlik , Matt Fleming , James Bottomley , Greg KH , JKosina@suse.com, Rusty Russell , Herbert Xu , "David S. Miller" , "H. Peter Anvin" , Michal Marek , Gary Lin , Vivek Goyal , Takashi Iwai In-Reply-To: <20130905085348.GJ28598@console-pimps.org> References: <1377169317-5959-1-git-send-email-jlee@suse.com> <1377169317-5959-12-git-send-email-jlee@suse.com> <20130905085348.GJ28598@console-pimps.org> Content-Type: text/plain; charset="UTF-8" Date: Thu, 05 Sep 2013 18:13:36 +0800 Message-ID: <1378376016.6193.71.camel@linux-s257.site> Mime-Version: 1.0 X-Mailer: Evolution 2.28.2 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2154 Lines: 83 Hi Matt, First, thanks for your review! 於 四,2013-09-05 於 09:53 +0100,Matt Fleming 提到: > On Thu, 22 Aug, at 07:01:50PM, Lee, Chun-Yi wrote: > > +static int efi_status_to_err(efi_status_t status) > > +{ > > + int err; > > + > > + switch (status) { > > + case EFI_INVALID_PARAMETER: > > + err = -EINVAL; > > + break; > > + case EFI_OUT_OF_RESOURCES: > > + err = -ENOSPC; > > + break; > > + case EFI_DEVICE_ERROR: > > + err = -EIO; > > + break; > > + case EFI_WRITE_PROTECTED: > > + err = -EROFS; > > + break; > > + case EFI_SECURITY_VIOLATION: > > + err = -EACCES; > > + break; > > + case EFI_NOT_FOUND: > > + err = -ENODATA; > > + break; > > + default: > > + err = -EINVAL; > > + } > > + > > + return err; > > +} > > Please don't reimplement this. Instead make the existing function > global. > OK, I will make the function to global. > [...] > > > +static void *load_wake_key_data(unsigned long *datasize) > > +{ > > + u32 attr; > > + void *wkey_data; > > + efi_status_t status; > > + > > + if (!efi_enabled(EFI_RUNTIME_SERVICES)) > > + return ERR_PTR(-EPERM); > > + > > + /* obtain the size */ > > + *datasize = 0; > > + status = efi.get_variable(EFI_S4_WAKE_KEY_NAME, &EFI_HIBERNATE_GUID, > > + NULL, datasize, NULL); > > + if (status != EFI_BUFFER_TOO_SMALL) { > > + wkey_data = ERR_PTR(efi_status_to_err(status)); > > + pr_err("PM: Couldn't get wake key data size: 0x%lx\n", status); > > + goto error; > > + } > > Is it safe to completely bypass the efivars interface and access > efi.get_variable() directly? I wouldn't have thought so, unless you can > guarantee that the kernel isn't going to access any of the EFI runtime > services while you execute this function. > This S4WakeKey is a VOLATILE variable that could not modify by SetVariable() at runtime. So, it's read only even through efivars. Does it what your concern? Thanks a lot! Joey Lee -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/