9p: do not crash on unknown lock status code
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Mon, 29 Dec 2014 13:00:19 +0000 (15:00 +0200)
committerEric Van Hensbergen <ericvh@gmail.com>
Fri, 20 Mar 2015 14:34:41 +0000 (07:34 -0700)
Current 9p implementation will crash whole system if sees unknown lock
status code. It's trivial target for DOS: 9p server can produce such
code easily.

Let's fallback more gracefully: warning in dmesg + -ENOLCK.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
fs/9p/vfs_file.c

index 8d29e1e03dfa1d2fe75c7814458cdab2654131dc..9612e5fc0ae2416b53ac78168ab1bddd900b307d 100644 (file)
@@ -212,12 +212,13 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
        case P9_LOCK_BLOCKED:
                res = -EAGAIN;
                break;
+       default:
+               WARN_ONCE(1, "unknown lock status code: %d\n", status);
+               /* fallthough */
        case P9_LOCK_ERROR:
        case P9_LOCK_GRACE:
                res = -ENOLCK;
                break;
-       default:
-               BUG();
        }
 
 out_unlock: