mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] sandbox: prevent segfault in tap_alloc()
Date: Tue,  2 Jul 2019 12:59:59 +0300	[thread overview]
Message-ID: <20190702100001.28530-2-antonynpavlov@gmail.com> (raw)
In-Reply-To: <20190702100001.28530-1-antonynpavlov@gmail.com>

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 <antonynpavlov@gmail.com>
---
 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 <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;
 }
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-07-02 10:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-02  9:59 [PATCH 0/3] sandbox fixes Antony Pavlov
2019-07-02  9:59 ` Antony Pavlov [this message]
2019-07-02 10:00 ` [PATCH 2/3] sandbox: eliminale no previous prototype for ‘sandbox_add_device’ warning Antony Pavlov
2019-07-02 10:00 ` [PATCH 3/3] sandbox: drop blank lines at EOF Antony Pavlov
2019-07-04  6:50 ` [PATCH 0/3] sandbox fixes Sascha Hauer

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=20190702100001.28530-2-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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