Messages in this thread |  | | Subject | Re: [PATCH] fs: clear close-on-exec flag as part of put_unused_fd() | From | Yann Droneaud <> | Date | Thu, 12 Dec 2013 11:45:50 +0100 |
| |
Hi,
Le mercredi 11 décembre 2013 à 23:36 +0100, Mateusz Guzik a écrit : > On Wed, Dec 11, 2013 at 10:08:27PM +0100, Yann Droneaud wrote: > > @@ -806,8 +803,6 @@ static int do_dup2(struct files_struct *files, > > __set_open_fd(fd, fdt); > > if (flags & O_CLOEXEC) > > __set_close_on_exec(fd, fdt); > > - else > > - __clear_close_on_exec(fd, fdt); > > spin_unlock(&files->file_lock); > > > > if (tofree) > > From my reading this will break at least the following: > fd = open(..., .. | O_CLOEXEC); > dup2(whatever, fd); > > now fd has O_CLOEXEC even though it should not >
Thanks for the review.
You're right.
I've misunderstood the portion of the code handling the case where the destination fd is already marked as used: -EBUSY is only returned when the file descriptor is allocaged but not yet installed.
So close-on-exec flag must be cleared in do_dup2().
Regards.
-- Yann Droneaud OPTEYA
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |