diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-02-07 15:58:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-07 19:12:32 -0500 |
commit | 1d2ddcfb1935c9c0e98c4295458b01f24e3274f9 (patch) | |
tree | 94bc4ad32840430b22e22057dbf8deb70e72492a /arch/um/os-Linux | |
parent | fbd5577901388ff9306a05eb63648c30e4722134 (diff) |
[PATCH] uml: close TUN/TAP file descriptors
When UML opens a TUN/TAP device, the file descriptor could be copied into
later, long-lived threads, holding the device open even after the interface is
taken down, preventing it from being brought up again. This patch makes these
descriptors close-on-exec so that they disappear from helper processes, and
adds CLONE_FILES to a UML helper thread so that the descriptors are closed in
the thread when they are closed elsewhere in UML.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/drivers/tuntap_user.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 52945338b64d..87c3aa0252db 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c | |||
@@ -122,6 +122,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
122 | return(-EINVAL); | 122 | return(-EINVAL); |
123 | } | 123 | } |
124 | *fd_out = ((int *) CMSG_DATA(cmsg))[0]; | 124 | *fd_out = ((int *) CMSG_DATA(cmsg))[0]; |
125 | os_set_exec_close(*fd_out, 1); | ||
125 | return(0); | 126 | return(0); |
126 | } | 127 | } |
127 | 128 | ||
@@ -137,7 +138,8 @@ static int tuntap_open(void *data) | |||
137 | return(err); | 138 | return(err); |
138 | 139 | ||
139 | if(pri->fixed_config){ | 140 | if(pri->fixed_config){ |
140 | pri->fd = os_open_file("/dev/net/tun", of_rdwr(OPENFLAGS()), 0); | 141 | pri->fd = os_open_file("/dev/net/tun", |
142 | of_cloexec(of_rdwr(OPENFLAGS())), 0); | ||
141 | if(pri->fd < 0){ | 143 | if(pri->fd < 0){ |
142 | printk("Failed to open /dev/net/tun, err = %d\n", | 144 | printk("Failed to open /dev/net/tun, err = %d\n", |
143 | -pri->fd); | 145 | -pri->fd); |