8c721a87ae
- Remove deprecated patch "work-around-SA_RESTART-race" (boo#982208) - Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-2.6 * Patches dropped: 0002-XXX-work-around-SA_RESTART-race-wit.patch 0003-qemu-0.9.0.cvs-binfmt.patch 0004-qemu-cvs-alsa_bitfield.patch 0005-qemu-cvs-alsa_ioctl.patch 0006-qemu-cvs-alsa_mmap.patch 0007-qemu-cvs-gettimeofday.patch 0008-qemu-cvs-ioctl_debug.patch 0009-qemu-cvs-ioctl_nodirection.patch 0010-block-vmdk-Support-creation-of-SCSI.patch 0011-linux-user-add-binfmt-wrapper-for-a.patch 0012-PPC-KVM-Disable-mmu-notifier-check.patch 0013-linux-user-fix-segfault-deadlock.patch 0014-linux-user-binfmt-support-host-bina.patch 0015-linux-user-Ignore-broken-loop-ioctl.patch 0016-linux-user-lock-tcg.patch 0017-linux-user-Run-multi-threaded-code-.patch 0018-linux-user-lock-tb-flushing-too.patch 0019-linux-user-Fake-proc-cpuinfo.patch 0020-linux-user-implement-FS_IOC_GETFLAG.patch 0021-linux-user-implement-FS_IOC_SETFLAG.patch 0022-linux-user-XXX-disable-fiemap.patch 0023-slirp-nooutgoing.patch 0024-vnc-password-file-and-incoming-conn.patch 0025-linux-user-add-more-blk-ioctls.patch 0026-linux-user-use-target_ulong.patch 0027-block-Add-support-for-DictZip-enabl.patch 0028-block-Add-tar-container-format.patch OBS-URL: https://build.opensuse.org/request/show/408549 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=305
125 lines
3.7 KiB
Diff
125 lines
3.7 KiB
Diff
From d839baef69733ff67df56abd52bf01b13c2adc80 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
|
|
Date: Wed, 29 Aug 2012 18:42:56 +0200
|
|
Subject: [PATCH] slirp: -nooutgoing
|
|
|
|
TBD (from SUSE Studio team)
|
|
---
|
|
qemu-options.hx | 10 ++++++++++
|
|
slirp/socket.c | 8 ++++++++
|
|
slirp/tcp_subr.c | 12 ++++++++++++
|
|
vl.c | 9 +++++++++
|
|
4 files changed, 39 insertions(+)
|
|
|
|
diff --git a/qemu-options.hx b/qemu-options.hx
|
|
index 6106520..32b25a5 100644
|
|
--- a/qemu-options.hx
|
|
+++ b/qemu-options.hx
|
|
@@ -3102,6 +3102,16 @@ Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
|
|
from a script.
|
|
ETEXI
|
|
|
|
+DEF("nooutgoing", HAS_ARG, QEMU_OPTION_nooutgoing, \
|
|
+ "-nooutgoing <IP>\n" \
|
|
+ " incoming traffic only from IP, no outgoing\n", \
|
|
+ QEMU_ARCH_ALL)
|
|
+STEXI
|
|
+@item -nooutgoing
|
|
+Forbid userspace networking to make outgoing connections. Only accept incoming
|
|
+connections from ip address IP.
|
|
+ETEXI
|
|
+
|
|
DEF("singlestep", 0, QEMU_OPTION_singlestep, \
|
|
"-singlestep always run in singlestep mode\n", QEMU_ARCH_ALL)
|
|
STEXI
|
|
diff --git a/slirp/socket.c b/slirp/socket.c
|
|
index a10eff1..fec954e 100644
|
|
--- a/slirp/socket.c
|
|
+++ b/slirp/socket.c
|
|
@@ -608,6 +608,8 @@ sorecvfrom(struct socket *so)
|
|
} /* if ping packet */
|
|
}
|
|
|
|
+extern int slirp_nooutgoing;
|
|
+
|
|
/*
|
|
* sendto() a socket
|
|
*/
|
|
@@ -625,6 +627,12 @@ sosendto(struct socket *so, struct mbuf *m)
|
|
DEBUG_CALL(" sendto()ing)");
|
|
sotranslate_out(so, &addr);
|
|
|
|
+ /* Only allow DNS requests */
|
|
+ if (slirp_nooutgoing && ntohs(((struct sockaddr_in *)&addr)->sin_port) != 53) {
|
|
+ errno = EHOSTUNREACH;
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
/* Don't care what port we get */
|
|
ret = sendto(so->s, m->m_data, m->m_len, 0,
|
|
(struct sockaddr *)&addr, sockaddr_size(&addr));
|
|
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
|
|
index 6b9fef2..e712e21 100644
|
|
--- a/slirp/tcp_subr.c
|
|
+++ b/slirp/tcp_subr.c
|
|
@@ -391,6 +391,8 @@ tcp_sockclosed(struct tcpcb *tp)
|
|
* nonblocking. Connect returns after the SYN is sent, and does
|
|
* not wait for ACK+SYN.
|
|
*/
|
|
+extern int slirp_nooutgoing;
|
|
+
|
|
int tcp_fconnect(struct socket *so, unsigned short af)
|
|
{
|
|
int ret=0;
|
|
@@ -398,6 +400,11 @@ int tcp_fconnect(struct socket *so, unsigned short af)
|
|
DEBUG_CALL("tcp_fconnect");
|
|
DEBUG_ARG("so = %p", so);
|
|
|
|
+ if (slirp_nooutgoing) {
|
|
+ errno = EHOSTUNREACH;
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
ret = so->s = qemu_socket(af, SOCK_STREAM, 0);
|
|
if (ret >= 0) {
|
|
int opt, s=so->s;
|
|
@@ -478,6 +485,11 @@ void tcp_connect(struct socket *inso)
|
|
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
|
return;
|
|
}
|
|
+ if (slirp_nooutgoing && ((struct sockaddr_in *)&addr)->sin_addr.s_addr != slirp_nooutgoing) {
|
|
+ tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
|
+ closesocket(s);
|
|
+ return;
|
|
+ }
|
|
qemu_set_nonblock(s);
|
|
socket_set_fast_reuse(s);
|
|
opt = 1;
|
|
diff --git a/vl.c b/vl.c
|
|
index 5fd22cb..18c88ff 100644
|
|
--- a/vl.c
|
|
+++ b/vl.c
|
|
@@ -162,6 +162,7 @@ int smp_threads = 1;
|
|
int acpi_enabled = 1;
|
|
int no_hpet = 0;
|
|
int fd_bootchk = 1;
|
|
+int slirp_nooutgoing = 0;
|
|
static int no_reboot;
|
|
int no_shutdown = 0;
|
|
int cursor_hide = 1;
|
|
@@ -3382,6 +3383,14 @@ int main(int argc, char **argv, char **envp)
|
|
case QEMU_OPTION_singlestep:
|
|
singlestep = 1;
|
|
break;
|
|
+ case QEMU_OPTION_nooutgoing:
|
|
+ slirp_nooutgoing = inet_addr(optarg);
|
|
+ if (slirp_nooutgoing == INADDR_NONE) {
|
|
+ printf("Invalid address: %s.\nOnly addresses of the format "
|
|
+ "xxx.xxx.xxx.xxx are supported.\n", optarg);
|
|
+ exit(1);
|
|
+ }
|
|
+ break;
|
|
case QEMU_OPTION_S:
|
|
autostart = 0;
|
|
break;
|