From: Michael Jeanson Date: Mon, 27 May 2024 14:49:45 +0000 (-0400) Subject: fix: close_on_exec(): pass files_struct instead of fdtable (v6.10) X-Git-Tag: v2.13.14~7 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e8a6e2bd7018e549ffedb278ddc82ef7fb2188b4;p=lttng-modules.git fix: close_on_exec(): pass files_struct instead of fdtable (v6.10) See upstream commit: commit f60d374d2cc88034385265d193a38e3f4a4b430c Author: Al Viro Date: Thu Jan 4 21:35:38 2024 -0500 close_on_exec(): pass files_struct instead of fdtable both callers are happier that way... Change-Id: I8cdabb073c2090842b27b74954d86cb486c43b3e Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/include/wrapper/fdtable.h b/include/wrapper/fdtable.h index 8b32c030..5e89d66f 100644 --- a/include/wrapper/fdtable.h +++ b/include/wrapper/fdtable.h @@ -69,18 +69,27 @@ int lttng_iterate_fd(struct files_struct *files, #endif -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0)) +static inline +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files) +{ + return close_on_exec(fd, files); +} -static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0)) + +static inline +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files) { - return close_on_exec(fd, fdt); + return close_on_exec(fd, files_fdtable(files)); } #else -static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) +static inline +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files) { - return FD_ISSET(fd, fdt->close_on_exec); + return FD_ISSET(fd, files_fdtable(files)->close_on_exec); } #endif diff --git a/src/lttng-statedump-impl.c b/src/lttng-statedump-impl.c index 6ca1bf2e..87db2f60 100644 --- a/src/lttng-statedump-impl.c +++ b/src/lttng-statedump-impl.c @@ -451,7 +451,7 @@ int lttng_dump_one_fd(const void *p, struct file *file, unsigned int fd) * the lock is taken, but we are not aware whether this is * guaranteed or not, so play safe. */ - if (fd < fdt->max_fds && lttng_close_on_exec(fd, fdt)) + if (fd < fdt->max_fds && lttng_close_on_exec(fd, ctx->files)) flags |= O_CLOEXEC; if (IS_ERR(s)) { struct dentry *dentry = file->f_path.dentry;