qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] fff39a: 9pfs: forbid illegal path names


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] fff39a: 9pfs: forbid illegal path names
Date: Tue, 30 Aug 2016 13:00:05 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: fff39a7ad09da07ef490de05c92c91f22f8002f2
      
https://github.com/qemu/qemu/commit/fff39a7ad09da07ef490de05c92c91f22f8002f2
  Author: Greg Kurz <address@hidden>
  Date:   2016-08-30 (Tue, 30 Aug 2016)

  Changed paths:
    M hw/9pfs/9p.c

  Log Message:
  -----------
  9pfs: forbid illegal path names

Empty path components don't make sense for most commands and may cause
undefined behavior, depending on the backend.

Also, the walk request described in the 9P spec [1] clearly shows that
the client is supposed to send individual path components: the official
linux client never sends portions of path containing the / character for
example.

Moreover, the 9P spec [2] also states that a system can decide to restrict
the set of supported characters used in path components, with an explicit
mention "to remove slashes from name components".

This patch introduces a new name_is_illegal() helper that checks the
names sent by the client are not empty and don't contain unwanted chars.
Since 9pfs is only supported on linux hosts, only the / character is
checked at the moment. When support for other hosts (AKA. win32) is added,
other chars may need to be blacklisted as well.

If a client sends an illegal path component, the request will fail and
ENOENT is returned to the client.

[1] http://man.cat-v.org/plan_9/5/walk
[2] http://man.cat-v.org/plan_9/5/intro

Suggested-by: Peter Maydell <address@hidden>
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>


  Commit: 805b5d98c649d26fc44d2d7755a97f18e62b438a
      
https://github.com/qemu/qemu/commit/805b5d98c649d26fc44d2d7755a97f18e62b438a
  Author: Greg Kurz <address@hidden>
  Date:   2016-08-30 (Tue, 30 Aug 2016)

  Changed paths:
    M hw/9pfs/9p.c

  Log Message:
  -----------
  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 <address@hidden>
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>


  Commit: 56f101ecce0eafd09e2daf1c4eeb1377d6959261
      
https://github.com/qemu/qemu/commit/56f101ecce0eafd09e2daf1c4eeb1377d6959261
  Author: Greg Kurz <address@hidden>
  Date:   2016-08-30 (Tue, 30 Aug 2016)

  Changed paths:
    M hw/9pfs/9p.c
    M hw/9pfs/9p.h

  Log Message:
  -----------
  9pfs: handle walk of ".." in the root directory

The 9P spec at http://man.cat-v.org/plan_9/5/intro says:

All directories must support walks to the directory .. (dot-dot) meaning
parent directory, although by convention directories contain no explicit
entry for .. or . (dot).  The parent of the root directory of a server's
tree is itself.

This means that a client cannot walk further than the root directory
exported by the server. In other words, if the client wants to walk
"/.." or "/foo/../..", the server should answer like the request was
to walk "/".

This patch just does that:
- we cache the QID of the root directory at attach time
- during the walk we compare the QID of each path component with the root
  QID to detect if we're in a "/.." situation
- if so, we skip the current component and go to the next one

Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>


  Commit: 12d2c4184c5ab60be3428b2bdea5ae66e8d5d960
      
https://github.com/qemu/qemu/commit/12d2c4184c5ab60be3428b2bdea5ae66e8d5d960
  Author: Peter Maydell <address@hidden>
  Date:   2016-08-30 (Tue, 30 Aug 2016)

  Changed paths:
    M VERSION

  Log Message:
  -----------
  Update version for v2.7.0-rc5 release

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/2b294f6b65c7...12d2c4184c5a

reply via email to

[Prev in Thread] Current Thread [Next in Thread]