Skip to content

Commit cdf8c58

Browse files
committed
userns: Convert ecryptfs to use kuid/kgid where appropriate
Cc: Tyler Hicks <tyhicks@canonical.com> Cc: Dustin Kirkland <dustin.kirkland@gazzang.com> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
1 parent a7d9cfe commit cdf8c58

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎fs/ecryptfs/main.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,12 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
544544
goto out_free;
545545
}
546546

547-
if (check_ruid && path.dentry->d_inode->i_uid != current_uid()) {
547+
if (check_ruid && !uid_eq(path.dentry->d_inode->i_uid, current_uid())) {
548548
rc = -EPERM;
549549
printk(KERN_ERR "Mount of device (uid: %d) not owned by "
550550
"requested user (uid: %d)\n",
551-
path.dentry->d_inode->i_uid, current_uid());
551+
i_uid_read(path.dentry->d_inode),
552+
from_kuid(&init_user_ns, current_uid()));
552553
goto out_free;
553554
}
554555

‎fs/ecryptfs/messaging.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static struct hlist_head *ecryptfs_daemon_hash;
3333
struct mutex ecryptfs_daemon_hash_mux;
3434
static int ecryptfs_hash_bits;
3535
#define ecryptfs_current_euid_hash(uid) \
36-
hash_long((unsigned long)current_euid(), ecryptfs_hash_bits)
36+
hash_long((unsigned long)from_kuid(&init_user_ns, current_euid()), ecryptfs_hash_bits)
3737

3838
static u32 ecryptfs_msg_counter;
3939
static struct ecryptfs_msg_ctx *ecryptfs_msg_ctx_arr;
@@ -121,8 +121,7 @@ int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon)
121121
hlist_for_each_entry(*daemon, elem,
122122
&ecryptfs_daemon_hash[ecryptfs_current_euid_hash()],
123123
euid_chain) {
124-
if ((*daemon)->file->f_cred->euid == current_euid() &&
125-
(*daemon)->file->f_cred->user_ns == current_user_ns()) {
124+
if (uid_eq((*daemon)->file->f_cred->euid, current_euid())) {
126125
rc = 0;
127126
goto out;
128127
}

‎init/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,6 @@ config UIDGID_CONVERTED
941941
depends on CEPH_FS = n
942942
depends on CIFS = n
943943
depends on CODA_FS = n
944-
depends on ECRYPT_FS = n
945944
depends on EFS_FS = n
946945
depends on EXOFS_FS = n
947946
depends on FUSE_FS = n

0 commit comments

Comments
 (0)