[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241001225207.2215639-4-andrii@kernel.org>
Date: Tue, 1 Oct 2024 15:52:05 -0700
From: Andrii Nakryiko <andrii@...nel.org>
To: linux-trace-kernel@...r.kernel.org,
peterz@...radead.org,
oleg@...hat.com
Cc: rostedt@...dmis.org,
mhiramat@...nel.org,
bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
jolsa@...nel.org,
paulmck@...nel.org,
willy@...radead.org,
surenb@...gle.com,
akpm@...ux-foundation.org,
linux-mm@...ck.org,
mjguzik@...il.com,
brauner@...nel.org,
jannh@...gle.com,
mhocko@...nel.org,
vbabka@...e.cz,
mingo@...nel.org,
Andrii Nakryiko <andrii@...nel.org>,
Amir Goldstein <amir73il@...il.com>
Subject: [PATCH v2 tip/perf/core 3/5] fs: add back RCU-delayed freeing of FMODE_BACKING file
6cf41fcfe099 ("backing file: free directly") switched FMODE_BACKING
files to direct freeing as back then there were no use cases requiring
RCU protected access to such files.
Now, with speculative lockless VMA-to-uprobe lookup logic, we do need to
have a guarantee that struct file memory is not going to be freed from
under us during speculative check. So add back RCU-delayed freeing
logic.
We use headless kfree_rcu_mightsleep() variant, as file_free() is only
called for FMODE_BACKING files in might_sleep() context.
Suggested-by: Suren Baghdasaryan <surenb@...gle.com>
Cc: Christian Brauner <brauner@...nel.org>
Cc: Amir Goldstein <amir73il@...il.com>
Signed-off-by: Andrii Nakryiko <andrii@...nel.org>
---
fs/file_table.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/file_table.c b/fs/file_table.c
index ca7843dde56d..257691d358ee 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -68,7 +68,7 @@ static inline void file_free(struct file *f)
put_cred(f->f_cred);
if (unlikely(f->f_mode & FMODE_BACKING)) {
path_put(backing_file_user_path(f));
- kfree(backing_file(f));
+ kfree_rcu_mightsleep(backing_file(f));
} else {
kmem_cache_free(filp_cachep, f);
}
--
2.43.5
Powered by blists - more mailing lists