grub/head build with pre-release GCC10 ; fail @ "grub-core/disk/mdraid1x_linux.c:181:15: error: ..."

2020-03-23 Thread PGNet Dev
 building curren head,

git clone https://git.savannah.gnu.org/git/grub.git
cd grub
git describe
grub-2.04-71-g552c9fd08

with soon(ish)-to-be-release GCC10

gcc --version
gcc (SUSE Linux) 10.0.1 20200320 (experimental) [revision 
7d4549b2cd209eb621453ce13be7ffd84ffa720a]

config's OK

unset CC CPP
./bootstrap
./autogen.sh
./configure

build fails,

make V=1
...
gcc -DHAVE_CONFIG_H -I.  -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 
-I./include -DGRUB_FILE=\"grub-core/disk/mdraid1x_linux.c\" -I. -I. -I. -I. 
-I./include -I./include -I./grub-core/lib/libgcrypt-grub/src/  
-I./grub-core/lib/minilzo -I./grub-core/lib/xzembed -I./grub-core/lib/zstd 
-DMINILZO_HAVE_CONFIG_H -O3 -Wall -fstack-protector-strong -funwind-tables 
-fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches 
-march=native -mtune=native -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -Wall -W 
-Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment 
-Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal 
-Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit 
-Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces 
-Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type 
-Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas 
-Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  
-Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes 
-Wcast-align  -Wextra -Wattributes -Wendif-labels -Winit-self 
-Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull 
-Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros 
-Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs 
-Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror  -fno-builtin 
-Wno-undef -O3 -Wall -fstack-protector-strong -funwind-tables 
-fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches 
-march=native -mtune=native -MT grub-core/disk/libgrubmods_a-mdraid1x_linux.o 
-MD -MP -MF grub-core/disk/.deps-util/libgrubmods_a-mdraid1x_linux.Tpo -c -o 
grub-core/disk/libgrubmods_a-mdraid1x_linux.o `test -f 
'grub-core/disk/mdraid1x_linux.c' || echo './'`grub-core/disk/mdraid1x_linux.c
grub-core/disk/mdraid1x_linux.c: In function ‘grub_mdraid_detect’:
grub-core/disk/mdraid1x_linux.c:181:15: error: array subscript 
 is outside array bounds of ‘grub_uint16_t[0]’ {aka ‘short unsigned 
int[0]’} [-Werror=array-bounds]
  181 |  (char *) _roles[grub_le_to_cpu32 (sb.dev_number)]
  |   ^~~
grub-core/disk/mdraid1x_linux.c:98:17: note: while referencing 
‘dev_roles’
   98 |   grub_uint16_t dev_roles[0]; /* Role in array, or 0x for a 
spare, or 0xfffe for faulty.  */
  | ^
grub-core/disk/mdraid1x_linux.c:127:33: note: defined here ‘sb’
  127 |   struct grub_raid_super_1x sb;
  | ^~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:7059: 
grub-core/disk/libgrubmods_a-mdraid1x_linux.o] Error 1
make[2]: Leaving directory '/usr/local/src/grub'
make[1]: *** [Makefile:11920: all-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/grub'
make: *** [Makefile:3772: all] Error 2


known/expected issue? bug-worthy?  or still too early for GCC10 issues?



___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] grub.d: Use linuxefi and initrdefi commands if platform is efi

2020-03-23 Thread Javier Martinez Canillas
On 3/23/20 7:31 PM, Julian Andres Klode wrote:
> On Mon, Mar 23, 2020 at 07:26:59PM +0100, Javier Martinez Canillas wrote:
>> On 3/23/20 12:53 PM, Tianjia Zhang wrote:
>>> When the platform is EFI platform, use 'linuxefi' and 'initrdefi'
>>> commands instead of 'linux' and 'initrd'.
>>>
>>
>> These two commands are added by most distros as a part of their Secure Boot
>> patch-set, but aren't present in upstream GRUB so this patch doesn't apply.
> 
> I was about to say that at least in Ubuntu, linux automatically loads
> via EFI and then falls back to native grub kernel loading if that
> does not work (and it's not on secure boot). Which IMO is the right
> thing to do.
> 

In Fedora also always 'linux' and 'initrd' is used nowadays. There's no need to
have separate linux16, linuxefi and linux commands although these are supported
for backward compatibility.

Best regards,
-- 
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] grub.d: Use linuxefi and initrdefi commands if platform is efi

2020-03-23 Thread Julian Andres Klode
On Mon, Mar 23, 2020 at 07:26:59PM +0100, Javier Martinez Canillas wrote:
> On 3/23/20 12:53 PM, Tianjia Zhang wrote:
> > When the platform is EFI platform, use 'linuxefi' and 'initrdefi'
> > commands instead of 'linux' and 'initrd'.
> >
> 
> These two commands are added by most distros as a part of their Secure Boot
> patch-set, but aren't present in upstream GRUB so this patch doesn't apply.

I was about to say that at least in Ubuntu, linux automatically loads
via EFI and then falls back to native grub kernel loading if that
does not work (and it's not on secure boot). Which IMO is the right
thing to do.

Also the other point is that this actually breaks stuff if you install
both MBR and EFI bootloaders. Which is something you actually should
be doing because you still want to be able to boot even if user switches
their BIOS from UEFI to BIOS or vice versa or other shenanigans.

-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer  i speak de, en

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] grub.d: Use linuxefi and initrdefi commands if platform is efi

2020-03-23 Thread Javier Martinez Canillas
On 3/23/20 12:53 PM, Tianjia Zhang wrote:
> When the platform is EFI platform, use 'linuxefi' and 'initrdefi'
> commands instead of 'linux' and 'initrd'.
>

These two commands are added by most distros as a part of their Secure Boot
patch-set, but aren't present in upstream GRUB so this patch doesn't apply.
 
Best regards,
-- 
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] efi/tpm: Fix memory leak in grub_tpm1/2_log_event()

2020-03-23 Thread Javier Martinez Canillas
Hello Tianjia,

On 3/23/20 12:52 PM, Tianjia Zhang wrote:
> The memory requested for the event is not released here,
> causing memory leaks. This patch fixes this problem.
> 
> Signed-off-by: Jia Zhang 
> Signed-off-by: Tianjia Zhang 
> ---

Reviewed-by: Javier Martinez Canillas 

Best regards,
-- 
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] grub.d: Use linuxefi and initrdefi commands if platform is efi

2020-03-23 Thread Paul Menzel

Dear Tianjia,


Am 23.03.20 um 12:53 schrieb Tianjia Zhang:

When the platform is EFI platform, use 'linuxefi' and 'initrdefi'
commands instead of 'linux' and 'initrd'.

Signed-off-by: Jia Zhang 
Signed-off-by: Tianjia Zhang 
---
  util/grub.d/10_linux.in | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index e8b01c0d0..8c5c3dab7 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -138,10 +138,17 @@ linux_entry ()
  fi
  printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
fi
+  if [ "@GRUB_PLATFORM@" != "efi" ] ; then
+linux_cmd="linux"
+initrd_cmd="initrd"
+  else
+linux_cmd="linuxefi"
+initrd_cmd="initrdefi"
+  fi
message="$(gettext_printf "Loading Linux %s ..." ${version})"
sed "s/^/$submenu_indentation/" << EOF
echo'$(echo "$message" | grub_quote)'
-   linux   ${rel_dirname}/${basename} 
root=${linux_root_device_thisversion} ro ${args}
+   ${linux_cmd}${rel_dirname}/${basename} 
root=${linux_root_device_thisversion} ro ${args}
  EOF
if test -n "${initrd}" ; then
  # TRANSLATORS: ramdisk isn't identifier. Should be translated.
@@ -152,7 +159,7 @@ EOF
  done
  sed "s/^/$submenu_indentation/" << EOF
echo'$(echo "$message" | grub_quote)'
-   initrd  $(echo $initrd_path)
+   ${initrd_cmd}   $(echo $initrd_path)
  EOF
fi
sed "s/^/$submenu_indentation/" << EOF


What problem does your change address?


Kind regards,

Paul

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] grub.d: Use linuxefi and initrdefi commands if platform is efi

2020-03-23 Thread Tianjia Zhang
When the platform is EFI platform, use 'linuxefi' and 'initrdefi'
commands instead of 'linux' and 'initrd'.

Signed-off-by: Jia Zhang 
Signed-off-by: Tianjia Zhang 
---
 util/grub.d/10_linux.in | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index e8b01c0d0..8c5c3dab7 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -138,10 +138,17 @@ linux_entry ()
 fi
 printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
   fi
+  if [ "@GRUB_PLATFORM@" != "efi" ] ; then
+linux_cmd="linux"
+initrd_cmd="initrd"
+  else
+linux_cmd="linuxefi"
+initrd_cmd="initrdefi"
+  fi
   message="$(gettext_printf "Loading Linux %s ..." ${version})"
   sed "s/^/$submenu_indentation/" << EOF
echo'$(echo "$message" | grub_quote)'
-   linux   ${rel_dirname}/${basename} 
root=${linux_root_device_thisversion} ro ${args}
+   ${linux_cmd}${rel_dirname}/${basename} 
root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
 # TRANSLATORS: ramdisk isn't identifier. Should be translated.
@@ -152,7 +159,7 @@ EOF
 done
 sed "s/^/$submenu_indentation/" << EOF
echo'$(echo "$message" | grub_quote)'
-   initrd  $(echo $initrd_path)
+   ${initrd_cmd}   $(echo $initrd_path)
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF
-- 
2.17.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] efi/tpm: Fix memory leak in grub_tpm1/2_log_event()

2020-03-23 Thread Tianjia Zhang
The memory requested for the event is not released here,
causing memory leaks. This patch fixes this problem.

Signed-off-by: Jia Zhang 
Signed-off-by: Tianjia Zhang 
---
 grub-core/commands/efi/tpm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
index 32909c192..6a6cd0d83 100644
--- a/grub-core/commands/efi/tpm.c
+++ b/grub-core/commands/efi/tpm.c
@@ -247,6 +247,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned 
char *buf,
   algorithm = TCG_ALG_SHA;
   status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, 
(grub_uint64_t) size,
   algorithm, event, , );
+  grub_free (event);
 
   switch (status)
 {
@@ -297,6 +298,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned 
char *buf,
 
   status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
   (grub_uint64_t) size, event);
+  grub_free (event);
 
   switch (status)
 {
-- 
2.17.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel