Skip to contentSkip to conversation

cmd: pxe_utils: sysboot: fix crash if either board or soc are not set.

PATCH New Dimitri John Ledkov 3 participants 5 messages Apr 21, 2021 – Jun 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: pxe_utils: sysboot: fix crash if either board or soc are not set.

If the environment does not have "soc" or "board" set, and fdtdir option is specified in extlinux.conf, the bootloader will crash whilst dereferencing a null pointer. Add a guard against null soc or board. Fixes a crash of qemu-riscv64_smode configuration, which does not have CONFIG_SYS_SOC defined.

---
 cmd/pxe_utils.c | 8 ++++++++
 1 file changed, 8 insertions(+)
cmd/pxe_utils.c +8 -0
index 71c5af4c25..9a30629e26 100644
@@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
 				f2 = "-";
 				f3 = env_get("board");
 				f4 = ".dtb";
+				if (!f1) {
+					f1 = "";
+					f2 = "";
+				}
+				if (!f3) {
+					f2 = "";
+					f3 = "";
+				}
 			}
 
 			len = strlen(label->fdtdir);
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 cmd: pxe_utils: sysboot: fix crash if either board or soc are not set.

Hi qemu-board meaintainers,

The below patch affects any boards that do not have either board or soc variables set.

Of which non-x86 qemu boards are exactly that, preventing to netboot the same rootfs across multiple boards and qemu at the same time.

Another alternative would be for all non-x86 qemu boards to also define config SYS_SOC
default "qemu"

However, I fear similar situation might still arise in the future where some boards lack either SYS_BOARD or SYS_SOC definitions. Thus even if non-qemu boards are fixed up, the below should still be applied?

Do you want me to send a separate patch to add SYS_SOC to all qemu boards?

Quoted 34 lines · Dimitri John Ledkov

If the environment does not have "soc" or "board" set, and fdtdir option is specified in extlinux.conf, the bootloader will crash whilst dereferencing a null pointer. Add a guard against null soc or board. Fixes a crash of qemu-riscv64_smode configuration, which does not have CONFIG_SYS_SOC defined.

---
 cmd/pxe_utils.c | 8 ++++++++
 1 file changed, 8 insertions(+)
cmd/pxe_utils.c +8 -1
index 71c5af4c25..9a30629e26 100644
@@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
                                f2 = "-";
                                f3 = env_get("board");
                                f4 = ".dtb";
+                               if (!f1) {
+                                       f1 = "";
+                                       f2 = "";
+                               }
+                               if (!f3) {
+                                       f2 = "";
+                                       f3 = "";
+                               }
                        }
 
                        len = strlen(label->fdtdir);
--

2.27.0

Signature · 3 lines
Regards,

Dimitri.
#2 lore raw

PATCH 1/1 cmd: pxe_utils: sysboot: fix crash if either board or soc are not set.

In reply to Dimitri John Ledkov
Quoted 32 lines · Dimitri John Ledkov

If the environment does not have "soc" or "board" set, and fdtdir option is specified in extlinux.conf, the bootloader will crash whilst dereferencing a null pointer. Add a guard against null soc or board. Fixes a crash of qemu-riscv64_smode configuration, which does not have CONFIG_SYS_SOC defined.

---
 cmd/pxe_utils.c | 8 ++++++++
 1 file changed, 8 insertions(+)
cmd/pxe_utils.c +8 -1
index 71c5af4c25..9a30629e26 100644
@@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
                                f2 = "-";
                                f3 = env_get("board");
                                f4 = ".dtb";
+                               if (!f1) {
+                                       f1 = "";
+                                       f2 = "";
+                               }
+                               if (!f3) {
+                                       f2 = "";
+                                       f3 = "";
+                               }
                        }
 
                        len = strlen(label->fdtdir);
--
Quoted 2 lines

2.27.0

#3 lore raw

Hi, this patch is still not pulled into master. It still applies cleanly onto master.

Can this patch please be pulled in? It fixes a crash of uboot. Without this patch upstream, people who build their own uboot cannot boot stock Ubuntu images.

What can I do, for this patch to be applied?

Quoted 37 lines · Ramon Fried
Quoted 32 lines · Dimitri John Ledkov

If the environment does not have "soc" or "board" set, and fdtdir option is specified in extlinux.conf, the bootloader will crash whilst dereferencing a null pointer. Add a guard against null soc or board. Fixes a crash of qemu-riscv64_smode configuration, which does not have CONFIG_SYS_SOC defined.

---
 cmd/pxe_utils.c | 8 ++++++++
 1 file changed, 8 insertions(+)
cmd/pxe_utils.c +8 -1
index 71c5af4c25..9a30629e26 100644
@@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
                                f2 = "-";
                                f3 = env_get("board");
                                f4 = ".dtb";
+                               if (!f1) {
+                                       f1 = "";
+                                       f2 = "";
+                               }
+                               if (!f3) {
+                                       f2 = "";
+                                       f3 = "";
+                               }
                        }
 
                        len = strlen(label->fdtdir);
--
Quoted 2 lines

2.27.0

Signature · 3 lines
Regards,

Dimitri.
#4 lore raw
Quoted 51 lines · Dimitri John Ledkov

Hi, this patch is still not pulled into master. It still applies cleanly onto master.

Can this patch please be pulled in? It fixes a crash of uboot. Without this patch upstream, people who build their own uboot cannot boot stock Ubuntu images.

What can I do, for this patch to be applied?

Quoted 32 lines · Ramon Fried
Quoted 30 lines · Dimitri John Ledkov

If the environment does not have "soc" or "board" set, and fdtdir option is specified in extlinux.conf, the bootloader will crash whilst dereferencing a null pointer. Add a guard against null soc or board. Fixes a crash of qemu-riscv64_smode configuration, which does not have CONFIG_SYS_SOC defined.

---
 cmd/pxe_utils.c | 8 ++++++++
 1 file changed, 8 insertions(+)
cmd/pxe_utils.c +8 -0
index 71c5af4c25..9a30629e26 100644
@@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
                                f2 = "-";
                                f3 = env_get("board");
                                f4 = ".dtb";
+                               if (!f1) {
+                                       f1 = "";
+                                       f2 = "";
+                               }
+                               if (!f3) {
+                                       f2 = "";
+                                       f3 = "";
+                               }
                        }
 
Quoted 5 lines
Quoted 4 lines
cmd/pxe_utils.c +0 -1
                        len = strlen(label->fdtdir);
--

2.27.0

Quoted 4 lines

--
Regards,

Dimitri.

applied to u-boot-net/master, thanks!

Best regards,
Ramon Fried