mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
nfsd: Fix id-to-name cache entry leak in idtoname_parse()
idtoname_lookup() returns the id-to-name cache entry with a new
reference. The name is parsed between the lookup and the update call,
and when the parsed name is malformed (negative length or longer than
IDMAP_NAMESZ), idtoname_parse() jumps to the error label without
dropping the reference returned by idtoname_lookup(), leaking the cache
entry.
Release the reference with cache_put() before taking the error exit.
Fixes: f9ecc921b5 ("[PATCH] knfsd: Use new cache code for name/id lookup caches")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260917163154.2162438-1-vulab@iscas.ac.cn
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
parent
f08cfa10c4
commit
8ca3b74c0c
|
|
@ -254,8 +254,10 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
|
|||
/* Name */
|
||||
error = -EINVAL;
|
||||
len = qword_get(&buf, buf1, PAGE_SIZE);
|
||||
if (len < 0 || len >= IDMAP_NAMESZ)
|
||||
if (len < 0 || len >= IDMAP_NAMESZ) {
|
||||
cache_put(&res->h, cd);
|
||||
goto out;
|
||||
}
|
||||
if (len == 0)
|
||||
set_bit(CACHE_NEGATIVE, &ent.h.flags);
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user