aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 15:34:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 15:34:13 -0400
commit2b76db6a0f649f5a54805807d36d51b6e9e49089 (patch)
tree1155e363d3ea5e416ac5627402dd862028db6907
parent53bf710832a7191e023e2bb1e333226e3115cfa0 (diff)
parent50192abe02929586111fb33f216060a9341875f1 (diff)
Merge tag 'for-linus-3.12-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
Pull 9p updates from Eric Van Hensbergen: "Minor 9p fixes and tweaks for 3.12 merge window The first fixes namespace issues which causes a kernel NULL pointer dereference, the second fixes uevent handling to work better with udev, and the third switches some code to use srlcpy instead of strncpy in order to be safer. All changes have been baking in for-next for at least 2 weeks" * tag 'for-linus-3.12-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: fs/9p: avoid accessing utsname after namespace has been torn down 9p: send uevent after adding/removing mount_tag attribute fs: 9p: use strlcpy instead of strncpy
-rw-r--r--fs/9p/vfs_file.c4
-rw-r--r--fs/9p/vfs_inode.c4
-rw-r--r--include/net/9p/client.h5
-rw-r--r--net/9p/client.c5
-rw-r--r--net/9p/trans_virtio.c5
5 files changed, 19 insertions, 4 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index d384a8b77ee8..aa5ecf479a57 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -183,7 +183,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
183 else 183 else
184 flock.length = fl->fl_end - fl->fl_start + 1; 184 flock.length = fl->fl_end - fl->fl_start + 1;
185 flock.proc_id = fl->fl_pid; 185 flock.proc_id = fl->fl_pid;
186 flock.client_id = utsname()->nodename; 186 flock.client_id = fid->clnt->name;
187 if (IS_SETLKW(cmd)) 187 if (IS_SETLKW(cmd))
188 flock.flags = P9_LOCK_FLAGS_BLOCK; 188 flock.flags = P9_LOCK_FLAGS_BLOCK;
189 189
@@ -260,7 +260,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
260 else 260 else
261 glock.length = fl->fl_end - fl->fl_start + 1; 261 glock.length = fl->fl_end - fl->fl_start + 1;
262 glock.proc_id = fl->fl_pid; 262 glock.proc_id = fl->fl_pid;
263 glock.client_id = utsname()->nodename; 263 glock.client_id = fid->clnt->name;
264 264
265 res = p9_client_getlock_dotl(fid, &glock); 265 res = p9_client_getlock_dotl(fid, &glock);
266 if (res < 0) 266 if (res < 0)
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 25b018efb8ab..94de6d1482e2 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -146,7 +146,7 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
146 char type = 0, ext[32]; 146 char type = 0, ext[32];
147 int major = -1, minor = -1; 147 int major = -1, minor = -1;
148 148
149 strncpy(ext, stat->extension, sizeof(ext)); 149 strlcpy(ext, stat->extension, sizeof(ext));
150 sscanf(ext, "%c %u %u", &type, &major, &minor); 150 sscanf(ext, "%c %u %u", &type, &major, &minor);
151 switch (type) { 151 switch (type) {
152 case 'c': 152 case 'c':
@@ -1186,7 +1186,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1186 * this even with .u extension. So check 1186 * this even with .u extension. So check
1187 * for non NULL stat->extension 1187 * for non NULL stat->extension
1188 */ 1188 */
1189 strncpy(ext, stat->extension, sizeof(ext)); 1189 strlcpy(ext, stat->extension, sizeof(ext));
1190 /* HARDLINKCOUNT %u */ 1190 /* HARDLINKCOUNT %u */
1191 sscanf(ext, "%13s %u", tag_name, &i_nlink); 1191 sscanf(ext, "%13s %u", tag_name, &i_nlink);
1192 if (!strncmp(tag_name, "HARDLINKCOUNT", 13)) 1192 if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index 4c7c01a73911..c38a005bd0cf 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -26,6 +26,8 @@
26#ifndef NET_9P_CLIENT_H 26#ifndef NET_9P_CLIENT_H
27#define NET_9P_CLIENT_H 27#define NET_9P_CLIENT_H
28 28
29#include <linux/utsname.h>
30
29/* Number of requests per row */ 31/* Number of requests per row */
30#define P9_ROW_MAXTAG 255 32#define P9_ROW_MAXTAG 255
31 33
@@ -134,6 +136,7 @@ struct p9_req_t {
134 * @tagpool - transaction id accounting for session 136 * @tagpool - transaction id accounting for session
135 * @reqs - 2D array of requests 137 * @reqs - 2D array of requests
136 * @max_tag - current maximum tag id allocated 138 * @max_tag - current maximum tag id allocated
139 * @name - node name used as client id
137 * 140 *
138 * The client structure is used to keep track of various per-client 141 * The client structure is used to keep track of various per-client
139 * state that has been instantiated. 142 * state that has been instantiated.
@@ -164,6 +167,8 @@ struct p9_client {
164 struct p9_idpool *tagpool; 167 struct p9_idpool *tagpool;
165 struct p9_req_t *reqs[P9_ROW_MAXTAG]; 168 struct p9_req_t *reqs[P9_ROW_MAXTAG];
166 int max_tag; 169 int max_tag;
170
171 char name[__NEW_UTS_LEN + 1];
167}; 172};
168 173
169/** 174/**
diff --git a/net/9p/client.c b/net/9p/client.c
index ba93bdab2701..ee8fd6bd4035 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -987,6 +987,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
987{ 987{
988 int err; 988 int err;
989 struct p9_client *clnt; 989 struct p9_client *clnt;
990 char *client_id;
990 991
991 err = 0; 992 err = 0;
992 clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL); 993 clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL);
@@ -995,6 +996,10 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
995 996
996 clnt->trans_mod = NULL; 997 clnt->trans_mod = NULL;
997 clnt->trans = NULL; 998 clnt->trans = NULL;
999
1000 client_id = utsname()->nodename;
1001 memcpy(clnt->name, client_id, strlen(client_id) + 1);
1002
998 spin_lock_init(&clnt->lock); 1003 spin_lock_init(&clnt->lock);
999 INIT_LIST_HEAD(&clnt->fidlist); 1004 INIT_LIST_HEAD(&clnt->fidlist);
1000 1005
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index e1c26b101830..990afab2be1b 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -577,6 +577,10 @@ static int p9_virtio_probe(struct virtio_device *vdev)
577 mutex_lock(&virtio_9p_lock); 577 mutex_lock(&virtio_9p_lock);
578 list_add_tail(&chan->chan_list, &virtio_chan_list); 578 list_add_tail(&chan->chan_list, &virtio_chan_list);
579 mutex_unlock(&virtio_9p_lock); 579 mutex_unlock(&virtio_9p_lock);
580
581 /* Let udev rules use the new mount_tag attribute. */
582 kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
583
580 return 0; 584 return 0;
581 585
582out_free_tag: 586out_free_tag:
@@ -654,6 +658,7 @@ static void p9_virtio_remove(struct virtio_device *vdev)
654 list_del(&chan->chan_list); 658 list_del(&chan->chan_list);
655 mutex_unlock(&virtio_9p_lock); 659 mutex_unlock(&virtio_9p_lock);
656 sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr); 660 sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
661 kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
657 kfree(chan->tag); 662 kfree(chan->tag);
658 kfree(chan->vc_wq); 663 kfree(chan->vc_wq);
659 kfree(chan); 664 kfree(chan);