[PATCH] net: fix null pointer dereference when parsing ICMP6_ROUTER_ADVERTISE messages

2022-02-17 Thread Qiumiao Zhang via Grub-devel
During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful 
automatic
configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message 
multicast
from the server, it will cause the problem of dereference null pointer and cause
the grub2 program to crash.

Fixes bug: https://savannah.gnu.org/bugs/index.php?62072
---
 grub-core/net/icmp6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c
index 2cbd95d..264fc4a 100644
--- a/grub-core/net/icmp6.c
+++ b/grub-core/net/icmp6.c
@@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
 
/* May not have gotten slaac info, find a global address on this
  card.  */
-   if (route_inf == NULL)
+   if (route_inf == NULL && orig_inf != NULL)
  {
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
{
-- 
2.19.1


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


Re: [PATCH] net: fix null pointer dereference when parsing ICMP6_ROUTER_ADVERTISE messages

2022-02-17 Thread Glenn Washburn
On Thu, 17 Feb 2022 21:48:58 +0800
Qiumiao Zhang via Grub-devel  wrote:

> During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful 
> automatic
> configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message 
> multicast
> from the server, it will cause the problem of dereference null
> pointer and cause the grub2 program to crash.

This commit message could be more clear. Maybe have something like:

  During UEFI PXE boot in IPv6 network, if the DHCP server adopts
  stateful automatic configuration, then the client receives a
  ICMP6_ROUTER_ADVERTISE multicast message from the server. This may be
  received without the interfaced having a configured network address,
  so orig_inf will be null, which can lead to a null dereference when
  creating the default route.

Of course, assuming that the above is in fact correct.

> 
> Fixes bug: https://savannah.gnu.org/bugs/index.php?62072
> ---
>  grub-core/net/icmp6.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c
> index 2cbd95d..264fc4a 100644
> --- a/grub-core/net/icmp6.c
> +++ b/grub-core/net/icmp6.c
> @@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
>  
>   /* May not have gotten slaac info, find a global address on this
> card.  */
> - if (route_inf == NULL)
> + if (route_inf == NULL && orig_inf != NULL)

So if orig_inf == NULL and route_inf == NULL here, we do not set a
default route. Does this have any implications to be concerned about?

In this case, can we still find a good route interface and setup a
default route?

Glenn

> {
>   FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
>   {

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


Re: [PATCH v4 1/2] cryptodisk: add OS provided secret support

2022-02-17 Thread James Bottomley
On Mon, 2022-02-14 at 16:18 -0600, Glenn Washburn wrote:
> On Mon,  7 Feb 2022 10:29:43 -0500
> James Bottomley  wrote:
> 
> > Make use of the new OS provided secrets API so that if the new '-s'
> > option is passed in we try to extract the secret from the API
> > rather than prompting for it.
> > 
> > The primary consumer of this is AMD SEV, which has been programmed
> > to provide an injectable secret to the encrypted virtual
> > machine.  OVMF provides the secret area and passes it into the EFI
> > Configuration Tables.  The grub EFI layer pulls the secret out and
> > primes the secrets API with it.  The upshot of all of this is that
> > a SEV protected VM can do an encrypted boot with a protected boot
> > secret.
> 
> I think I prefer the key protector framework proposed in the first
> patch of Hernan Gatta's Automatic TPM Disk Unlock lock series. It
> feels like a more generic mechanism (though admittedly very similar
> to yours) because its not tied to cryptodisk.

It's not really an either/or, though is it?  It looks to me like one
can trivially evolve into the other.

>  I'm not sure where we'd want to use the secrets/protectors framework
> outside of cryptodisk, but it seems like it could be useful. The
> advantage of this patch is that it allows for the clearing of key
> data from memory.

So if you evolve one into the other the put API would naturally remain
even if the tpm2 protector didn't want it.

> I don't think we should have both a secrets and a key protectors
> framework, as its seems they are aiming to accomplish basically the
> same thing.

Well, I don't think we would either.  Looking at the protectors API, it
would become an incremental patch to this.  Where I come from, this is
how we do API development: you merge an implementation and an API
that's as minimal as possible.  You try to make sure the API can be
extended if necessary, but you don't extend it yourself until another
implementation comes along that needs the extension.  This way you
don't need to bikeshed about future implementations because the perfect
is the enemy of the good.

> The name "secrets" seems a bit more generic than "protectors"
> because, as in this case, the secret is not protected. There is
> something I don't like about the word "secrets", but I don't have a
> better suggestion, so this might be what sticks. One thing going for
> "secrets" over "protectors", is that the cryptomount option "-s"
> works better than "-p" for protectors because that's already taken by
> the password option.
[...]

> +  else if (state[4].set) /* secret module */
> > +{
> > +  grub_err_t rc;
> > +
> > +  if (argc < 1)
> > +   return grub_error (GRUB_ERR_BAD_ARGUMENT, "secret module must
> > be specified");
> > +#ifndef GRUB_UTIL
> > +  grub_dl_load (args[0]);
> > +#endif
> > +  se = grub_named_list_find (GRUB_AS_NAMED_LIST
> > (secret_providers), args[0]);
> > +  if (se == NULL)
> > +   return grub_error (GRUB_ERR_INVALID_COMMAND, "No secret
> > provider is found");
> > +
> > +  rc = se->get (args[1], &cargs.key_data);
> > +  if (rc)
> > +   return rc;
> > +  cargs.key_len = grub_strlen((char *) cargs.key_data);
> 
> It seems better to me to send a pointer to cargs.key_len to se->get()
> because it already knows the length without having to do a strlen.
> And this will allow NULLs in the key data.

The original implementation was based on the grub password limitations
in that it had to be a zero terminated ASCII string.  While the zero
termination could now be relaxed, the ASCII requirement remains,
because the LUKS tools don't like passphrases with NULLS in them.  It
does simplify the code to pass the length pointer into the get API, so
I'll do that.

[...]
> > @@ -1385,7 +1437,7 @@ GRUB_MOD_INIT (cryptodisk)
> >  {
> >grub_disk_dev_register (&grub_cryptodisk_dev);
> >cmd = grub_register_extcmd ("cryptomount", grub_cmd_cryptomount,
> > 0,
> > - N_("[-p password]  > b>"),
> > + N_("[-p password]  > s MOD [ID]>"),
> 
> Seems like this should be:
>  "[-p password|-s MOD [ID]]  diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
> > index c6524c9ea..60249f1fc 100644
> > --- a/include/grub/cryptodisk.h
> > +++ b/include/grub/cryptodisk.h
> > @@ -183,4 +183,18 @@ grub_util_get_geli_uuid (const char *dev);
> >  grub_cryptodisk_t grub_cryptodisk_get_by_uuid (const char *uuid);
> >  grub_cryptodisk_t grub_cryptodisk_get_by_source_disk (grub_disk_t
> > disk);
> >  
> > +struct grub_secret_entry {
> 
> s/grub_secret_entry/grub_secret_provider/

OK

> > +  /* as named list */
> > +  struct grub_secret_entry *next;
> > +  struct grub_secret_entry **prev;
> > +  const char *name;
> > +
> > +  /* additional entries */
> > +  grub_err_t (*get) (const char *arg, grub_uint8_t **secret);
> 
> I like having this first arg to pass some data to the secret
> provider. I'm guessing this is to accomodate a keyfiles secrets
> provider. It see

Re: [PATCH] net: fix null pointer dereference when parsing ICMP6_ROUTER_ADVERTISE messages

2022-02-17 Thread Daniel Axtens
Hi,

I tested this against grub-emu and it fixed the crash I had observed.

net_ls_addr reports an address as expected now also.

Reviewed-by: Daniel Axtens 

Kind regards,
Daniel

Qiumiao Zhang via Grub-devel  writes:

> During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful 
> automatic
> configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message 
> multicast
> from the server, it will cause the problem of dereference null pointer and 
> cause
> the grub2 program to crash.
>
> Fixes bug: https://savannah.gnu.org/bugs/index.php?62072
> ---
>  grub-core/net/icmp6.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c
> index 2cbd95d..264fc4a 100644
> --- a/grub-core/net/icmp6.c
> +++ b/grub-core/net/icmp6.c
> @@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
>  
>   /* May not have gotten slaac info, find a global address on this
> card.  */
> - if (route_inf == NULL)
> + if (route_inf == NULL && orig_inf != NULL)
> {
>   FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
>   {
> -- 
> 2.19.1
>
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel

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