diff options
author | Tim Gardner <tim.gardner@canonical.com> | 2013-02-13 08:40:16 -0700 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-02-15 11:29:38 -0500 |
commit | f25cc71e634edcf8a15bc60a48f2b5f3ec9fbb1d (patch) | |
tree | b66f98dacd1c095dfded8ee673290230366dd8c8 /fs/lockd/clntlock.c | |
parent | deb4534f4f3be7aea7d9d24c3b0d58f370cbf9ef (diff) | |
download | kernel-common-f25cc71e634edcf8a15bc60a48f2b5f3ec9fbb1d.tar.gz kernel-common-f25cc71e634edcf8a15bc60a48f2b5f3ec9fbb1d.tar.bz2 kernel-common-f25cc71e634edcf8a15bc60a48f2b5f3ec9fbb1d.zip |
lockd: nlmclnt_reclaim(): avoid stack overflow
Even though nlmclnt_reclaim() is only one call into the stack frame,
928 bytes on the stack seems like a lot. Recode to dynamically
allocate the request structure once from within the reclaimer task,
then pass this pointer into nlmclnt_reclaim() for reuse on
subsequent calls.
smatch analysis:
fs/lockd/clntproc.c:620 nlmclnt_reclaim() warn: 'reqst' puts
928 bytes on stack
Also remove redundant assignment of 0 after memset.
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/lockd/clntlock.c')
-rw-r--r-- | fs/lockd/clntlock.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 4885b53e56bd..6cd673d34fb9 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c @@ -220,10 +220,19 @@ reclaimer(void *ptr) { struct nlm_host *host = (struct nlm_host *) ptr; struct nlm_wait *block; + struct nlm_rqst *req; struct file_lock *fl, *next; u32 nsmstate; struct net *net = host->net; + req = kmalloc(sizeof(*req), GFP_KERNEL); + if (!req) { + printk(KERN_ERR "lockd: reclaimer unable to alloc memory." + " Locks for %s won't be reclaimed!\n", + host->h_name); + return 0; + } + allow_signal(SIGKILL); down_write(&host->h_rwsem); @@ -253,7 +262,7 @@ restart: */ if (signalled()) continue; - if (nlmclnt_reclaim(host, fl) != 0) + if (nlmclnt_reclaim(host, fl, req) != 0) continue; list_add_tail(&fl->fl_u.nfs_fl.list, &host->h_granted); if (host->h_nsmstate != nsmstate) { @@ -279,5 +288,6 @@ restart: /* Release host handle after use */ nlmclnt_release_host(host); lockd_down(net); + kfree(req); return 0; } |