1 From c8adc20d19d853527a29411a03e114efdeff5f59 Mon Sep 17 00:00:00 2001
2 From: Michael Jeanson <mjeanson@efficios.com>
3 Date: Mon, 27 May 2024 10:49:45 -0400
4 Subject: [PATCH] fix: close_on_exec(): pass files_struct instead of fdtable
9 commit f60d374d2cc88034385265d193a38e3f4a4b430c
10 Author: Al Viro <viro@zeniv.linux.org.uk>
11 Date: Thu Jan 4 21:35:38 2024 -0500
13 close_on_exec(): pass files_struct instead of fdtable
15 both callers are happier that way...
17 Upstream-Status: Backport [c8adc20d fix: close_on_exec(): pass files_struct instead of fdtable (v6.10)]
19 Change-Id: I8cdabb073c2090842b27b74954d86cb486c43b3e
20 Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
21 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
23 include/wrapper/fdtable.h | 14 ++++++++++++++
24 src/lttng-statedump-impl.c | 3 +--
25 2 files changed, 15 insertions(+), 2 deletions(-)
27 Index: lttng-modules-2.13.13/include/wrapper/fdtable.h
28 ===================================================================
29 --- lttng-modules-2.13.13.orig/include/wrapper/fdtable.h
30 +++ lttng-modules-2.13.13/include/wrapper/fdtable.h
31 @@ -69,20 +69,18 @@ int lttng_iterate_fd(struct files_struct
35 -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0))
37 -static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt)
38 +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
40 +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
42 - return close_on_exec(fd, fdt);
43 + return close_on_exec(fd, files);
48 -static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt)
50 +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
52 - return FD_ISSET(fd, fdt->close_on_exec);
53 + return close_on_exec(fd, files_fdtable(files));
58 #endif /* _LTTNG_WRAPPER_FDTABLE_H */
59 Index: lttng-modules-2.13.13/src/lttng-statedump-impl.c
60 ===================================================================
61 --- lttng-modules-2.13.13.orig/src/lttng-statedump-impl.c
62 +++ lttng-modules-2.13.13/src/lttng-statedump-impl.c
64 #include <wrapper/tracepoint.h>
65 #include <wrapper/genhd.h>
66 #include <wrapper/file.h>
67 -#include <wrapper/fdtable.h>
68 #include <wrapper/sched.h>
70 #ifdef CONFIG_LTTNG_HAS_LIST_IRQ
71 @@ -451,7 +450,7 @@ int lttng_dump_one_fd(const void *p, str
72 * the lock is taken, but we are not aware whether this is
73 * guaranteed or not, so play safe.
75 - if (fd < fdt->max_fds && lttng_close_on_exec(fd, fdt))
76 + if (fd < fdt->max_fds && lttng_close_on_exec(fd, ctx->files))
79 struct dentry *dentry = file->f_path.dentry;