9pfs: forbid . and .. in file names
authorGreg Kurz <groug@kaod.org>
Tue, 30 Aug 2016 17:13:11 +0000 (19:13 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 8 Sep 2016 20:46:58 +0000 (15:46 -0500)
commitb5191b2df7dc92a7a4f7fb4d18c37cf8aae38894
treeea47d7d2875f2c6c705983585c69eabee7e9498a
parent917e9a9816f34787391059c89ba5fb770fe22028
9pfs: forbid . and .. in file names

According to the 9P spec http://man.cat-v.org/plan_9/5/open about the
create request:

The names . and .. are special; it is illegal to create files with these
names.

This patch causes the create and lcreate requests to fail with EINVAL if
the file name is either "." or "..".

Even if it isn't explicitly written in the spec, this patch extends the
checking to all requests that may cause a directory entry to be created:

    - mknod
    - rename
    - renameat
    - mkdir
    - link
    - symlink

The unlinkat request also gets patched for consistency (even if
rmdir("foo/..") is expected to fail according to POSIX.1-2001).

The various error values come from the linux manual pages.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 805b5d98c649d26fc44d2d7755a97f18e62b438a)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/9p.c