mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
lockd: fix NULL dereference on lockowner allocation failure
commit4c7fc129dbupstream. nlmclnt_locks_init_private() installs NLM file lock operations even when nlmclnt_find_lockowner() fails to allocate a lockowner. nlmclnt_proc() then returns -ENOMEM, but the VFS still tears down the partially initialized file_lock and calls locks_release_private(). That invokes nlmclnt_locks_release_private(), which dereferences fl->fl_u.nfs_fl.owner and crashes because the owner was never installed. Clear fl_ops before attempting to initialize the NLM private state, and install the NLM lock operations only after a lockowner has been allocated successfully. Fixes:1da177e4c3("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c24bdb7df2
commit
07adfbb3de
@@ -487,9 +487,12 @@ static const struct file_lock_operations nlmclnt_lock_ops = {
|
||||
static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host)
|
||||
{
|
||||
fl->fl_u.nfs_fl.state = 0;
|
||||
fl->fl_ops = NULL;
|
||||
fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host,
|
||||
fl->c.flc_owner);
|
||||
INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list);
|
||||
if (!fl->fl_u.nfs_fl.owner)
|
||||
return;
|
||||
fl->fl_ops = &nlmclnt_lock_ops;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user