Browse Source

9p: do not crash on unknown lock status code

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>
Kirill A. Shutemov 10 years ago
parent
commit
b642f7269b
1 changed files with 3 additions and 2 deletions
  1. 3 2
      fs/9p/vfs_file.c

+ 3 - 2
fs/9p/vfs_file.c

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