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-Url: https://git.lttng.org./?a=commitdiff_plain;h=c8adc20d19d853527a29411a03e114efdeff5f59;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 46fc3f33..d81b4f0b 100644 --- a/include/wrapper/fdtable.h +++ b/include/wrapper/fdtable.h @@ -41,4 +41,18 @@ struct file *lttng_lookup_fdget_rcu(unsigned int fd) } #endif +#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); +} +#else +static inline +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files) +{ + return close_on_exec(fd, files_fdtable(files)); +} +#endif + #endif /* _LTTNG_WRAPPER_FDTABLE_H */ diff --git a/src/lttng-statedump-impl.c b/src/lttng-statedump-impl.c index a0e97e1c..e06649e7 100644 --- a/src/lttng-statedump-impl.c +++ b/src/lttng-statedump-impl.c @@ -42,7 +42,6 @@ #include #include #include -#include #include /* Define the tracepoints, but do not build the probes */ @@ -445,7 +444,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 && 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;