Skip to content

Commit 1c892cd

Browse files
committed
Merge tag 'vfs-6.8-rc6.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner: - Fix a memory leak in cachefiles - Restrict aio cancellations to I/O submitted through the aio interfaces as this is otherwise causing issues for I/O submitted via io_uring - Increase buffer for afs volume status to avoid overflow - Fix a missing zero-length check in unbuffered writes in the netfs library. If generic_write_checks() returns zero make netfs_unbuffered_write_iter() return right away - Prevent a leak in i_dio_count caused by netfs_begin_read() operating past i_size. It will return early and leave i_dio_count incremented - Account for ipv4 addresses as well as ipv6 addresses when processing incoming callbacks in afs * tag 'vfs-6.8-rc6.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs/aio: Restrict kiocb_set_cancel_fn() to I/O submitted via libaio afs: Increase buffer size in afs_update_volume_status() afs: Fix ignored callbacks over ipv4 cachefiles: fix memory leak in cachefiles_add_cache() netfs: Fix missing zero-length check in unbuffered write netfs: Fix i_dio_count leak on DIO read past i_size
2 parents 6714ebb + b820de7 commit 1c892cd

File tree

11 files changed

+32
-19
lines changed

11 files changed

+32
-19
lines changed

fs/afs/internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ struct afs_net {
321321
struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */
322322
struct hlist_head fs_proc; /* procfs servers list */
323323

324-
struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */
325-
struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */
324+
struct hlist_head fs_addresses; /* afs_server (by lowest IPv6 addr) */
326325
seqlock_t fs_addr_lock; /* For fs_addresses[46] */
327326

328327
struct work_struct fs_manager;
@@ -561,8 +560,7 @@ struct afs_server {
561560
struct afs_server __rcu *uuid_next; /* Next server with same UUID */
562561
struct afs_server *uuid_prev; /* Previous server with same UUID */
563562
struct list_head probe_link; /* Link in net->fs_probe_list */
564-
struct hlist_node addr4_link; /* Link in net->fs_addresses4 */
565-
struct hlist_node addr6_link; /* Link in net->fs_addresses6 */
563+
struct hlist_node addr_link; /* Link in net->fs_addresses6 */
566564
struct hlist_node proc_link; /* Link in net->fs_proc */
567565
struct list_head volumes; /* RCU list of afs_server_entry objects */
568566
struct afs_server *gc_next; /* Next server in manager's list */

fs/afs/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ static int __net_init afs_net_init(struct net *net_ns)
9090
INIT_LIST_HEAD(&net->fs_probe_slow);
9191
INIT_HLIST_HEAD(&net->fs_proc);
9292

93-
INIT_HLIST_HEAD(&net->fs_addresses4);
94-
INIT_HLIST_HEAD(&net->fs_addresses6);
93+
INIT_HLIST_HEAD(&net->fs_addresses);
9594
seqlock_init(&net->fs_addr_lock);
9695

9796
INIT_WORK(&net->fs_manager, afs_manage_servers);

fs/afs/server.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct afs_server *afs_find_server(struct afs_net *net, const struct rxrpc_peer
3838
seq++; /* 2 on the 1st/lockless path, otherwise odd */
3939
read_seqbegin_or_lock(&net->fs_addr_lock, &seq);
4040

41-
hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) {
41+
hlist_for_each_entry_rcu(server, &net->fs_addresses, addr_link) {
4242
estate = rcu_dereference(server->endpoint_state);
4343
alist = estate->addresses;
4444
for (i = 0; i < alist->nr_addrs; i++)
@@ -177,10 +177,8 @@ static struct afs_server *afs_install_server(struct afs_cell *cell,
177177
* bit, but anything we might want to do gets messy and memory
178178
* intensive.
179179
*/
180-
if (alist->nr_ipv4 > 0)
181-
hlist_add_head_rcu(&server->addr4_link, &net->fs_addresses4);
182-
if (alist->nr_addrs > alist->nr_ipv4)
183-
hlist_add_head_rcu(&server->addr6_link, &net->fs_addresses6);
180+
if (alist->nr_addrs > 0)
181+
hlist_add_head_rcu(&server->addr_link, &net->fs_addresses);
184182

185183
write_sequnlock(&net->fs_addr_lock);
186184

@@ -511,10 +509,8 @@ static void afs_gc_servers(struct afs_net *net, struct afs_server *gc_list)
511509

512510
list_del(&server->probe_link);
513511
hlist_del_rcu(&server->proc_link);
514-
if (!hlist_unhashed(&server->addr4_link))
515-
hlist_del_rcu(&server->addr4_link);
516-
if (!hlist_unhashed(&server->addr6_link))
517-
hlist_del_rcu(&server->addr6_link);
512+
if (!hlist_unhashed(&server->addr_link))
513+
hlist_del_rcu(&server->addr_link);
518514
}
519515
write_sequnlock(&net->fs_lock);
520516

fs/afs/volume.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,15 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key)
353353
{
354354
struct afs_server_list *new, *old, *discard;
355355
struct afs_vldb_entry *vldb;
356-
char idbuf[16];
356+
char idbuf[24];
357357
int ret, idsz;
358358

359359
_enter("");
360360

361361
/* We look up an ID by passing it as a decimal string in the
362362
* operation's name parameter.
363363
*/
364-
idsz = sprintf(idbuf, "%llu", volume->vid);
364+
idsz = snprintf(idbuf, sizeof(idbuf), "%llu", volume->vid);
365365

366366
vldb = afs_vl_lookup_vldb(volume->cell, key, idbuf, idsz);
367367
if (IS_ERR(vldb)) {

fs/aio.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,13 @@ void kiocb_set_cancel_fn(struct kiocb *iocb, kiocb_cancel_fn *cancel)
593593
struct kioctx *ctx = req->ki_ctx;
594594
unsigned long flags;
595595

596+
/*
597+
* kiocb didn't come from aio or is neither a read nor a write, hence
598+
* ignore it.
599+
*/
600+
if (!(iocb->ki_flags & IOCB_AIO_RW))
601+
return;
602+
596603
if (WARN_ON_ONCE(!list_empty(&req->ki_list)))
597604
return;
598605

@@ -1509,7 +1516,7 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
15091516
req->ki_complete = aio_complete_rw;
15101517
req->private = NULL;
15111518
req->ki_pos = iocb->aio_offset;
1512-
req->ki_flags = req->ki_filp->f_iocb_flags;
1519+
req->ki_flags = req->ki_filp->f_iocb_flags | IOCB_AIO_RW;
15131520
if (iocb->aio_flags & IOCB_FLAG_RESFD)
15141521
req->ki_flags |= IOCB_EVENTFD;
15151522
if (iocb->aio_flags & IOCB_FLAG_IOPRIO) {

fs/cachefiles/cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ int cachefiles_add_cache(struct cachefiles_cache *cache)
168168
dput(root);
169169
error_open_root:
170170
cachefiles_end_secure(cache, saved_cred);
171+
put_cred(cache->cache_cred);
172+
cache->cache_cred = NULL;
171173
error_getsec:
172174
fscache_relinquish_cache(cache_cookie);
173175
cache->cache = NULL;

fs/cachefiles/daemon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ static void cachefiles_daemon_unbind(struct cachefiles_cache *cache)
816816
cachefiles_put_directory(cache->graveyard);
817817
cachefiles_put_directory(cache->store);
818818
mntput(cache->mnt);
819+
put_cred(cache->cache_cred);
819820

820821
kfree(cache->rootdirname);
821822
kfree(cache->secctx);

fs/netfs/buffered_write.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ ssize_t netfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
477477

478478
_enter("%llx,%zx,%llx", iocb->ki_pos, iov_iter_count(from), i_size_read(inode));
479479

480+
if (!iov_iter_count(from))
481+
return 0;
482+
480483
if ((iocb->ki_flags & IOCB_DIRECT) ||
481484
test_bit(NETFS_ICTX_UNBUFFERED, &ictx->flags))
482485
return netfs_unbuffered_write_iter(iocb, from);

fs/netfs/direct_write.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,17 @@ ssize_t netfs_unbuffered_write_iter(struct kiocb *iocb, struct iov_iter *from)
139139

140140
_enter("%llx,%zx,%llx", iocb->ki_pos, iov_iter_count(from), i_size_read(inode));
141141

142+
if (!iov_iter_count(from))
143+
return 0;
144+
142145
trace_netfs_write_iter(iocb, from);
143146
netfs_stat(&netfs_n_rh_dio_write);
144147

145148
ret = netfs_start_io_direct(inode);
146149
if (ret < 0)
147150
return ret;
148151
ret = generic_write_checks(iocb, from);
149-
if (ret < 0)
152+
if (ret <= 0)
150153
goto out;
151154
ret = file_remove_privs(file);
152155
if (ret < 0)

fs/netfs/io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync)
748748

749749
if (!rreq->submitted) {
750750
netfs_put_request(rreq, false, netfs_rreq_trace_put_no_submit);
751+
if (rreq->origin == NETFS_DIO_READ)
752+
inode_dio_end(rreq->inode);
751753
ret = 0;
752754
goto out;
753755
}

0 commit comments

Comments
 (0)