Skip to content

Commit

Permalink
9p: do not crash on unknown lock status code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Dominique Martinet <[email protected]>
Signed-off-by: Eric Van Hensbergen <[email protected]>
  • Loading branch information
kiryl authored and ericvh committed Mar 20, 2015
1 parent ad80492 commit b642f72
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/9p/vfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b642f72

Please sign in to comment.