Skip to content

Commit

Permalink
vfs: Fix refcounting of filenames in fs_parser
Browse files Browse the repository at this point in the history
commit 7cdfa44 upstream.

Fix an overput in which filename_lookup() unconditionally drops a ref to
the filename it was given, but this isn't taken account of in the caller,
fs_lookup_param().

Addresses-Coverity-ID: 1443811 ("Use after free")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
David Howells authored and Greg Kroah-Hartman committed Sep 21, 2019
1 parent d4911cc commit 1243493
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/fs_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ int fs_lookup_param(struct fs_context *fc,
return invalf(fc, "%s: not usable as path", param->key);
}

f->refcnt++; /* filename_lookup() drops our ref. */
ret = filename_lookup(param->dirfd, f, flags, _path, NULL);
if (ret < 0) {
errorf(fc, "%s: Lookup failure for '%s'", param->key, f->name);
Expand Down

0 comments on commit 1243493

Please sign in to comment.