Hi Mulyadi,
struct embedded_fd_set { unsigned long fds_bits[1]; }; http://lxr.linux.no/linux/include/linux/file.h#L26 [...] so, I bet it's bitwise operation...should work atomically.
Yes, that's what I thought too, though the bit set used in fdtable should be __kernel_fd_set and not embedded_fd_set, which is used in the files_struct. Doesn't matter though, bit setting is bit setting.
FD_SET(fd, fdt->open_fds); if (flags & O_CLOEXEC) FD_SET(fd, fdt->close_on_exec); else FD_CLR(fd, fdt->close_on_exec);
However, between FD_SET(fd, fdt->open_fds) and FD_SET(fd, fdt->close_on_exec)|FD_CLR(fd, fdt->close_on_exec) the state is inconsistent.
I know that kernel preemption is disabled and that you shouldn't access these entries until after the syscall has completed. However, interrupt handling isn't disabled, so that gap can be enlarged "arbitrarily".
Whether this actually matters, I do not know as I do not know all legal access paths/kernel control paths to this structure. For instance, if an enumeration over all fds as in close_files() is always legal.
Cheers, Martin -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ