public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] efi: add protection for block_dev
Date: Wed, 10 Apr 2019 11:02:58 +0200	[thread overview]
Message-ID: <1554886979-22890-2-git-send-email-patrick.delaunay@st.com> (raw)
In-Reply-To: <1554886979-22890-1-git-send-email-patrick.delaunay@st.com>

Check the value of block_dev before to use this pointer.

This patch solves problem for the command "load" when ubifs
is previously mounted: in this case the function
blk_get_device_part_str("ubi 0") don't return error but return
block_dev = NULL and then data abort.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

To reproduce the issue, I have a boot script 'boot.scr.uimg'
with a load command executed during ubi boot:

load ${devtype} ${devnum}:${distro_bootpart} ${m4fw_addr} ${m4fw_name}

I have a data abort for call stack:
- do_load_wrapper for "ubi 0"
-- efi_set_bootdev
--- efi_dp_from_name

=> desc = 0 and data abort for access to 'desc->*'

I also proposed a protection for the same issue in ums command
http://patchwork.ozlabs.org/project/uboot/list/?series=68096


 lib/efi_loader/efi_device_path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 53b40c8..fd57be8 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -970,7 +970,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
 	if (!is_net) {
 		part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
 					       1);
-		if (part < 0)
+		if (part < 0 || !desc)
 			return EFI_INVALID_PARAMETER;
 
 		if (device)
-- 
2.7.4

  reply	other threads:[~2019-04-10  9:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10  9:02 [U-Boot] [PATCH 1/3] efi: fix issue for 32bit targets with ram_top at 4G Patrick Delaunay
2019-04-10  9:02 ` Patrick Delaunay [this message]
2019-04-10 17:42   ` [U-Boot] [PATCH 2/3] efi: add protection for block_dev Heinrich Schuchardt
2019-04-11  9:30     ` Patrick DELAUNAY
2019-04-11 17:26   ` Heinrich Schuchardt
2019-04-10  9:02 ` [U-Boot] [PATCH 3/3] efi: update virtual address in efi_mem_carve_out Patrick Delaunay
2019-04-11 18:12   ` Heinrich Schuchardt
2019-04-10 16:40 ` [U-Boot] [PATCH 1/3] efi: fix issue for 32bit targets with ram_top at 4G Patrick Wildt
2019-04-11  8:03   ` Patrick DELAUNAY

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-all 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=1554886979-22890-2-git-send-email-patrick.delaunay@st.com \
    --to=patrick.delaunay@st.com \
    --cc=u-boot@lists.denx.de \
    /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