mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
cachefiles: use path_get instead of lone dget
Dentry references should not be acquired without a corresponding vfsmount ref. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Acked-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
6d0b5456e1
commit
542ce7a9bc
@ -553,7 +553,7 @@ static int cachefiles_daemon_tag(struct cachefiles_cache *cache, char *args)
|
|||||||
static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
|
static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
|
||||||
{
|
{
|
||||||
struct fs_struct *fs;
|
struct fs_struct *fs;
|
||||||
struct dentry *dir;
|
struct path path;
|
||||||
const struct cred *saved_cred;
|
const struct cred *saved_cred;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -575,22 +575,23 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
|
|||||||
/* extract the directory dentry from the cwd */
|
/* extract the directory dentry from the cwd */
|
||||||
fs = current->fs;
|
fs = current->fs;
|
||||||
read_lock(&fs->lock);
|
read_lock(&fs->lock);
|
||||||
dir = dget(fs->pwd.dentry);
|
path = fs->pwd;
|
||||||
|
path_get(&path);
|
||||||
read_unlock(&fs->lock);
|
read_unlock(&fs->lock);
|
||||||
|
|
||||||
if (!S_ISDIR(dir->d_inode->i_mode))
|
if (!S_ISDIR(path.dentry->d_inode->i_mode))
|
||||||
goto notdir;
|
goto notdir;
|
||||||
|
|
||||||
cachefiles_begin_secure(cache, &saved_cred);
|
cachefiles_begin_secure(cache, &saved_cred);
|
||||||
ret = cachefiles_cull(cache, dir, args);
|
ret = cachefiles_cull(cache, path.dentry, args);
|
||||||
cachefiles_end_secure(cache, saved_cred);
|
cachefiles_end_secure(cache, saved_cred);
|
||||||
|
|
||||||
dput(dir);
|
path_put(&path);
|
||||||
_leave(" = %d", ret);
|
_leave(" = %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
notdir:
|
notdir:
|
||||||
dput(dir);
|
path_put(&path);
|
||||||
kerror("cull command requires dirfd to be a directory");
|
kerror("cull command requires dirfd to be a directory");
|
||||||
return -ENOTDIR;
|
return -ENOTDIR;
|
||||||
|
|
||||||
@ -629,7 +630,7 @@ inval:
|
|||||||
static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
|
static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
|
||||||
{
|
{
|
||||||
struct fs_struct *fs;
|
struct fs_struct *fs;
|
||||||
struct dentry *dir;
|
struct path path;
|
||||||
const struct cred *saved_cred;
|
const struct cred *saved_cred;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -651,22 +652,23 @@ static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
|
|||||||
/* extract the directory dentry from the cwd */
|
/* extract the directory dentry from the cwd */
|
||||||
fs = current->fs;
|
fs = current->fs;
|
||||||
read_lock(&fs->lock);
|
read_lock(&fs->lock);
|
||||||
dir = dget(fs->pwd.dentry);
|
path = fs->pwd;
|
||||||
|
path_get(&path);
|
||||||
read_unlock(&fs->lock);
|
read_unlock(&fs->lock);
|
||||||
|
|
||||||
if (!S_ISDIR(dir->d_inode->i_mode))
|
if (!S_ISDIR(path.dentry->d_inode->i_mode))
|
||||||
goto notdir;
|
goto notdir;
|
||||||
|
|
||||||
cachefiles_begin_secure(cache, &saved_cred);
|
cachefiles_begin_secure(cache, &saved_cred);
|
||||||
ret = cachefiles_check_in_use(cache, dir, args);
|
ret = cachefiles_check_in_use(cache, path.dentry, args);
|
||||||
cachefiles_end_secure(cache, saved_cred);
|
cachefiles_end_secure(cache, saved_cred);
|
||||||
|
|
||||||
dput(dir);
|
path_put(&path);
|
||||||
//_leave(" = %d", ret);
|
//_leave(" = %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
notdir:
|
notdir:
|
||||||
dput(dir);
|
path_put(&path);
|
||||||
kerror("inuse command requires dirfd to be a directory");
|
kerror("inuse command requires dirfd to be a directory");
|
||||||
return -ENOTDIR;
|
return -ENOTDIR;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user