* [PATCH] net/9p: Mount only matching virtio channels
@ 2010-09-26 15:28 Sven Eckelmann
2010-09-27 22:54 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2010-09-26 15:28 UTC (permalink / raw)
To: ericvh; +Cc: davem, netdev, linux-kernel, Sven Eckelmann
p9_virtio_create will only compare the the channel's tag characters
against the device name till the end of the channel's tag but not till
the end of the device name. This means that if a user defines channels
with the tags foo and foobar then he would mount foo when he requested
foonot and may mount foo when he requested foobar.
Thus it is necessary to check both string lengths against each other in
case of a successful partial string match.
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
net/9p/trans_virtio.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index dcfbe99..b885159 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -329,7 +329,8 @@ p9_virtio_create(struct p9_client *client, const char *devname, char *args)
mutex_lock(&virtio_9p_lock);
list_for_each_entry(chan, &virtio_chan_list, chan_list) {
- if (!strncmp(devname, chan->tag, chan->tag_len)) {
+ if (!strncmp(devname, chan->tag, chan->tag_len) &&
+ strlen(devname) == chan->tag_len) {
if (!chan->inuse) {
chan->inuse = true;
found = 1;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net/9p: Mount only matching virtio channels
2010-09-26 15:28 [PATCH] net/9p: Mount only matching virtio channels Sven Eckelmann
@ 2010-09-27 22:54 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-09-27 22:54 UTC (permalink / raw)
To: sven.eckelmann; +Cc: ericvh, netdev, linux-kernel
From: Sven Eckelmann <sven.eckelmann@gmx.de>
Date: Sun, 26 Sep 2010 17:28:13 +0200
> p9_virtio_create will only compare the the channel's tag characters
> against the device name till the end of the channel's tag but not till
> the end of the device name. This means that if a user defines channels
> with the tags foo and foobar then he would mount foo when he requested
> foonot and may mount foo when he requested foobar.
>
> Thus it is necessary to check both string lengths against each other in
> case of a successful partial string match.
>
> Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
I'll apply this, but this code would be so much simpler and this bug
would have never happened if these tags were NULL terminated when they
were pulled in from virtio.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-27 22:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-26 15:28 [PATCH] net/9p: Mount only matching virtio channels Sven Eckelmann
2010-09-27 22:54 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).