diff --git a/debian/changelog b/debian/changelog index d1ee5c16c..5513b9516 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,11 @@ linux-2.6 (3.2.16-1) UNRELEASED; urgency=low * rt2x00: Identify rt2800usb chipsets. (Closes: #658067) * [x86] Add EFI boot stub support (Closes: #669033) * brcmsmac: "INTERMEDIATE but not AMPDU" only when tracing + * NFSv4: Fix error handling and improve error reporting for file locking + (Closes: #669270) + - Rate limit the state manager for lock reclaim warning messages + - Ensure that the LOCK code sets exception->inode + - Ensure that we check lock exclusive/shared type against open modes -- Ben Hutchings Mon, 16 Apr 2012 02:27:29 +0100 diff --git a/debian/patches/bugfix/all/NFSv4-Ensure-that-the-LOCK-code-sets-exception-inode.patch b/debian/patches/bugfix/all/NFSv4-Ensure-that-the-LOCK-code-sets-exception-inode.patch new file mode 100644 index 000000000..6a9e5b9d5 --- /dev/null +++ b/debian/patches/bugfix/all/NFSv4-Ensure-that-the-LOCK-code-sets-exception-inode.patch @@ -0,0 +1,52 @@ +From: Trond Myklebust +Date: Wed, 18 Apr 2012 12:20:10 -0400 +Subject: [PATCH 1/2] NFSv4: Ensure that the LOCK code sets exception->inode + +commit 05ffe24f5290dc095f98fbaf84afe51ef404ccc5 upstream. + +All callers of nfs4_handle_exception() that need to handle +NFS4ERR_OPENMODE correctly should set exception->inode + +Signed-off-by: Trond Myklebust +Cc: stable@vger.kernel.org +--- + fs/nfs/nfs4proc.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index f82bde0..3c787d0 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -4558,7 +4558,9 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f + static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) + { + struct nfs_server *server = NFS_SERVER(state->inode); +- struct nfs4_exception exception = { }; ++ struct nfs4_exception exception = { ++ .inode = state->inode, ++ }; + int err; + + do { +@@ -4576,7 +4578,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request + static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) + { + struct nfs_server *server = NFS_SERVER(state->inode); +- struct nfs4_exception exception = { }; ++ struct nfs4_exception exception = { ++ .inode = state->inode, ++ }; + int err; + + err = nfs4_set_lock_state(state, request); +@@ -4676,6 +4680,7 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock * + { + struct nfs4_exception exception = { + .state = state, ++ .inode = state->inode, + }; + int err; + +-- +1.7.10 + diff --git a/debian/patches/bugfix/all/NFSv4-Ensure-that-we-check-lock-exclusive-shared-typ.patch b/debian/patches/bugfix/all/NFSv4-Ensure-that-we-check-lock-exclusive-shared-typ.patch new file mode 100644 index 000000000..8eda0d139 --- /dev/null +++ b/debian/patches/bugfix/all/NFSv4-Ensure-that-we-check-lock-exclusive-shared-typ.patch @@ -0,0 +1,44 @@ +From: Trond Myklebust +Date: Wed, 18 Apr 2012 12:48:35 -0400 +Subject: [PATCH 2/2] NFSv4: Ensure that we check lock exclusive/shared type + against open modes + +commit 55725513b5ef9d462aa3e18527658a0362aaae83 upstream. + +Since we may be simulating flock() locks using NFS byte range locks, +we can't rely on the VFS having checked the file open mode for us. + +Signed-off-by: Trond Myklebust +Cc: stable@vger.kernel.org +--- + fs/nfs/nfs4proc.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index 3c787d0..ba837d9 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -4726,6 +4726,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) + + if (state == NULL) + return -ENOLCK; ++ /* ++ * Don't rely on the VFS having checked the file open mode, ++ * since it won't do this for flock() locks. ++ */ ++ switch (request->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) { ++ case F_RDLCK: ++ if (!(filp->f_mode & FMODE_READ)) ++ return -EBADF; ++ break; ++ case F_WRLCK: ++ if (!(filp->f_mode & FMODE_WRITE)) ++ return -EBADF; ++ } ++ + do { + status = nfs4_proc_setlk(state, cmd, request); + if ((status != -EAGAIN) || IS_SETLK(cmd)) +-- +1.7.10 + diff --git a/debian/patches/bugfix/all/NFSv4-Rate-limit-the-state-manager-for-lock-reclaim-.patch b/debian/patches/bugfix/all/NFSv4-Rate-limit-the-state-manager-for-lock-reclaim-.patch new file mode 100644 index 000000000..972e21eb0 --- /dev/null +++ b/debian/patches/bugfix/all/NFSv4-Rate-limit-the-state-manager-for-lock-reclaim-.patch @@ -0,0 +1,28 @@ +From: William Dauchy +Date: Wed, 14 Mar 2012 12:32:04 +0100 +Subject: [PATCH] NFSv4: Rate limit the state manager for lock reclaim warning + messages + +commit 96dcadc2fdd111dca90d559f189a30c65394451a upstream. + +Adding rate limit on `Lock reclaim failed` messages since it could fill +up system logs +Signed-off-by: William Dauchy +Signed-off-by: Trond Myklebust +[bwh: Backported to 3.2: add the 'NFS:' prefix at the same time] +Signed-off-by: Ben Hutchings +--- +--- a/fs/nfs/nfs4state.c ++++ b/fs/nfs/nfs4state.c +@@ -1261,8 +1261,9 @@ restart: + spin_lock(&state->state_lock); + list_for_each_entry(lock, &state->lock_states, ls_locks) { + if (!(lock->ls_flags & NFS_LOCK_INITIALIZED)) +- printk("%s: Lock reclaim failed!\n", +- __func__); ++ pr_warn_ratelimited("NFS: " ++ "%s: Lock reclaim " ++ "failed!\n", __func__); + } + spin_unlock(&state->state_lock); + nfs4_put_open_state(state); diff --git a/debian/patches/series/base b/debian/patches/series/base index 0a5f10d67..0ae8e9261 100644 --- a/debian/patches/series/base +++ b/debian/patches/series/base @@ -184,3 +184,6 @@ + features/x86/efi-stub/0010-x86-efi-Break-up-large-initrd-reads.patch + features/x86/efi-stub/0011-x86-efi-Fix-pointer-math-issue-in-handle_ramdisks.patch + bugfix/all/brcmsmac-INTERMEDIATE-but-not-AMPDU-only-when-tracin.patch ++ bugfix/all/NFSv4-Rate-limit-the-state-manager-for-lock-reclaim-.patch ++ bugfix/all/NFSv4-Ensure-that-the-LOCK-code-sets-exception-inode.patch ++ bugfix/all/NFSv4-Ensure-that-we-check-lock-exclusive-shared-typ.patch