Skip to content

Commit c9b93ca

Browse files
committed
Merge tag '9p-for-6.7-rc1' of https://github.com/martinetd/linux
Pull 9p updates from Dominique Martinet: A bunch of small fixes: - three W=1 warning fixes: the NULL -> "" replacement isn't trivial but is serialized identically by the protocol layer and has been tested - one syzbot/KCSAN datarace annotation where we don't care about users messing with the fd they passed to mount -t 9p - removing a declaration without implementation - yet another race fix for trans_fd around connection close: the 'err' field is also used in potentially racy calls and this isn't complete, but it's better than what we had - and finally a theorical memory leak fix on serialization failure" * tag '9p-for-6.7-rc1' of https://github.com/martinetd/linux: 9p/net: fix possible memory leak in p9_check_errors() 9p/fs: add MODULE_DESCRIPTION 9p/net: xen: fix false positive printf format overflow warning 9p: v9fs_listxattr: fix %s null argument warning 9p/trans_fd: Annotate data-racy writes to file::f_flags fs/9p: Remove unused function declaration v9fs_inode2stat() 9p/trans_fd: avoid sending req to a cancelled conn
2 parents 766e9cf + ce07087 commit c9b93ca

File tree

6 files changed

+32
-19
lines changed

6 files changed

+32
-19
lines changed

fs/9p/v9fs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,4 +732,5 @@ module_exit(exit_v9fs)
732732
MODULE_AUTHOR("Latchesar Ionkov <[email protected]>");
733733
MODULE_AUTHOR("Eric Van Hensbergen <[email protected]>");
734734
MODULE_AUTHOR("Ron Minnich <[email protected]>");
735+
MODULE_DESCRIPTION("9P Client File System");
735736
MODULE_LICENSE("GPL");

fs/9p/v9fs_vfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ void v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
5252
unsigned int flags);
5353
int v9fs_dir_release(struct inode *inode, struct file *filp);
5454
int v9fs_file_open(struct inode *inode, struct file *file);
55-
void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);
5655
int v9fs_uflags2omode(int uflags, int extended);
5756

5857
void v9fs_blank_wstat(struct p9_wstat *wstat);

fs/9p/xattr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ssize_t v9fs_xattr_get(struct dentry *dentry, const char *name,
6868
struct p9_fid *fid;
6969
int ret;
7070

71-
p9_debug(P9_DEBUG_VFS, "name = %s value_len = %zu\n",
71+
p9_debug(P9_DEBUG_VFS, "name = '%s' value_len = %zu\n",
7272
name, buffer_size);
7373
fid = v9fs_fid_lookup(dentry);
7474
if (IS_ERR(fid))
@@ -139,7 +139,8 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
139139

140140
ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
141141
{
142-
return v9fs_xattr_get(dentry, NULL, buffer, buffer_size);
142+
/* Txattrwalk with an empty string lists xattrs instead */
143+
return v9fs_xattr_get(dentry, "", buffer, buffer_size);
143144
}
144145

145146
static int v9fs_xattr_handler_get(const struct xattr_handler *handler,

net/9p/client.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,14 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
540540
return 0;
541541

542542
if (!p9_is_proto_dotl(c)) {
543-
char *ename;
543+
char *ename = NULL;
544544

545545
err = p9pdu_readf(&req->rc, c->proto_version, "s?d",
546546
&ename, &ecode);
547-
if (err)
547+
if (err) {
548+
kfree(ename);
548549
goto out_err;
550+
}
549551

550552
if (p9_is_proto_dotu(c) && ecode < 512)
551553
err = -ecode;
@@ -1979,7 +1981,7 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
19791981
goto error;
19801982
}
19811983
p9_debug(P9_DEBUG_9P,
1982-
">>> TXATTRWALK file_fid %d, attr_fid %d name %s\n",
1984+
">>> TXATTRWALK file_fid %d, attr_fid %d name '%s'\n",
19831985
file_fid->fid, attr_fid->fid, attr_name);
19841986

19851987
req = p9_client_rpc(clnt, P9_TXATTRWALK, "dds",

net/9p/trans_fd.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,14 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req)
671671

672672
p9_debug(P9_DEBUG_TRANS, "mux %p task %p tcall %p id %d\n",
673673
m, current, &req->tc, req->tc.id);
674-
if (m->err < 0)
675-
return m->err;
676674

677675
spin_lock(&m->req_lock);
676+
677+
if (m->err < 0) {
678+
spin_unlock(&m->req_lock);
679+
return m->err;
680+
}
681+
678682
WRITE_ONCE(req->status, REQ_STATUS_UNSENT);
679683
list_add_tail(&req->req_list, &m->unsent_req_list);
680684
spin_unlock(&m->req_lock);
@@ -832,14 +836,21 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd)
832836
goto out_free_ts;
833837
if (!(ts->rd->f_mode & FMODE_READ))
834838
goto out_put_rd;
835-
/* prevent workers from hanging on IO when fd is a pipe */
836-
ts->rd->f_flags |= O_NONBLOCK;
839+
/* Prevent workers from hanging on IO when fd is a pipe.
840+
* It's technically possible for userspace or concurrent mounts to
841+
* modify this flag concurrently, which will likely result in a
842+
* broken filesystem. However, just having bad flags here should
843+
* not crash the kernel or cause any other sort of bug, so mark this
844+
* particular data race as intentional so that tooling (like KCSAN)
845+
* can allow it and detect further problems.
846+
*/
847+
data_race(ts->rd->f_flags |= O_NONBLOCK);
837848
ts->wr = fget(wfd);
838849
if (!ts->wr)
839850
goto out_put_rd;
840851
if (!(ts->wr->f_mode & FMODE_WRITE))
841852
goto out_put_wr;
842-
ts->wr->f_flags |= O_NONBLOCK;
853+
data_race(ts->wr->f_flags |= O_NONBLOCK);
843854

844855
client->trans = ts;
845856
client->status = Connected;

net/9p/trans_xen.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ struct xen_9pfs_front_priv {
5454
char *tag;
5555
struct p9_client *client;
5656

57-
int num_rings;
5857
struct xen_9pfs_dataring *rings;
5958
};
6059

@@ -131,7 +130,7 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
131130
if (list_entry_is_head(priv, &xen_9pfs_devs, list))
132131
return -EINVAL;
133132

134-
num = p9_req->tc.tag % priv->num_rings;
133+
num = p9_req->tc.tag % XEN_9PFS_NUM_RINGS;
135134
ring = &priv->rings[num];
136135

137136
again:
@@ -279,7 +278,7 @@ static void xen_9pfs_front_free(struct xen_9pfs_front_priv *priv)
279278
list_del(&priv->list);
280279
write_unlock(&xen_9pfs_lock);
281280

282-
for (i = 0; i < priv->num_rings; i++) {
281+
for (i = 0; i < XEN_9PFS_NUM_RINGS; i++) {
283282
struct xen_9pfs_dataring *ring = &priv->rings[i];
284283

285284
cancel_work_sync(&ring->work);
@@ -408,15 +407,14 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
408407
if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order))
409408
p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2;
410409

411-
priv->num_rings = XEN_9PFS_NUM_RINGS;
412-
priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings),
410+
priv->rings = kcalloc(XEN_9PFS_NUM_RINGS, sizeof(*priv->rings),
413411
GFP_KERNEL);
414412
if (!priv->rings) {
415413
kfree(priv);
416414
return -ENOMEM;
417415
}
418416

419-
for (i = 0; i < priv->num_rings; i++) {
417+
for (i = 0; i < XEN_9PFS_NUM_RINGS; i++) {
420418
priv->rings[i].priv = priv;
421419
ret = xen_9pfs_front_alloc_dataring(dev, &priv->rings[i],
422420
max_ring_order);
@@ -434,10 +432,11 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
434432
if (ret)
435433
goto error_xenbus;
436434
ret = xenbus_printf(xbt, dev->nodename, "num-rings", "%u",
437-
priv->num_rings);
435+
XEN_9PFS_NUM_RINGS);
438436
if (ret)
439437
goto error_xenbus;
440-
for (i = 0; i < priv->num_rings; i++) {
438+
439+
for (i = 0; i < XEN_9PFS_NUM_RINGS; i++) {
441440
char str[16];
442441

443442
BUILD_BUG_ON(XEN_9PFS_NUM_RINGS > 9);

0 commit comments

Comments
 (0)