Skip to content

Commit 0b3974e

Browse files
author
Miklos Szeredi
committed
security: add flags to rename hooks
Add flags to security_path_rename() and security_inode_rename() hooks. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Reviewed-by: J. Bruce Fields <bfields@redhat.com>
1 parent 0a7c393 commit 0b3974e

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎fs/cachefiles/namei.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
391391
path.dentry = dir;
392392
path_to_graveyard.mnt = cache->mnt;
393393
path_to_graveyard.dentry = cache->graveyard;
394-
ret = security_path_rename(&path, rep, &path_to_graveyard, grave);
394+
ret = security_path_rename(&path, rep, &path_to_graveyard, grave, 0);
395395
if (ret < 0) {
396396
cachefiles_io_error(cache, "Rename security error %d", ret);
397397
} else {

‎fs/namei.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,7 +4062,8 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
40624062
return error;
40634063
}
40644064

4065-
error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry);
4065+
error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry,
4066+
flags);
40664067
if (error)
40674068
return error;
40684069

@@ -4217,7 +4218,7 @@ SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname,
42174218
goto exit5;
42184219

42194220
error = security_path_rename(&oldnd.path, old_dentry,
4220-
&newnd.path, new_dentry);
4221+
&newnd.path, new_dentry, flags);
42214222
if (error)
42224223
goto exit5;
42234224
error = vfs_rename(old_dir->d_inode, old_dentry,

‎include/linux/security.h‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,8 @@ int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
17931793
int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
17941794
int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
17951795
int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1796-
struct inode *new_dir, struct dentry *new_dentry);
1796+
struct inode *new_dir, struct dentry *new_dentry,
1797+
unsigned int flags);
17971798
int security_inode_readlink(struct dentry *dentry);
17981799
int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
17991800
int security_inode_permission(struct inode *inode, int mask);
@@ -2161,7 +2162,8 @@ static inline int security_inode_mknod(struct inode *dir,
21612162
static inline int security_inode_rename(struct inode *old_dir,
21622163
struct dentry *old_dentry,
21632164
struct inode *new_dir,
2164-
struct dentry *new_dentry)
2165+
struct dentry *new_dentry,
2166+
unsigned int flags)
21652167
{
21662168
return 0;
21672169
}
@@ -2955,7 +2957,8 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
29552957
int security_path_link(struct dentry *old_dentry, struct path *new_dir,
29562958
struct dentry *new_dentry);
29572959
int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
2958-
struct path *new_dir, struct dentry *new_dentry);
2960+
struct path *new_dir, struct dentry *new_dentry,
2961+
unsigned int flags);
29592962
int security_path_chmod(struct path *path, umode_t mode);
29602963
int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
29612964
int security_path_chroot(struct path *path);
@@ -3003,7 +3006,8 @@ static inline int security_path_link(struct dentry *old_dentry,
30033006
static inline int security_path_rename(struct path *old_dir,
30043007
struct dentry *old_dentry,
30053008
struct path *new_dir,
3006-
struct dentry *new_dentry)
3009+
struct dentry *new_dentry,
3010+
unsigned int flags)
30073011
{
30083012
return 0;
30093013
}

‎security/security.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
433433
}
434434

435435
int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
436-
struct path *new_dir, struct dentry *new_dentry)
436+
struct path *new_dir, struct dentry *new_dentry,
437+
unsigned int flags)
437438
{
438439
if (unlikely(IS_PRIVATE(old_dentry->d_inode) ||
439440
(new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode))))
@@ -524,7 +525,8 @@ int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
524525
}
525526

526527
int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
527-
struct inode *new_dir, struct dentry *new_dentry)
528+
struct inode *new_dir, struct dentry *new_dentry,
529+
unsigned int flags)
528530
{
529531
if (unlikely(IS_PRIVATE(old_dentry->d_inode) ||
530532
(new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode))))

0 commit comments

Comments
 (0)