From 1d2ddcfb1935c9c0e98c4295458b01f24e3274f9 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Tue, 7 Feb 2006 12:58:41 -0800 Subject: [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 Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/os-Linux/drivers/tuntap_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'arch/um/os-Linux/drivers') diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 52945338b64..87c3aa0252d 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, return(-EINVAL); } *fd_out = ((int *) CMSG_DATA(cmsg))[0]; + os_set_exec_close(*fd_out, 1); return(0); } @@ -137,7 +138,8 @@ static int tuntap_open(void *data) return(err); if(pri->fixed_config){ - pri->fd = os_open_file("/dev/net/tun", of_rdwr(OPENFLAGS()), 0); + pri->fd = os_open_file("/dev/net/tun", + of_cloexec(of_rdwr(OPENFLAGS())), 0); if(pri->fd < 0){ printk("Failed to open /dev/net/tun, err = %d\n", -pri->fd); -- cgit v1.2.3