From 7cdfa44227b0d8842d46a775cebe4311150cb8f2 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 25 Mar 2019 16:38:22 +0000 Subject: vfs: Fix refcounting of filenames in fs_parser 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 --- fs/fs_parser.c | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/fs_parser.c') diff --git a/fs/fs_parser.c b/fs/fs_parser.c index 570d71043acf..3a1697c2f72f 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -268,6 +268,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); -- cgit v1.2.3