public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: nariman.poushin@linaro.org
Subject: Re: [PATCH v2 edk2-platforms 3/3] Platform/ARM/BdsLib: maintain alignment for DevicePaths
Date: Fri, 23 Nov 2018 13:46:58 +0100	[thread overview]
Message-ID: <55dc86b2-99ba-7a1f-77b5-9996f6c280a4@redhat.com> (raw)
In-Reply-To: <20181123084406.27192-4-ard.biesheuvel@linaro.org>

On 11/23/18 09:44, Ard Biesheuvel wrote:
> DevicePath node types may have any size, and so it is up to the
> code that manipulates them to ensure that dereferencing them only
> occurs when the pointer is aligned explicitly.
> 
> Since BdsConnectAndUpdateDevicePath() has only two callers, one of
> which itself, we can simply duplicate the device path (similar to
> how DxeCore's CoreConnectController () does it), and free the pool
> allocation again on the way out. (Note that the allocation only
> occurs when the non-recursive path is taken and the function
> returns EFI_SUCCESS)
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  Platform/ARM/Library/BdsLib/BdsFilePath.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/Platform/ARM/Library/BdsLib/BdsFilePath.c b/Platform/ARM/Library/BdsLib/BdsFilePath.c
> index 62f796e5526d..ad66b2f82718 100644
> --- a/Platform/ARM/Library/BdsLib/BdsFilePath.c
> +++ b/Platform/ARM/Library/BdsLib/BdsFilePath.c
> @@ -423,8 +423,8 @@ BdsConnectAndUpdateDevicePath (
>      }
>    }
>  
> -  if (RemainingDevicePath) {
> -    *RemainingDevicePath = Remaining;
> +  if (!EFI_ERROR (Status) && RemainingDevicePath != NULL) {
> +    *RemainingDevicePath = DuplicateDevicePath (Remaining);
>    }
>  
>    return Status;
> @@ -1314,14 +1314,18 @@ BdsLoadImageAndUpdateDevicePath (
>    }
>  
>    FileLoader = FileLoaders;
> +  Status = EFI_UNSUPPORTED;
>    while (FileLoader->Support != NULL) {
>      if (FileLoader->Support (*DevicePath, Handle, RemainingDevicePath)) {
> -      return FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize);
> +      Status = FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath,
> +                             Type, Image, FileSize);
> +      break;
>      }
>      FileLoader++;
>    }
>  
> -  return EFI_UNSUPPORTED;
> +  FreePool (RemainingDevicePath);
> +  return Status;
>  }
>  
>  EFI_STATUS
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>


  reply	other threads:[~2018-11-23 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23  8:44 [PATCH v2 edk2-platforms 0/3] Platform/ARM: fix DevicePath mishandling in BdsLib Ard Biesheuvel
2018-11-23  8:44 ` [PATCH v2 edk2-platforms 1/3] Platform/ARM: import ARM platform specific BdsLib header Ard Biesheuvel
2018-11-23  8:44 ` [PATCH v2 edk2-platforms 2/3] Platform/ARM/BdsLib: drop unused functions Ard Biesheuvel
2018-11-23 12:39   ` Laszlo Ersek
2018-11-23  8:44 ` [PATCH v2 edk2-platforms 3/3] Platform/ARM/BdsLib: maintain alignment for DevicePaths Ard Biesheuvel
2018-11-23 12:46   ` Laszlo Ersek [this message]
2018-11-23 14:15 ` [PATCH v2 edk2-platforms 0/3] Platform/ARM: fix DevicePath mishandling in BdsLib Thomas Abraham
2018-11-23 15:17   ` Ard Biesheuvel
2018-11-26 15:06 ` Leif Lindholm
2018-11-26 16:53   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55dc86b2-99ba-7a1f-77b5-9996f6c280a4@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox