pxe: Ensure we don't overflow bootargs
PATCH 1/1 pxe: Ensure we don't overflow bootargs
From: Ian Campbell <[email protected]>
On a couple of platforms I've tripped over long PXE append lines overflowing this array, due to having CONFIG_SYS_CBSIZE == 256. When doing preseeded Debian installs it's pretty trivial to exceed that.
Since the symptom can be a silent hang or a crash add a check. Of course the affected boards would also need an increased CBSIZE to actually work.
Note that due to the printing of the final bootargs string CONFIG_SYS_PBSIZE also needs to be sufficiently large.
---
I think this is v2014.10 material?
--- common/cmd_pxe.c | 9 +++++++++ 1 file changed, 9 insertions(+)
common/cmd_pxe.c +9 -0
@@ -674,6 +674,15 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)char bootargs[CONFIG_SYS_CBSIZE ] ="" ;char finalbootargs[CONFIG_SYS_CBSIZE ]; +if (strlen (label->append ?:"" ) + +strlen (ip_str) +strlen (mac_str) +1 >sizeof (bootargs)) { +printf ("bootarg overflow %d+%d+%d+1 > %zd\n" , +strlen (label->append ?:"" ), +strlen (ip_str),strlen (mac_str), +sizeof (bootargs)); +return 1 ; + } +if (label->append)strcpy (bootargs, label->append);strcat (bootargs, ip_str);
Signature · 1 line
2.1.0
Quoted 24 lines · Ian Campbell
From: Ian Campbell <[email protected]>
On a couple of platforms I've tripped over long PXE append lines overflowing this array, due to having
CONFIG_SYS_CBSIZE== 256. When doing preseeded Debian installs it's pretty trivial to exceed that.Since the symptom can be a silent hang or a crash add a check. Of course the affected boards would also need an increased CBSIZE to actually work.
Note that due to the printing of the final bootargs string
CONFIG_SYS_PBSIZEalso needs to be sufficiently large.Signed-off-by Ian Campbell <[email protected]>---
I think this is v2014.10 material?--- common/cmd_pxe.c | 9 +++++++++ 1 file changed, 9 insertions(+)common/cmd_pxe.c +0
-0
common/cmd_pxe.c static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) · line 679
Quoted 6 lines
common/cmd_pxe.c +3
-0@@ -674,6 +674,15 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)char bootargs[CONFIG_SYS_CBSIZE ] ="" ;char finalbootargs[CONFIG_SYS_CBSIZE ]; +if (strlen (label->append ?:"" ) + +strlen (ip_str) +strlen (mac_str) +1 >sizeof (bootargs)) { + printf("bootarg overflow %d+%d+%d+1 > %zd\n",
With a change to use %zd in all cases (aarch64 warns otherwise), applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141010/8fe6e03e/attachment.pgp>
Quoted 29 lines · Tom Rini
Quoted 27 lines · Ian Campbell
From: Ian Campbell <[email protected]>
On a couple of platforms I've tripped over long PXE append lines overflowing this array, due to having
CONFIG_SYS_CBSIZE== 256. When doing preseeded Debian installs it's pretty trivial to exceed that.Since the symptom can be a silent hang or a crash add a check. Of course the affected boards would also need an increased CBSIZE to actually work.
Note that due to the printing of the final bootargs string
CONFIG_SYS_PBSIZEalso needs to be sufficiently large.Signed-off-by Ian Campbell <[email protected]>---
I think this is v2014.10 material?--- common/cmd_pxe.c | 9 +++++++++ 1 file changed, 9 insertions(+)common/cmd_pxe.c +0
-0@@ -674,6 +674,15 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)char bootargs[CONFIG_SYS_CBSIZE ] ="" ;char finalbootargs[CONFIG_SYS_CBSIZE ];
Quoted 5 lines
common/cmd_pxe.c static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) · line 679
Quoted 3 lines
common/cmd_pxe.c +3
-0+if (strlen (label->append ?:"" ) + +strlen (ip_str) +strlen (mac_str) +1 >sizeof (bootargs)) { + printf("bootarg overflow %d+%d+%d+1 > %zd\n",With a change to use %zd in all cases (aarch64 warns otherwise),
Oops, sorry!
Quoted 2 lines
applied
to u-boot/master, thanks!
thanks!