Skip to contentSkip to conversation

sandbox fixes

PATCH Applied Antony Pavlov 2 participants 5 messages Jul 2, 2019 – Jul 4, 2019

lore
Share & tools
lore
#0 lore raw

cover sandbox fixes

Antony Pavlov (3):
sandbox: prevent segfault in tap_alloc()
sandbox: eliminale no previous prototype for ‘sandbox_add_device’ warning
sandbox: drop blank lines at EOF

 arch/sandbox/board/board.c                     | 1 -
 arch/sandbox/board/console.c                   | 1 -
 arch/sandbox/board/devices.c                   | 1 +
 arch/sandbox/mach-sandbox/include/mach/linux.h | 2 +-
 arch/sandbox/os/tap.c                          | 3 +--
 5 files changed, 3 insertions(+), 5 deletions(-)
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/3 sandbox: prevent segfault in tap_alloc()

Tap network interface initialization in sandbox barebox leads to segfault under Debian Buster/Sid.

The problem is that strcpy(dev, ifr.ifr_name) inside tap_alloc() tries to alter read-only data passed by tap_probe() and barebox receives SIGSEGV.

Nobody uses network interface name returned by tap_alloc() so we can drop this strcpy().

---
 arch/sandbox/mach-sandbox/include/mach/linux.h | 2 +-
 arch/sandbox/os/tap.c                          | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
arch/sandbox/mach-sandbox/include/mach/linux.h +1 -1
index 52360f8771..7d0ed55735 100644
@@ -8,7 +8,7 @@ int sandbox_add_device(struct device_d *dev);
 struct fb_bitfield;
 
 int linux_register_device(const char *name, void *start, void *end);
-int tap_alloc(char *dev);
+int tap_alloc(const char *dev);
 uint64_t linux_get_time(void);
 int linux_read(int fd, void *buf, size_t count);
 int linux_read_nonblock(int fd, void *buf, size_t count);
arch/sandbox/os/tap.c +1 -2
index 0e29e8e8ad..3a29a4be64 100644
@@ -28,7 +28,7 @@
 #include <linux/if_tun.h>
 #include <string.h>
 
-int tap_alloc(char *dev)
+int tap_alloc(const char *dev)
 {
 	struct ifreq ifr;
 	int fd, err;
@@ -55,7 +55,6 @@ int tap_alloc(char *dev)
 		return err;
 	}
 
-	strcpy(dev, ifr.ifr_name);
 	return fd;
 }
 
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/3 sandbox: eliminale no previous prototype for ‘sandbox_add_device’ warning

In reply to Antony Pavlov

The patch fixes the following gcc-8.3.0 warning:

arch/sandbox/board/devices.c:13:5: warning: no previous prototype for ‘sandbox_add_device’ [-Wmissing-prototypes]
int sandbox_add_device(struct device_d *dev)

     ^~~~~~~~~~~~~~~~~~
---
 arch/sandbox/board/devices.c | 1 +
 1 file changed, 1 insertion(+)
arch/sandbox/board/devices.c +1 -0
index 10d6b67cc4..242a0d718e 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <driver.h>
+#include <mach/linux.h>
 #include <init.h>
 
 static LIST_HEAD(sandbox_device_list);
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/3 sandbox: drop blank lines at EOF

In reply to Antony Pavlov
---
 arch/sandbox/board/board.c   | 1 -
 arch/sandbox/board/console.c | 1 -
 2 files changed, 2 deletions(-)
arch/sandbox/board/board.c +0 -1
index dcad3c249b..1f6392d15e 100644
@@ -58,4 +58,3 @@ static int devices_init(void)
 }
 
 device_initcall(devices_init);
-
arch/sandbox/board/console.c +0 -1
index 006bbd1a6e..4b251e9087 100644
@@ -40,4 +40,3 @@ int barebox_register_console(int stdinfd, int stdoutfd)
 
 	return sandbox_add_device(dev);
 }
-
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#4 lore raw
In reply to Antony Pavlov
Quoted 5 lines · Antony Pavlov

Antony Pavlov (3):
sandbox: prevent segfault in tap_alloc()
sandbox: eliminale no previous prototype for ‘sandbox_add_device’ warning
sandbox: drop blank lines at EOF

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox