GRUB: Bundle of various fixes and cleanups
cover GRUB: Bundle of various fixes and cleanups
Hey,
As in subject... Please review...
Daniel
docs/grub.texi | 3 +-- grub-core/commands/efi/tpm.c | 97 ------------------------------------------------------------------------------------------------- grub-core/kern/i386/efi/init.c | 1 - grub-core/net/http.c | 4 ++-- include/grub/efi/tpm.h | 8 ++++---- include/grub/tpm.h | 3 --- util/grub-install-common.c | 4 ++-- 7 files changed, 9 insertions(+), 111 deletions(-)
Daniel Kiper (4):
docs: Fix devicetree command description
tpm: Drop unneeded code
i386/efi/init: Drop bogus include efi/tpm: Fix typo in grub_efi_tpm2_protocol struct
Martin Whitaker (1):
grub-install: Fix inverted test for NLS enabled when copying locales
Olaf Hering (1):
net/http: Return an error on HTTP error responses
PATCH 1/6 grub-install: Fix inverted test for NLS enabled when copying locales
From: Martin Whitaker <[email protected]>
Commit 3d8439da8 (grub-install: Locale depends on nls) attempted to avoid copying locale files to the target directory when NLS was disabled. However the test is inverted, and it does the opposite.
--- util/grub-install-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
util/grub-install-common.c +2 -2
@@ -598,7 +598,7 @@ copy_all (const char *srcd,grub_util_fd_closedir (d); } -#if !(defined (GRUB_UTIL ) && defined(ENABLE_NLS ) &&ENABLE_NLS ) +#if (defined (GRUB_UTIL ) && defined(ENABLE_NLS ) &&ENABLE_NLS )static const char *get_localedir (void ) {
@@ -659,7 +659,7 @@ static void grub_install_copy_nls(const char *src __attribute__ ((unused)), const char *dst __attribute__ ((unused))) { -#if !(defined (GRUB_UTIL ) && defined(ENABLE_NLS ) &&ENABLE_NLS ) +#if (defined (GRUB_UTIL ) && defined(ENABLE_NLS ) &&ENABLE_NLS )char *dst_locale; dst_locale =grub_util_path_concat (2 , dst,"locale" );
Signature · 1 line
2.11.0
Re: [PATCH 1/6] grub-install: Fix inverted test for NLS enabled when copying locales
Quoted 9 lines · Daniel Kiper
From: Martin Whitaker <[email protected]>
Commit
3d8439da8(grub-install: Locale depends on nls) attempted to avoid copying locale files to the target directory when NLS was disabled. However the test is inverted, and it does the opposite.Signed-off-by Martin Whitaker <[email protected]>Signed-off-by Daniel Kiper <[email protected]>---
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
PATCH 2/6 net/http: Return an error on HTTP error responses
In reply to Daniel KiperFrom: Olaf Hering <[email protected]>
A http transfer will hang if an error is returned. The error branch returns the value GRUB_ERR_NONE which is not expected by the caller.
--- grub-core/net/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
grub-core/net/http.c +2 -2
@@ -118,14 +118,14 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)case 404 : data->err =GRUB_ERR_FILE_NOT_FOUND ; data->errmsg =grub_xasprintf (_ ("file `%s' not found" ), data->filename); -return GRUB_ERR_NONE ; +return GRUB_ERR_FILE_NOT_FOUND ;default : data->err =GRUB_ERR_NET_UNKNOWN_ERROR ;/* TRANSLATORS: GRUB HTTP code is pretty young. So even perfectly valid answers like 403 will trigger this very generic message. */ data->errmsg =grub_xasprintf (_ ("unsupported HTTP error %d: %s" ), code, ptr); -return GRUB_ERR_NONE ; +return GRUB_ERR_FILE_READ_ERROR ; } data->first_line_recv =1 ;return GRUB_ERR_NONE ;
Signature · 1 line
2.11.0
Re: [PATCH 2/6] net/http: Return an error on HTTP error responses
Quoted 23 lines · Daniel Kiper
From: Olaf Hering <[email protected]>
A http transfer will hang if an error is returned. The error branch returns the value
GRUB_ERR_NONEwhich is not expected by the caller.Signed-off-by Olaf Hering <[email protected]>Signed-off-by Daniel Kiper <[email protected]>--- grub-core/net/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)grub-core/net/http.c +1
-1@@ -118,14 +118,14 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)case 404 : data->err =GRUB_ERR_FILE_NOT_FOUND ; data->errmsg =grub_xasprintf (_ ("file `%s' not found" ), data->filename); -return GRUB_ERR_NONE ; +return GRUB_ERR_FILE_NOT_FOUND ;default :
grub-core/net/http.c parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) · line 131
Quoted 10 lines
grub-core/net/http.c +1
-1data->err =GRUB_ERR_NET_UNKNOWN_ERROR ;/* TRANSLATORS: GRUB HTTP code is pretty young. So even perfectly valid answers like 403 will trigger this very generic message. */ data->errmsg =grub_xasprintf (_ ("unsupported HTTP error %d: %s" ), code, ptr); -return GRUB_ERR_NONE ; +return GRUB_ERR_FILE_READ_ERROR ; } data->first_line_recv =1 ;return GRUB_ERR_NONE ;
There is one case that is still returning GRUB_ERR_NONE even when is taken as an error and that is when the HTTP version != 1.1. Maybe fixing that as well?
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
Re: [PATCH 2/6] net/http: Return an error on HTTP error responses
Quoted 29 lines · Javier Martinez Canillas
Quoted 28 lines · Daniel Kiper
From: Olaf Hering <[email protected]>
A http transfer will hang if an error is returned. The error branch returns the value
GRUB_ERR_NONEwhich is not expected by the caller.Signed-off-by Olaf Hering <[email protected]>Signed-off-by Daniel Kiper <[email protected]>--- grub-core/net/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)grub-core/net/http.c +1
-2@@ -118,14 +118,14 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)case 404 : data->err =GRUB_ERR_FILE_NOT_FOUND ; data->errmsg =grub_xasprintf (_ ("file `%s' not found" ), data->filename); -return GRUB_ERR_NONE ; +return GRUB_ERR_FILE_NOT_FOUND ;default : data->err =GRUB_ERR_NET_UNKNOWN_ERROR ;/* TRANSLATORS: GRUB HTTP code is pretty young. So even perfectly valid answers like 403 will trigger this very generic message. */ data->errmsg =grub_xasprintf (_ ("unsupported HTTP error %d: %s" ), code, ptr); -return GRUB_ERR_NONE ;
Quoted 8 lines
grub-core/net/http.c parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) · line 131
Quoted 5 lines
grub-core/net/http.c +1
-0+return GRUB_ERR_FILE_READ_ERROR ; } data->first_line_recv =1 ;return GRUB_ERR_NONE ;There is one case that is still returning
GRUB_ERR_NONEeven when is taken as an error and that is when the HTTP version != 1.1. Maybe fixing that as well?
OK, I will take a look at it.
Daniel
PATCH 3/6 docs: Fix devicetree command description
In reply to Daniel KiperSpecifically fix the subsection and drop bogus reference to the GNU/Linux.
--- docs/grub.texi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
docs/grub.texi +1 -2
@@ -4295,13 +4295,12 @@ hour, minute, and second unchanged. @node devicetree -@subsection linux +@subsection devicetree @deffn Command devicetree file Load a device tree blob (.dtb) from a filesystem, for later use by a Linux kernel. Does not perform merging with any device tree supplied by firmware, but rather replaces it completely. -@ref{GNU/Linux}. @end deffn @node distrust
Signature · 1 line
2.11.0
Re: [PATCH 3/6] docs: Fix devicetree command description
Quoted 5 lines · Daniel Kiper
Specifically fix the subsection and drop bogus reference to the GNU/Linux.
Reported-by Patrick Higgins <[email protected]>Signed-off-by Daniel Kiper <[email protected]>---
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
PATCH 4/6 tpm: Drop unneeded code
In reply to Daniel KiperDrop unused grub_tpm*_execute() and declaration of nonexistent grub_tpm_init().
--- grub-core/commands/efi/tpm.c | 97 -------------------------------------------- include/grub/tpm.h | 3 -- 2 files changed, 100 deletions(-)
grub-core/commands/efi/tpm.c +0 -97
@@ -120,103 +120,6 @@ grub_tpm_handle_find (grub_efi_handle_t *tpm_handle, }static grub_err_t -grub_tpm1_execute (grub_efi_handle_t tpm_handle, -PassThroughToTPM_InputParamBlock *inbuf, -PassThroughToTPM_OutputParamBlock *outbuf) -{ -grub_efi_status_t status; -grub_efi_tpm_protocol_t *tpm; -grub_uint32_t inhdrsize =sizeof (*inbuf) -sizeof (inbuf->TPMOperandIn); -grub_uint32_t outhdrsize = -sizeof (*outbuf) -sizeof (outbuf->TPMOperandOut); - - tpm =grub_efi_open_protocol (tpm_handle, &tpm_guid, -GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - -if (!grub_tpm1_present (tpm)) -return 0 ; - -/* UEFI TPM protocol takes the raw operand block, no param block header. */ - status =efi_call_5 (tpm->pass_through_to_tpm, tpm, - inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, - outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); - -switch (status) - { -case GRUB_EFI_SUCCESS : -return 0 ; -case GRUB_EFI_DEVICE_ERROR : -return grub_error (GRUB_ERR_IO ,N_ ("Command failed" )); -case GRUB_EFI_INVALID_PARAMETER : -return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("Invalid parameter" )); -case GRUB_EFI_BUFFER_TOO_SMALL : -return grub_error (GRUB_ERR_BAD_ARGUMENT , -N_ ("Output buffer too small" )); -case GRUB_EFI_NOT_FOUND : -return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,N_ ("TPM unavailable" )); -default : -return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,N_ ("Unknown TPM error" )); - } -} - -static grub_err_t -grub_tpm2_execute (grub_efi_handle_t tpm_handle, -PassThroughToTPM_InputParamBlock *inbuf, -PassThroughToTPM_OutputParamBlock *outbuf) -{ -grub_efi_status_t status; -grub_efi_tpm2_protocol_t *tpm; -grub_uint32_t inhdrsize =sizeof (*inbuf) -sizeof (inbuf->TPMOperandIn); -grub_uint32_t outhdrsize = -sizeof (*outbuf) -sizeof (outbuf->TPMOperandOut); - - tpm =grub_efi_open_protocol (tpm_handle, &tpm2_guid, -GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - -if (!grub_tpm2_present (tpm)) -return 0 ; - -/* UEFI TPM protocol takes the raw operand block, no param block header. */ - status =efi_call_5 (tpm->submit_command, tpm, - inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, - outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); - -switch (status) - { -case GRUB_EFI_SUCCESS : -return 0 ; -case GRUB_EFI_DEVICE_ERROR : -return grub_error (GRUB_ERR_IO ,N_ ("Command failed" )); -case GRUB_EFI_INVALID_PARAMETER : -return grub_error (GRUB_ERR_BAD_ARGUMENT ,N_ ("Invalid parameter" )); -case GRUB_EFI_BUFFER_TOO_SMALL : -return grub_error (GRUB_ERR_BAD_ARGUMENT , -N_ ("Output buffer too small" )); -case GRUB_EFI_NOT_FOUND : -return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,N_ ("TPM unavailable" )); -default : -return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,N_ ("Unknown TPM error" )); - } -} - -grub_err_t -grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf, -PassThroughToTPM_OutputParamBlock *outbuf) -{ -grub_efi_handle_t tpm_handle; -grub_uint8_t protocol_version; - -/* Absence of a TPM isn't a failure. */ -if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) -return 0 ; - -if (protocol_version ==1 ) -return grub_tpm1_execute (tpm_handle, inbuf, outbuf); -else -return grub_tpm2_execute (tpm_handle, inbuf, outbuf); -} - -static grub_err_t grub_tpm1_log_event (grub_efi_handle_t tpm_handle,unsigned char *buf,grub_size_t size,grub_uint8_t pcr,const char *description)
include/grub/tpm.h +0 -3
@@ -74,7 +74,4 @@ typedef structgrub_err_t grub_tpm_measure (unsigned char *buf,grub_size_t size,grub_uint8_t pcr,const char *description); -grub_err_t grub_tpm_init (void ); -grub_err_t grub_tpm_execute (PassThroughToTPM_InputParamBlock *inbuf, -PassThroughToTPM_OutputParamBlock *outbuf);#endif
Signature · 1 line
2.11.0
Re: [PATCH 4/6] tpm: Drop unneeded code
Quoted 4 lines · Daniel Kiper
Drop unused grub_tpm*_execute() and declaration of nonexistent
grub_tpm_init().Signed-off-by Daniel Kiper <[email protected]>---
[snip]
Quoted 12 lines
grub-core/commands/efi/tpm.c +0
-12-static grub_err_t -grub_tpm2_execute (grub_efi_handle_t tpm_handle, -PassThroughToTPM_InputParamBlock *inbuf, -PassThroughToTPM_OutputParamBlock *outbuf) -{ -grub_efi_status_t status; -grub_efi_tpm2_protocol_t *tpm; -grub_uint32_t inhdrsize =sizeof (*inbuf) -sizeof (inbuf->TPMOperandIn); -grub_uint32_t outhdrsize = -sizeof (*outbuf) -sizeof (outbuf->TPMOperandOut); - - tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid,
grub-core/commands/efi/tpm.c grub_tpm_handle_find (grub_efi_handle_t *tpm_handle, · line 183
Quoted 10 lines
grub-core/commands/efi/tpm.c +0
-10- GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); - -if (!grub_tpm2_present (tpm)) -return 0 ; - -/* UEFI TPM protocol takes the raw operand block, no param block header. */ - status =efi_call_5 (tpm->submit_command, tpm, - inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, - outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); -
I think this would be useful if we ever add support for sending TPM commands. But I agree that should be removed since is unused and can always be brought back from the git history if needed.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
Re: [PATCH 4/6] tpm: Drop unneeded code
Quoted 26 lines · Javier Martinez Canillas
Quoted 4 lines · Daniel Kiper
Drop unused grub_tpm*_execute() and declaration of nonexistent
grub_tpm_init().Signed-off-by Daniel Kiper <[email protected]>---
[snip]
Quoted 18 lines
grub-core/commands/efi/tpm.c +0
-18-static grub_err_t -grub_tpm2_execute (grub_efi_handle_t tpm_handle, -PassThroughToTPM_InputParamBlock *inbuf, -PassThroughToTPM_OutputParamBlock *outbuf) -{ -grub_efi_status_t status; -grub_efi_tpm2_protocol_t *tpm; -grub_uint32_t inhdrsize =sizeof (*inbuf) -sizeof (inbuf->TPMOperandIn); -grub_uint32_t outhdrsize = -sizeof (*outbuf) -sizeof (outbuf->TPMOperandOut); - - tpm =grub_efi_open_protocol (tpm_handle, &tpm2_guid, -GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - -if (!grub_tpm2_present (tpm)) -return 0 ; - -/* UEFI TPM protocol takes the raw operand block, no param block header. */
Quoted 8 lines
grub-core/commands/efi/tpm.c grub_tpm_handle_find (grub_efi_handle_t *tpm_handle, · line 183
Quoted 4 lines
grub-core/commands/efi/tpm.c +0
-4- status =efi_call_5 (tpm->submit_command, tpm, - inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, - outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); -I think this would be useful if we ever add support for sending TPM commands. But I agree that should be removed since is unused and can always be brought back from the git history if needed.
Yeah, I was thinking about mentioning something about this but later forgot about it. I will add following clarification to the commit message before pushing the patch:
If somebody needs the functionality implemented in the dropped code then he/she can readd it later. Now it only increases the GRUB code/image size.
Quoted 1 line
Reviewed-by Javier Martinez Canillas <[email protected]>
Thanks a lot for review!
Daniel
PATCH 5/6 i386/efi/init: Drop bogus include
In reply to Daniel Kiper--- grub-core/kern/i386/efi/init.c | 1 - 1 file changed, 1 deletion(-)
grub-core/kern/i386/efi/init.c +0 -1
@@ -27,7 +27,6 @@#include <grub/efi/efi.h> #include <grub/i386/tsc.h> #include <grub/loader.h> -#include <grub/tpm.h> void grub_machine_init (void )
Signature · 1 line
2.11.0
Re: [PATCH 5/6] i386/efi/init: Drop bogus include
Quoted 11 lines · Daniel Kiper
Signed-off-by Daniel Kiper <[email protected]>--- grub-core/kern/i386/efi/init.c | 1 - 1 file changed, 1 deletion(-)grub-core/kern/i386/efi/init.c +0
-0
grub-core/kern/i386/efi/init.c line 32
Quoted 7 lines
grub-core/kern/i386/efi/init.c +0
-1@@ -27,7 +27,6 @@#include <grub/efi/efi.h> #include <grub/i386/tsc.h> #include <grub/loader.h> -#include <grub/tpm.h> void grub_machine_init (void )
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
PATCH 6/6 efi/tpm: Fix typo in grub_efi_tpm2_protocol struct
In reply to Daniel KiperRename get_active_pcr_blanks() to get_active_pcr_banks().
--- include/grub/efi/tpm.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/grub/efi/tpm.h +4 -4
@@ -176,10 +176,10 @@ struct grub_efi_tpm2_protocol OutputParameterBlockSize, grub_efi_uint8_t * OutputParameterBlock); -grub_efi_status_t (*get_active_pcr_blanks) (struct grub_efi_tpm2_protocol * - this, -grub_efi_uint32_t * - ActivePcrBanks); +grub_efi_status_t (*get_active_pcr_banks) (struct grub_efi_tpm2_protocol * + this, +grub_efi_uint32_t * + ActivePcrBanks);grub_efi_status_t (*set_active_pcr_banks) (struct grub_efi_tpm2_protocol * this, grub_efi_uint32_t
Signature · 1 line
2.11.0
Re: [PATCH 6/6] efi/tpm: Fix typo in grub_efi_tpm2_protocol struct
Quoted 17 lines · Daniel Kiper
Rename
get_active_pcr_blanks()toget_active_pcr_banks().Signed-off-by Daniel Kiper <[email protected]>--- include/grub/efi/tpm.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)include/grub/efi/tpm.h +0
-1@@ -176,10 +176,10 @@ struct grub_efi_tpm2_protocol OutputParameterBlockSize, grub_efi_uint8_t * OutputParameterBlock); - grub_efi_status_t (*get_active_pcr_blanks) (struct grub_efi_tpm2_protocol *
include/grub/efi/tpm.h struct grub_efi_tpm2_protocol · line 185
Quoted 10 lines
include/grub/efi/tpm.h +4
-3- this, - grub_efi_uint32_t * - ActivePcrBanks); +grub_efi_status_t (*get_active_pcr_banks) (struct grub_efi_tpm2_protocol * + this, +grub_efi_uint32_t * + ActivePcrBanks);grub_efi_status_t (*set_active_pcr_banks) (struct grub_efi_tpm2_protocol * this, grub_efi_uint32_t
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat