From b6eab2a491184dcf6361baeca709c3d781a165bb Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Tue, 2 Jul 2019 12:59:59 +0300 Subject: 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(). Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/sandbox/mach-sandbox/include/mach/linux.h | 2 +- arch/sandbox/os/tap.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 52360f8771..7d0ed55735 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -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); diff --git a/arch/sandbox/os/tap.c b/arch/sandbox/os/tap.c index 0e29e8e8ad..3a29a4be64 100644 --- a/arch/sandbox/os/tap.c +++ b/arch/sandbox/os/tap.c @@ -28,7 +28,7 @@ #include #include -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; } -- cgit v1.2.3 From 26239bfee943b5e6bbf8ee03a9cf76208d90adfa Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Tue, 2 Jul 2019 13:00:00 +0300 Subject: sandbox: eliminale no previous prototype for ‘sandbox_add_device’ warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) ^~~~~~~~~~~~~~~~~~ Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/sandbox/board/devices.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sandbox/board/devices.c b/arch/sandbox/board/devices.c index 10d6b67cc4..242a0d718e 100644 --- a/arch/sandbox/board/devices.c +++ b/arch/sandbox/board/devices.c @@ -6,6 +6,7 @@ #include #include +#include #include static LIST_HEAD(sandbox_device_list); -- cgit v1.2.3 From a04d27474c50c08d917a831c9cc7e1b27e3599ff Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Tue, 2 Jul 2019 13:00:01 +0300 Subject: sandbox: drop blank lines at EOF Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/sandbox/board/board.c | 1 - arch/sandbox/board/console.c | 1 - 2 files changed, 2 deletions(-) diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c index dcad3c249b..1f6392d15e 100644 --- a/arch/sandbox/board/board.c +++ b/arch/sandbox/board/board.c @@ -58,4 +58,3 @@ static int devices_init(void) } device_initcall(devices_init); - diff --git a/arch/sandbox/board/console.c b/arch/sandbox/board/console.c index 006bbd1a6e..4b251e9087 100644 --- a/arch/sandbox/board/console.c +++ b/arch/sandbox/board/console.c @@ -40,4 +40,3 @@ int barebox_register_console(int stdinfd, int stdoutfd) return sandbox_add_device(dev); } - -- cgit v1.2.3