Skip to content

Commit 2ef5971

Browse files
committed
Merge tag 'vfs-6.10-rc4.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner: "Misc: - Restore debugfs behavior of ignoring unknown mount options - Fix kernel doc for netfs_wait_for_oustanding_io() - Fix struct statx comment after new addition for this cycle - Fix a check in find_next_fd() iomap: - Fix data zeroing behavior when an extent spans the block that contains i_size - Restore i_size increasing in iomap_write_end() for now to avoid stale data exposure on xfs with a realtime device Cachefiles: - Remove unneeded fdtable.h include - Improve trace output for cachefiles_obj_{get,put}_ondemand_fd() - Remove requests from the request list to prevent accessing already freed requests - Fix UAF when issuing restore command while the daemon is still alive by adding an additional reference count to requests - Fix UAF by grabbing a reference during xarray lookup with xa_lock() held - Simplify error handling in cachefiles_ondemand_daemon_read() - Add consistency checks read and open requests to avoid crashes - Add a spinlock to protect ondemand_id variable which is used to determine whether an anonymous cachefiles fd has already been closed - Make on-demand reads killable allowing to handle broken cachefiles daemon better - Flush all requests after the kernel has been marked dead via CACHEFILES_DEAD to avoid hung-tasks - Ensure that closed requests are marked as such to avoid reusing them with a reopen request - Defer fd_install() until after copy_to_user() succeeded and thereby get rid of having to use close_fd() - Ensure that anonymous cachefiles on-demand fds are reused while they are valid to avoid pinning already freed cookies" * tag 'vfs-6.10-rc4.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: iomap: Fix iomap_adjust_read_range for plen calculation iomap: keep on increasing i_size in iomap_write_end() cachefiles: remove unneeded include of <linux/fdtable.h> fs/file: fix the check in find_next_fd() cachefiles: make on-demand read killable cachefiles: flush all requests after setting CACHEFILES_DEAD cachefiles: Set object to close if ondemand_id < 0 in copen cachefiles: defer exposing anon_fd until after copy_to_user() succeeds cachefiles: never get a new anonymous fd if ondemand_id is valid cachefiles: add spin_lock for cachefiles_ondemand_info cachefiles: add consistency check for copen/cread cachefiles: remove err_put_fd label in cachefiles_ondemand_daemon_read() cachefiles: fix slab-use-after-free in cachefiles_ondemand_daemon_read() cachefiles: fix slab-use-after-free in cachefiles_ondemand_get_fd() cachefiles: remove requests from xarray during flushing requests cachefiles: add output string to cachefiles_obj_[get|put]_ondemand_fd statx: Update offset commentary for struct statx netfs: fix kernel doc for nets_wait_for_outstanding_io() debugfs: continue to ignore unknown mount options
2 parents 83a7eef + f5ceb1b commit 2ef5971

File tree

9 files changed

+215
-93
lines changed

9 files changed

+215
-93
lines changed

fs/cachefiles/daemon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int cachefiles_daemon_open(struct inode *inode, struct file *file)
133133
return 0;
134134
}
135135

136-
static void cachefiles_flush_reqs(struct cachefiles_cache *cache)
136+
void cachefiles_flush_reqs(struct cachefiles_cache *cache)
137137
{
138138
struct xarray *xa = &cache->reqs;
139139
struct cachefiles_req *req;
@@ -159,6 +159,7 @@ static void cachefiles_flush_reqs(struct cachefiles_cache *cache)
159159
xa_for_each(xa, index, req) {
160160
req->error = -EIO;
161161
complete(&req->done);
162+
__xa_erase(xa, index);
162163
}
163164
xa_unlock(xa);
164165

fs/cachefiles/internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct cachefiles_ondemand_info {
5555
int ondemand_id;
5656
enum cachefiles_object_state state;
5757
struct cachefiles_object *object;
58+
spinlock_t lock;
5859
};
5960

6061
/*
@@ -138,6 +139,7 @@ static inline bool cachefiles_in_ondemand_mode(struct cachefiles_cache *cache)
138139
struct cachefiles_req {
139140
struct cachefiles_object *object;
140141
struct completion done;
142+
refcount_t ref;
141143
int error;
142144
struct cachefiles_msg msg;
143145
};
@@ -186,6 +188,7 @@ extern int cachefiles_has_space(struct cachefiles_cache *cache,
186188
* daemon.c
187189
*/
188190
extern const struct file_operations cachefiles_daemon_fops;
191+
extern void cachefiles_flush_reqs(struct cachefiles_cache *cache);
189192
extern void cachefiles_get_unbind_pincount(struct cachefiles_cache *cache);
190193
extern void cachefiles_put_unbind_pincount(struct cachefiles_cache *cache);
191194

@@ -424,6 +427,8 @@ do { \
424427
pr_err("I/O Error: " FMT"\n", ##__VA_ARGS__); \
425428
fscache_io_error((___cache)->cache); \
426429
set_bit(CACHEFILES_DEAD, &(___cache)->flags); \
430+
if (cachefiles_in_ondemand_mode(___cache)) \
431+
cachefiles_flush_reqs(___cache); \
427432
} while (0)
428433

429434
#define cachefiles_io_error_obj(object, FMT, ...) \

0 commit comments

Comments
 (0)