forked from Minki/linux
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull user namespace changes from Eric Biederman: "This is a mostly modest set of changes to enable basic user namespace support. This allows the code to code to compile with user namespaces enabled and removes the assumption there is only the initial user namespace. Everything is converted except for the most complex of the filesystems: autofs4, 9p, afs, ceph, cifs, coda, fuse, gfs2, ncpfs, nfs, ocfs2 and xfs as those patches need a bit more review. The strategy is to push kuid_t and kgid_t values are far down into subsystems and filesystems as reasonable. Leaving the make_kuid and from_kuid operations to happen at the edge of userspace, as the values come off the disk, and as the values come in from the network. Letting compile type incompatible compile errors (present when user namespaces are enabled) guide me to find the issues. The most tricky areas have been the places where we had an implicit union of uid and gid values and were storing them in an unsigned int. Those places were converted into explicit unions. I made certain to handle those places with simple trivial patches. Out of that work I discovered we have generic interfaces for storing quota by projid. I had never heard of the project identifiers before. Adding full user namespace support for project identifiers accounts for most of the code size growth in my git tree. Ultimately there will be work to relax privlige checks from "capable(FOO)" to "ns_capable(user_ns, FOO)" where it is safe allowing root in a user names to do those things that today we only forbid to non-root users because it will confuse suid root applications. While I was pushing kuid_t and kgid_t changes deep into the audit code I made a few other cleanups. I capitalized on the fact we process netlink messages in the context of the message sender. I removed usage of NETLINK_CRED, and started directly using current->tty. Some of these patches have also made it into maintainer trees, with no problems from identical code from different trees showing up in linux-next. After reading through all of this code I feel like I might be able to win a game of kernel trivial pursuit." Fix up some fairly trivial conflicts in netfilter uid/git logging code. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (107 commits) userns: Convert the ufs filesystem to use kuid/kgid where appropriate userns: Convert the udf filesystem to use kuid/kgid where appropriate userns: Convert ubifs to use kuid/kgid userns: Convert squashfs to use kuid/kgid where appropriate userns: Convert reiserfs to use kuid and kgid where appropriate userns: Convert jfs to use kuid/kgid where appropriate userns: Convert jffs2 to use kuid and kgid where appropriate userns: Convert hpfs to use kuid and kgid where appropriate userns: Convert btrfs to use kuid/kgid where appropriate userns: Convert bfs to use kuid/kgid where appropriate userns: Convert affs to use kuid/kgid wherwe appropriate userns: On alpha modify linux_to_osf_stat to use convert from kuids and kgids userns: On ia64 deal with current_uid and current_gid being kuid and kgid userns: On ppc convert current_uid from a kuid before printing. userns: Convert s390 getting uid and gid system calls to use kuid and kgid userns: Convert s390 hypfs to use kuid and kgid where appropriate userns: Convert binder ipc to use kuids userns: Teach security_path_chown to take kuids and kgids userns: Add user namespace support to IMA userns: Convert EVM to deal with kuids and kgids in it's hmac computation ...
This commit is contained in:
commit
437589a74b
@ -278,8 +278,8 @@ linux_to_osf_stat(struct kstat *lstat, struct osf_stat __user *osf_stat)
|
||||
tmp.st_dev = lstat->dev;
|
||||
tmp.st_mode = lstat->mode;
|
||||
tmp.st_nlink = lstat->nlink;
|
||||
tmp.st_uid = lstat->uid;
|
||||
tmp.st_gid = lstat->gid;
|
||||
tmp.st_uid = from_kuid_munged(current_user_ns(), lstat->uid);
|
||||
tmp.st_gid = from_kgid_munged(current_user_ns(), lstat->gid);
|
||||
tmp.st_rdev = lstat->rdev;
|
||||
tmp.st_ldev = lstat->rdev;
|
||||
tmp.st_size = lstat->size;
|
||||
|
@ -158,7 +158,8 @@ mca_handler_bh(unsigned long paddr, void *iip, unsigned long ipsr)
|
||||
ia64_mlogbuf_dump();
|
||||
printk(KERN_ERR "OS_MCA: process [cpu %d, pid: %d, uid: %d, "
|
||||
"iip: %p, psr: 0x%lx,paddr: 0x%lx](%s) encounters MCA.\n",
|
||||
raw_smp_processor_id(), current->pid, current_uid(),
|
||||
raw_smp_processor_id(), current->pid,
|
||||
from_kuid(&init_user_ns, current_uid()),
|
||||
iip, ipsr, paddr, current->comm);
|
||||
|
||||
spin_lock(&mca_bh_lock);
|
||||
|
@ -2380,8 +2380,8 @@ static int
|
||||
pfm_bad_permissions(struct task_struct *task)
|
||||
{
|
||||
const struct cred *tcred;
|
||||
uid_t uid = current_uid();
|
||||
gid_t gid = current_gid();
|
||||
kuid_t uid = current_uid();
|
||||
kgid_t gid = current_gid();
|
||||
int ret;
|
||||
|
||||
rcu_read_lock();
|
||||
@ -2389,20 +2389,20 @@ pfm_bad_permissions(struct task_struct *task)
|
||||
|
||||
/* inspired by ptrace_attach() */
|
||||
DPRINT(("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n",
|
||||
uid,
|
||||
gid,
|
||||
tcred->euid,
|
||||
tcred->suid,
|
||||
tcred->uid,
|
||||
tcred->egid,
|
||||
tcred->sgid));
|
||||
from_kuid(&init_user_ns, uid),
|
||||
from_kgid(&init_user_ns, gid),
|
||||
from_kuid(&init_user_ns, tcred->euid),
|
||||
from_kuid(&init_user_ns, tcred->suid),
|
||||
from_kuid(&init_user_ns, tcred->uid),
|
||||
from_kgid(&init_user_ns, tcred->egid),
|
||||
from_kgid(&init_user_ns, tcred->sgid)));
|
||||
|
||||
ret = ((uid != tcred->euid)
|
||||
|| (uid != tcred->suid)
|
||||
|| (uid != tcred->uid)
|
||||
|| (gid != tcred->egid)
|
||||
|| (gid != tcred->sgid)
|
||||
|| (gid != tcred->gid)) && !capable(CAP_SYS_PTRACE);
|
||||
ret = ((!uid_eq(uid, tcred->euid))
|
||||
|| (!uid_eq(uid, tcred->suid))
|
||||
|| (!uid_eq(uid, tcred->uid))
|
||||
|| (!gid_eq(gid, tcred->egid))
|
||||
|| (!gid_eq(gid, tcred->sgid))
|
||||
|| (!gid_eq(gid, tcred->gid))) && !capable(CAP_SYS_PTRACE);
|
||||
|
||||
rcu_read_unlock();
|
||||
return ret;
|
||||
|
@ -220,7 +220,7 @@ ia64_rt_sigreturn (struct sigscratch *scr)
|
||||
si.si_errno = 0;
|
||||
si.si_code = SI_KERNEL;
|
||||
si.si_pid = task_pid_vnr(current);
|
||||
si.si_uid = current_uid();
|
||||
si.si_uid = from_kuid_munged(current_user_ns(), current_uid());
|
||||
si.si_addr = sc;
|
||||
force_sig_info(SIGSEGV, &si, current);
|
||||
return retval;
|
||||
@ -317,7 +317,7 @@ force_sigsegv_info (int sig, void __user *addr)
|
||||
si.si_errno = 0;
|
||||
si.si_code = SI_KERNEL;
|
||||
si.si_pid = task_pid_vnr(current);
|
||||
si.si_uid = current_uid();
|
||||
si.si_uid = from_kuid_munged(current_user_ns(), current_uid());
|
||||
si.si_addr = addr;
|
||||
force_sig_info(SIGSEGV, &si, current);
|
||||
return 0;
|
||||
|
@ -470,7 +470,7 @@ bad_area_nosemaphore:
|
||||
if (is_exec && (error_code & DSISR_PROTFAULT))
|
||||
printk_ratelimited(KERN_CRIT "kernel tried to execute NX-protected"
|
||||
" page (%lx) - exploit attempt? (uid: %d)\n",
|
||||
address, current_uid());
|
||||
address, from_kuid(&init_user_ns, current_uid()));
|
||||
|
||||
return SIGSEGV;
|
||||
|
||||
|
@ -31,8 +31,8 @@ static struct dentry *hypfs_create_update_file(struct super_block *sb,
|
||||
struct dentry *dir);
|
||||
|
||||
struct hypfs_sb_info {
|
||||
uid_t uid; /* uid used for files and dirs */
|
||||
gid_t gid; /* gid used for files and dirs */
|
||||
kuid_t uid; /* uid used for files and dirs */
|
||||
kgid_t gid; /* gid used for files and dirs */
|
||||
struct dentry *update_file; /* file to trigger update */
|
||||
time_t last_update; /* last update time in secs since 1970 */
|
||||
struct mutex lock; /* lock to protect update process */
|
||||
@ -229,6 +229,8 @@ static int hypfs_parse_options(char *options, struct super_block *sb)
|
||||
{
|
||||
char *str;
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
|
||||
if (!options)
|
||||
return 0;
|
||||
@ -243,12 +245,18 @@ static int hypfs_parse_options(char *options, struct super_block *sb)
|
||||
case opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
return -EINVAL;
|
||||
hypfs_info->uid = option;
|
||||
uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(uid))
|
||||
return -EINVAL;
|
||||
hypfs_info->uid = uid;
|
||||
break;
|
||||
case opt_gid:
|
||||
if (match_int(&args[0], &option))
|
||||
return -EINVAL;
|
||||
hypfs_info->gid = option;
|
||||
gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(gid))
|
||||
return -EINVAL;
|
||||
hypfs_info->gid = gid;
|
||||
break;
|
||||
case opt_err:
|
||||
default:
|
||||
@ -263,8 +271,8 @@ static int hypfs_show_options(struct seq_file *s, struct dentry *root)
|
||||
{
|
||||
struct hypfs_sb_info *hypfs_info = root->d_sb->s_fs_info;
|
||||
|
||||
seq_printf(s, ",uid=%u", hypfs_info->uid);
|
||||
seq_printf(s, ",gid=%u", hypfs_info->gid);
|
||||
seq_printf(s, ",uid=%u", from_kuid_munged(&init_user_ns, hypfs_info->uid));
|
||||
seq_printf(s, ",gid=%u", from_kgid_munged(&init_user_ns, hypfs_info->gid));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -131,13 +131,19 @@ asmlinkage long sys32_setresuid16(u16 ruid, u16 euid, u16 suid)
|
||||
low2highuid(suid));
|
||||
}
|
||||
|
||||
asmlinkage long sys32_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user *suid)
|
||||
asmlinkage long sys32_getresuid16(u16 __user *ruidp, u16 __user *euidp, u16 __user *suidp)
|
||||
{
|
||||
const struct cred *cred = current_cred();
|
||||
int retval;
|
||||
u16 ruid, euid, suid;
|
||||
|
||||
if (!(retval = put_user(high2lowuid(current->cred->uid), ruid)) &&
|
||||
!(retval = put_user(high2lowuid(current->cred->euid), euid)))
|
||||
retval = put_user(high2lowuid(current->cred->suid), suid);
|
||||
ruid = high2lowuid(from_kuid_munged(cred->user_ns, cred->uid));
|
||||
euid = high2lowuid(from_kuid_munged(cred->user_ns, cred->euid));
|
||||
suid = high2lowuid(from_kuid_munged(cred->user_ns, cred->suid));
|
||||
|
||||
if (!(retval = put_user(ruid, ruidp)) &&
|
||||
!(retval = put_user(euid, euidp)))
|
||||
retval = put_user(suid, suidp);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -148,13 +154,19 @@ asmlinkage long sys32_setresgid16(u16 rgid, u16 egid, u16 sgid)
|
||||
low2highgid(sgid));
|
||||
}
|
||||
|
||||
asmlinkage long sys32_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
|
||||
asmlinkage long sys32_getresgid16(u16 __user *rgidp, u16 __user *egidp, u16 __user *sgidp)
|
||||
{
|
||||
const struct cred *cred = current_cred();
|
||||
int retval;
|
||||
u16 rgid, egid, sgid;
|
||||
|
||||
if (!(retval = put_user(high2lowgid(current->cred->gid), rgid)) &&
|
||||
!(retval = put_user(high2lowgid(current->cred->egid), egid)))
|
||||
retval = put_user(high2lowgid(current->cred->sgid), sgid);
|
||||
rgid = high2lowgid(from_kgid_munged(cred->user_ns, cred->gid));
|
||||
egid = high2lowgid(from_kgid_munged(cred->user_ns, cred->egid));
|
||||
sgid = high2lowgid(from_kgid_munged(cred->user_ns, cred->sgid));
|
||||
|
||||
if (!(retval = put_user(rgid, rgidp)) &&
|
||||
!(retval = put_user(egid, egidp)))
|
||||
retval = put_user(sgid, sgidp);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -258,22 +270,22 @@ asmlinkage long sys32_setgroups16(int gidsetsize, u16 __user *grouplist)
|
||||
|
||||
asmlinkage long sys32_getuid16(void)
|
||||
{
|
||||
return high2lowuid(current->cred->uid);
|
||||
return high2lowuid(from_kuid_munged(current_user_ns(), current_uid()));
|
||||
}
|
||||
|
||||
asmlinkage long sys32_geteuid16(void)
|
||||
{
|
||||
return high2lowuid(current->cred->euid);
|
||||
return high2lowuid(from_kuid_munged(current_user_ns(), current_euid()));
|
||||
}
|
||||
|
||||
asmlinkage long sys32_getgid16(void)
|
||||
{
|
||||
return high2lowgid(current->cred->gid);
|
||||
return high2lowgid(from_kgid_munged(current_user_ns(), current_gid()));
|
||||
}
|
||||
|
||||
asmlinkage long sys32_getegid16(void)
|
||||
{
|
||||
return high2lowgid(current->cred->egid);
|
||||
return high2lowgid(from_kgid_munged(current_user_ns(), current_egid()));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -309,8 +309,8 @@ static int handle_remove(const char *nodename, struct device *dev)
|
||||
* before unlinking this node, reset permissions
|
||||
* of possible references like hardlinks
|
||||
*/
|
||||
newattrs.ia_uid = 0;
|
||||
newattrs.ia_gid = 0;
|
||||
newattrs.ia_uid = GLOBAL_ROOT_UID;
|
||||
newattrs.ia_gid = GLOBAL_ROOT_GID;
|
||||
newattrs.ia_mode = stat.mode & ~0777;
|
||||
newattrs.ia_valid =
|
||||
ATTR_UID|ATTR_GID|ATTR_MODE;
|
||||
|
@ -1038,10 +1038,10 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
|
||||
{
|
||||
int err;
|
||||
struct loop_func_table *xfer;
|
||||
uid_t uid = current_uid();
|
||||
kuid_t uid = current_uid();
|
||||
|
||||
if (lo->lo_encrypt_key_size &&
|
||||
lo->lo_key_owner != uid &&
|
||||
!uid_eq(lo->lo_key_owner, uid) &&
|
||||
!capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
if (lo->lo_state != Lo_bound)
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/pid_namespace.h>
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
@ -127,11 +128,11 @@ void proc_id_connector(struct task_struct *task, int which_id)
|
||||
rcu_read_lock();
|
||||
cred = __task_cred(task);
|
||||
if (which_id == PROC_EVENT_UID) {
|
||||
ev->event_data.id.r.ruid = cred->uid;
|
||||
ev->event_data.id.e.euid = cred->euid;
|
||||
ev->event_data.id.r.ruid = from_kuid_munged(&init_user_ns, cred->uid);
|
||||
ev->event_data.id.e.euid = from_kuid_munged(&init_user_ns, cred->euid);
|
||||
} else if (which_id == PROC_EVENT_GID) {
|
||||
ev->event_data.id.r.rgid = cred->gid;
|
||||
ev->event_data.id.e.egid = cred->egid;
|
||||
ev->event_data.id.r.rgid = from_kgid_munged(&init_user_ns, cred->gid);
|
||||
ev->event_data.id.e.egid = from_kgid_munged(&init_user_ns, cred->egid);
|
||||
} else {
|
||||
rcu_read_unlock();
|
||||
return;
|
||||
@ -303,6 +304,15 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
|
||||
if (msg->len != sizeof(*mc_op))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Events are reported with respect to the initial pid
|
||||
* and user namespaces so ignore requestors from
|
||||
* other namespaces.
|
||||
*/
|
||||
if ((current_user_ns() != &init_user_ns) ||
|
||||
(task_active_pid_ns(current) != &init_pid_ns))
|
||||
return;
|
||||
|
||||
mc_op = (enum proc_cn_mcast_op *)msg->data;
|
||||
switch (*mc_op) {
|
||||
case PROC_CN_MCAST_LISTEN:
|
||||
|
@ -251,7 +251,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
|
||||
filp->private_data = priv;
|
||||
priv->filp = filp;
|
||||
priv->uid = current_euid();
|
||||
priv->pid = task_pid_nr(current);
|
||||
priv->pid = get_pid(task_pid(current));
|
||||
priv->minor = idr_find(&drm_minors_idr, minor_id);
|
||||
priv->ioctl_count = 0;
|
||||
/* for compatibility root is always authenticated */
|
||||
@ -524,6 +524,7 @@ int drm_release(struct inode *inode, struct file *filp)
|
||||
if (drm_core_check_feature(dev, DRIVER_PRIME))
|
||||
drm_prime_destroy_file_private(&file_priv->prime);
|
||||
|
||||
put_pid(file_priv->pid);
|
||||
kfree(file_priv);
|
||||
|
||||
/* ========================================================
|
||||
|
@ -191,8 +191,9 @@ int drm_clients_info(struct seq_file *m, void *data)
|
||||
seq_printf(m, "%c %3d %5d %5d %10u %10lu\n",
|
||||
priv->authenticated ? 'y' : 'n',
|
||||
priv->minor->index,
|
||||
priv->pid,
|
||||
priv->uid, priv->magic, priv->ioctl_count);
|
||||
pid_vnr(priv->pid),
|
||||
from_kuid_munged(seq_user_ns(m), priv->uid),
|
||||
priv->magic, priv->ioctl_count);
|
||||
}
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
return 0;
|
||||
|
@ -215,8 +215,8 @@ int drm_getclient(struct drm_device *dev, void *data,
|
||||
list_for_each_entry(pt, &dev->filelist, lhead) {
|
||||
if (i++ >= idx) {
|
||||
client->auth = pt->authenticated;
|
||||
client->pid = pt->pid;
|
||||
client->uid = pt->uid;
|
||||
client->pid = pid_vnr(pt->pid);
|
||||
client->uid = from_kuid_munged(current_user_ns(), pt->uid);
|
||||
client->magic = pt->magic;
|
||||
client->iocs = pt->ioctl_count;
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
|
@ -61,8 +61,8 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
inode->i_ino = get_next_ino();
|
||||
inode->i_mode = mode;
|
||||
inode->i_uid = 0;
|
||||
inode->i_gid = 0;
|
||||
inode->i_uid = GLOBAL_ROOT_UID;
|
||||
inode->i_gid = GLOBAL_ROOT_GID;
|
||||
inode->i_blocks = 0;
|
||||
inode->i_atime = CURRENT_TIME;
|
||||
inode->i_mtime = inode->i_atime;
|
||||
|
@ -121,8 +121,8 @@ struct tun_sock;
|
||||
struct tun_struct {
|
||||
struct tun_file *tfile;
|
||||
unsigned int flags;
|
||||
uid_t owner;
|
||||
gid_t group;
|
||||
kuid_t owner;
|
||||
kgid_t group;
|
||||
|
||||
struct net_device *dev;
|
||||
netdev_features_t set_features;
|
||||
@ -1032,8 +1032,8 @@ static void tun_setup(struct net_device *dev)
|
||||
{
|
||||
struct tun_struct *tun = netdev_priv(dev);
|
||||
|
||||
tun->owner = -1;
|
||||
tun->group = -1;
|
||||
tun->owner = INVALID_UID;
|
||||
tun->group = INVALID_GID;
|
||||
|
||||
dev->ethtool_ops = &tun_ethtool_ops;
|
||||
dev->destructor = tun_free_netdev;
|
||||
@ -1156,14 +1156,20 @@ static ssize_t tun_show_owner(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct tun_struct *tun = netdev_priv(to_net_dev(dev));
|
||||
return sprintf(buf, "%d\n", tun->owner);
|
||||
return uid_valid(tun->owner)?
|
||||
sprintf(buf, "%u\n",
|
||||
from_kuid_munged(current_user_ns(), tun->owner)):
|
||||
sprintf(buf, "-1\n");
|
||||
}
|
||||
|
||||
static ssize_t tun_show_group(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct tun_struct *tun = netdev_priv(to_net_dev(dev));
|
||||
return sprintf(buf, "%d\n", tun->group);
|
||||
return gid_valid(tun->group) ?
|
||||
sprintf(buf, "%u\n",
|
||||
from_kgid_munged(current_user_ns(), tun->group)):
|
||||
sprintf(buf, "-1\n");
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(tun_flags, 0444, tun_show_flags, NULL);
|
||||
@ -1190,8 +1196,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
if (((tun->owner != -1 && cred->euid != tun->owner) ||
|
||||
(tun->group != -1 && !in_egroup_p(tun->group))) &&
|
||||
if (((uid_valid(tun->owner) && !uid_eq(cred->euid, tun->owner)) ||
|
||||
(gid_valid(tun->group) && !in_egroup_p(tun->group))) &&
|
||||
!capable(CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
err = security_tun_dev_attach(tun->socket.sk);
|
||||
@ -1375,6 +1381,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
|
||||
void __user* argp = (void __user*)arg;
|
||||
struct sock_fprog fprog;
|
||||
struct ifreq ifr;
|
||||
kuid_t owner;
|
||||
kgid_t group;
|
||||
int sndbuf;
|
||||
int vnet_hdr_sz;
|
||||
int ret;
|
||||
@ -1448,16 +1456,26 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
|
||||
|
||||
case TUNSETOWNER:
|
||||
/* Set owner of the device */
|
||||
tun->owner = (uid_t) arg;
|
||||
|
||||
tun_debug(KERN_INFO, tun, "owner set to %d\n", tun->owner);
|
||||
owner = make_kuid(current_user_ns(), arg);
|
||||
if (!uid_valid(owner)) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
tun->owner = owner;
|
||||
tun_debug(KERN_INFO, tun, "owner set to %d\n",
|
||||
from_kuid(&init_user_ns, tun->owner));
|
||||
break;
|
||||
|
||||
case TUNSETGROUP:
|
||||
/* Set group of the device */
|
||||
tun->group= (gid_t) arg;
|
||||
|
||||
tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
|
||||
group = make_kgid(current_user_ns(), arg);
|
||||
if (!gid_valid(group)) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
tun->group = group;
|
||||
tun_debug(KERN_INFO, tun, "group set to %d\n",
|
||||
from_kgid(&init_user_ns, tun->group));
|
||||
break;
|
||||
|
||||
case TUNSETLINK:
|
||||
|
@ -232,8 +232,10 @@ static int adhoc;
|
||||
|
||||
static int probe = 1;
|
||||
|
||||
static kuid_t proc_kuid;
|
||||
static int proc_uid /* = 0 */;
|
||||
|
||||
static kgid_t proc_kgid;
|
||||
static int proc_gid /* = 0 */;
|
||||
|
||||
static int airo_perm = 0555;
|
||||
@ -4499,78 +4501,79 @@ struct proc_data {
|
||||
static int setup_proc_entry( struct net_device *dev,
|
||||
struct airo_info *apriv ) {
|
||||
struct proc_dir_entry *entry;
|
||||
|
||||
/* First setup the device directory */
|
||||
strcpy(apriv->proc_name,dev->name);
|
||||
apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm,
|
||||
airo_entry);
|
||||
if (!apriv->proc_entry)
|
||||
goto fail;
|
||||
apriv->proc_entry->uid = proc_uid;
|
||||
apriv->proc_entry->gid = proc_gid;
|
||||
apriv->proc_entry->uid = proc_kuid;
|
||||
apriv->proc_entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the StatsDelta */
|
||||
entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm,
|
||||
apriv->proc_entry, &proc_statsdelta_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_stats_delta;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the Stats */
|
||||
entry = proc_create_data("Stats", S_IRUGO & proc_perm,
|
||||
apriv->proc_entry, &proc_stats_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_stats;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the Status */
|
||||
entry = proc_create_data("Status", S_IRUGO & proc_perm,
|
||||
apriv->proc_entry, &proc_status_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_status;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the Config */
|
||||
entry = proc_create_data("Config", proc_perm,
|
||||
apriv->proc_entry, &proc_config_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_config;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the SSID */
|
||||
entry = proc_create_data("SSID", proc_perm,
|
||||
apriv->proc_entry, &proc_SSID_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_ssid;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the APList */
|
||||
entry = proc_create_data("APList", proc_perm,
|
||||
apriv->proc_entry, &proc_APList_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_aplist;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the BSSList */
|
||||
entry = proc_create_data("BSSList", proc_perm,
|
||||
apriv->proc_entry, &proc_BSSList_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_bsslist;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
/* Setup the WepKey */
|
||||
entry = proc_create_data("WepKey", proc_perm,
|
||||
apriv->proc_entry, &proc_wepkey_ops, dev);
|
||||
if (!entry)
|
||||
goto fail_wepkey;
|
||||
entry->uid = proc_uid;
|
||||
entry->gid = proc_gid;
|
||||
entry->uid = proc_kuid;
|
||||
entry->gid = proc_kgid;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -5697,11 +5700,16 @@ static int __init airo_init_module( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
proc_kuid = make_kuid(&init_user_ns, proc_uid);
|
||||
proc_kgid = make_kgid(&init_user_ns, proc_gid);
|
||||
if (!uid_valid(proc_kuid) || !gid_valid(proc_kgid))
|
||||
return -EINVAL;
|
||||
|
||||
airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL);
|
||||
|
||||
if (airo_entry) {
|
||||
airo_entry->uid = proc_uid;
|
||||
airo_entry->gid = proc_gid;
|
||||
airo_entry->uid = proc_kuid;
|
||||
airo_entry->gid = proc_kgid;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4 && io[i] && irq[i]; i++) {
|
||||
|
@ -47,7 +47,7 @@ static HLIST_HEAD(binder_dead_nodes);
|
||||
static struct dentry *binder_debugfs_dir_entry_root;
|
||||
static struct dentry *binder_debugfs_dir_entry_proc;
|
||||
static struct binder_node *binder_context_mgr_node;
|
||||
static uid_t binder_context_mgr_uid = -1;
|
||||
static kuid_t binder_context_mgr_uid = INVALID_UID;
|
||||
static int binder_last_id;
|
||||
static struct workqueue_struct *binder_deferred_workqueue;
|
||||
|
||||
@ -356,7 +356,7 @@ struct binder_transaction {
|
||||
unsigned int flags;
|
||||
long priority;
|
||||
long saved_priority;
|
||||
uid_t sender_euid;
|
||||
kuid_t sender_euid;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -2427,7 +2427,7 @@ retry:
|
||||
}
|
||||
tr.code = t->code;
|
||||
tr.flags = t->flags;
|
||||
tr.sender_euid = t->sender_euid;
|
||||
tr.sender_euid = from_kuid(current_user_ns(), t->sender_euid);
|
||||
|
||||
if (t->from) {
|
||||
struct task_struct *sender = t->from->proc->tsk;
|
||||
@ -2705,12 +2705,12 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||
ret = -EBUSY;
|
||||
goto err;
|
||||
}
|
||||
if (binder_context_mgr_uid != -1) {
|
||||
if (binder_context_mgr_uid != current->cred->euid) {
|
||||
if (uid_valid(binder_context_mgr_uid)) {
|
||||
if (!uid_eq(binder_context_mgr_uid, current->cred->euid)) {
|
||||
pr_err("binder: BINDER_SET_"
|
||||
"CONTEXT_MGR bad uid %d != %d\n",
|
||||
current->cred->euid,
|
||||
binder_context_mgr_uid);
|
||||
from_kuid(&init_user_ns, current->cred->euid),
|
||||
from_kuid(&init_user_ns, binder_context_mgr_uid));
|
||||
ret = -EPERM;
|
||||
goto err;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ static void tty_audit_buf_put(struct tty_audit_buf *buf)
|
||||
}
|
||||
|
||||
static void tty_audit_log(const char *description, struct task_struct *tsk,
|
||||
uid_t loginuid, unsigned sessionid, int major,
|
||||
kuid_t loginuid, unsigned sessionid, int major,
|
||||
int minor, unsigned char *data, size_t size)
|
||||
{
|
||||
struct audit_buffer *ab;
|
||||
@ -69,11 +69,14 @@ static void tty_audit_log(const char *description, struct task_struct *tsk,
|
||||
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY);
|
||||
if (ab) {
|
||||
char name[sizeof(tsk->comm)];
|
||||
uid_t uid = task_uid(tsk);
|
||||
kuid_t uid = task_uid(tsk);
|
||||
|
||||
audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u "
|
||||
"major=%d minor=%d comm=", description,
|
||||
tsk->pid, uid, loginuid, sessionid,
|
||||
tsk->pid,
|
||||
from_kuid(&init_user_ns, uid),
|
||||
from_kuid(&init_user_ns, loginuid),
|
||||
sessionid,
|
||||
major, minor);
|
||||
get_task_comm(name, tsk);
|
||||
audit_log_untrustedstring(ab, name);
|
||||
@ -89,7 +92,7 @@ static void tty_audit_log(const char *description, struct task_struct *tsk,
|
||||
* Generate an audit message from the contents of @buf, which is owned by
|
||||
* @tsk with @loginuid. @buf->mutex must be locked.
|
||||
*/
|
||||
static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid,
|
||||
static void tty_audit_buf_push(struct task_struct *tsk, kuid_t loginuid,
|
||||
unsigned int sessionid,
|
||||
struct tty_audit_buf *buf)
|
||||
{
|
||||
@ -112,7 +115,7 @@ static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid,
|
||||
*/
|
||||
static void tty_audit_buf_push_current(struct tty_audit_buf *buf)
|
||||
{
|
||||
uid_t auid = audit_get_loginuid(current);
|
||||
kuid_t auid = audit_get_loginuid(current);
|
||||
unsigned int sessionid = audit_get_sessionid(current);
|
||||
tty_audit_buf_push(current, auid, sessionid, buf);
|
||||
}
|
||||
@ -179,7 +182,7 @@ void tty_audit_tiocsti(struct tty_struct *tty, char ch)
|
||||
}
|
||||
|
||||
if (should_audit && audit_enabled) {
|
||||
uid_t auid;
|
||||
kuid_t auid;
|
||||
unsigned int sessionid;
|
||||
|
||||
auid = audit_get_loginuid(current);
|
||||
@ -199,7 +202,7 @@ void tty_audit_tiocsti(struct tty_struct *tty, char ch)
|
||||
* reference to the tty audit buffer if available.
|
||||
* Flush the buffer or return an appropriate error code.
|
||||
*/
|
||||
int tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
|
||||
int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid)
|
||||
{
|
||||
struct tty_audit_buf *buf = ERR_PTR(-EPERM);
|
||||
unsigned long flags;
|
||||
|
@ -224,8 +224,8 @@ struct ffs_data {
|
||||
/* File permissions, written once when fs is mounted */
|
||||
struct ffs_file_perms {
|
||||
umode_t mode;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
} file_perms;
|
||||
|
||||
/*
|
||||
@ -1147,10 +1147,19 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (!memcmp(opts, "uid", 3))
|
||||
data->perms.uid = value;
|
||||
if (!memcmp(opts, "uid", 3)) {
|
||||
data->perms.uid = make_kuid(current_user_ns(), value);
|
||||
if (!uid_valid(data->perms.uid)) {
|
||||
pr_err("%s: unmapped value: %lu\n", opts, value);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else if (!memcmp(opts, "gid", 3))
|
||||
data->perms.gid = value;
|
||||
data->perms.gid = make_kgid(current_user_ns(), value);
|
||||
if (!gid_valid(data->perms.gid)) {
|
||||
pr_err("%s: unmapped value: %lu\n", opts, value);
|
||||
return -EINVAL;
|
||||
}
|
||||
else
|
||||
goto invalid;
|
||||
break;
|
||||
@ -1179,8 +1188,8 @@ ffs_fs_mount(struct file_system_type *t, int flags,
|
||||
struct ffs_sb_fill_data data = {
|
||||
.perms = {
|
||||
.mode = S_IFREG | 0600,
|
||||
.uid = 0,
|
||||
.gid = 0
|
||||
.uid = GLOBAL_ROOT_UID,
|
||||
.gid = GLOBAL_ROOT_GID,
|
||||
},
|
||||
.root_mode = S_IFDIR | 0500,
|
||||
};
|
||||
|
@ -1985,8 +1985,8 @@ gadgetfs_make_inode (struct super_block *sb,
|
||||
if (inode) {
|
||||
inode->i_ino = get_next_ino();
|
||||
inode->i_mode = mode;
|
||||
inode->i_uid = default_uid;
|
||||
inode->i_gid = default_gid;
|
||||
inode->i_uid = make_kuid(&init_user_ns, default_uid);
|
||||
inode->i_gid = make_kgid(&init_user_ns, default_gid);
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime
|
||||
= CURRENT_TIME;
|
||||
inode->i_private = data;
|
||||
|
@ -30,7 +30,8 @@ static struct inode *xenfs_make_inode(struct super_block *sb, int mode)
|
||||
|
||||
if (ret) {
|
||||
ret->i_mode = mode;
|
||||
ret->i_uid = ret->i_gid = 0;
|
||||
ret->i_uid = GLOBAL_ROOT_UID;
|
||||
ret->i_gid = GLOBAL_ROOT_GID;
|
||||
ret->i_blocks = 0;
|
||||
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
size = v9fs_fid_xattr_get(fid, name, value, size);
|
||||
if (size > 0) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
goto err_out;
|
||||
}
|
||||
@ -131,7 +131,7 @@ static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl)
|
||||
buffer = kmalloc(size, GFP_KERNEL);
|
||||
if (!buffer)
|
||||
return -ENOMEM;
|
||||
retval = posix_acl_to_xattr(acl, buffer, size);
|
||||
retval = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
if (retval < 0)
|
||||
goto err_free_out;
|
||||
switch (type) {
|
||||
@ -251,7 +251,7 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
@ -304,7 +304,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
|
||||
return -EPERM;
|
||||
if (value) {
|
||||
/* update the cached acl value */
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
else if (acl) {
|
||||
|
@ -46,8 +46,8 @@ struct adfs_sb_info {
|
||||
struct adfs_discmap *s_map; /* bh list containing map */
|
||||
struct adfs_dir_ops *s_dir; /* directory operations */
|
||||
|
||||
uid_t s_uid; /* owner uid */
|
||||
gid_t s_gid; /* owner gid */
|
||||
kuid_t s_uid; /* owner uid */
|
||||
kgid_t s_gid; /* owner gid */
|
||||
umode_t s_owner_mask; /* ADFS owner perm -> unix perm */
|
||||
umode_t s_other_mask; /* ADFS other perm -> unix perm */
|
||||
int s_ftsuffix; /* ,xyz hex filetype suffix option */
|
||||
|
@ -304,8 +304,8 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
|
||||
* we can't change the UID or GID of any file -
|
||||
* we have a global UID/GID in the superblock
|
||||
*/
|
||||
if ((ia_valid & ATTR_UID && attr->ia_uid != ADFS_SB(sb)->s_uid) ||
|
||||
(ia_valid & ATTR_GID && attr->ia_gid != ADFS_SB(sb)->s_gid))
|
||||
if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, ADFS_SB(sb)->s_uid)) ||
|
||||
(ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, ADFS_SB(sb)->s_gid)))
|
||||
error = -EPERM;
|
||||
|
||||
if (error)
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/statfs.h>
|
||||
#include <linux/user_namespace.h>
|
||||
#include "adfs.h"
|
||||
#include "dir_f.h"
|
||||
#include "dir_fplus.h"
|
||||
@ -130,10 +131,10 @@ static int adfs_show_options(struct seq_file *seq, struct dentry *root)
|
||||
{
|
||||
struct adfs_sb_info *asb = ADFS_SB(root->d_sb);
|
||||
|
||||
if (asb->s_uid != 0)
|
||||
seq_printf(seq, ",uid=%u", asb->s_uid);
|
||||
if (asb->s_gid != 0)
|
||||
seq_printf(seq, ",gid=%u", asb->s_gid);
|
||||
if (!uid_eq(asb->s_uid, GLOBAL_ROOT_UID))
|
||||
seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, asb->s_uid));
|
||||
if (!gid_eq(asb->s_gid, GLOBAL_ROOT_GID))
|
||||
seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, asb->s_gid));
|
||||
if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK)
|
||||
seq_printf(seq, ",ownmask=%o", asb->s_owner_mask);
|
||||
if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK)
|
||||
@ -175,12 +176,16 @@ static int parse_options(struct super_block *sb, char *options)
|
||||
case Opt_uid:
|
||||
if (match_int(args, &option))
|
||||
return -EINVAL;
|
||||
asb->s_uid = option;
|
||||
asb->s_uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(asb->s_uid))
|
||||
return -EINVAL;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_int(args, &option))
|
||||
return -EINVAL;
|
||||
asb->s_gid = option;
|
||||
asb->s_gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(asb->s_gid))
|
||||
return -EINVAL;
|
||||
break;
|
||||
case Opt_ownmask:
|
||||
if (match_octal(args, &option))
|
||||
@ -369,8 +374,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
sb->s_fs_info = asb;
|
||||
|
||||
/* set default options */
|
||||
asb->s_uid = 0;
|
||||
asb->s_gid = 0;
|
||||
asb->s_uid = GLOBAL_ROOT_UID;
|
||||
asb->s_gid = GLOBAL_ROOT_GID;
|
||||
asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK;
|
||||
asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
|
||||
asb->s_ftsuffix = 0;
|
||||
|
@ -88,8 +88,8 @@ struct affs_sb_info {
|
||||
u32 s_root_block; /* FFS root block number. */
|
||||
int s_hashsize; /* Size of hash table. */
|
||||
unsigned long s_flags; /* See below. */
|
||||
uid_t s_uid; /* uid to override */
|
||||
gid_t s_gid; /* gid to override */
|
||||
kuid_t s_uid; /* uid to override */
|
||||
kgid_t s_gid; /* gid to override */
|
||||
umode_t s_mode; /* mode to override */
|
||||
struct buffer_head *s_root_bh; /* Cached root block. */
|
||||
struct mutex s_bmlock; /* Protects bitmap access. */
|
||||
|
@ -80,17 +80,17 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
|
||||
if (id == 0 || sbi->s_flags & SF_SETUID)
|
||||
inode->i_uid = sbi->s_uid;
|
||||
else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
|
||||
inode->i_uid = 0;
|
||||
i_uid_write(inode, 0);
|
||||
else
|
||||
inode->i_uid = id;
|
||||
i_uid_write(inode, id);
|
||||
|
||||
id = be16_to_cpu(tail->gid);
|
||||
if (id == 0 || sbi->s_flags & SF_SETGID)
|
||||
inode->i_gid = sbi->s_gid;
|
||||
else if (id == 0xFFFF && sbi->s_flags & SF_MUFS)
|
||||
inode->i_gid = 0;
|
||||
i_gid_write(inode, 0);
|
||||
else
|
||||
inode->i_gid = id;
|
||||
i_gid_write(inode, id);
|
||||
|
||||
switch (be32_to_cpu(tail->stype)) {
|
||||
case ST_ROOT:
|
||||
@ -193,13 +193,13 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc)
|
||||
tail->size = cpu_to_be32(inode->i_size);
|
||||
secs_to_datestamp(inode->i_mtime.tv_sec,&tail->change);
|
||||
if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) {
|
||||
uid = inode->i_uid;
|
||||
gid = inode->i_gid;
|
||||
uid = i_uid_read(inode);
|
||||
gid = i_gid_read(inode);
|
||||
if (AFFS_SB(sb)->s_flags & SF_MUFS) {
|
||||
if (inode->i_uid == 0 || inode->i_uid == 0xFFFF)
|
||||
uid = inode->i_uid ^ ~0;
|
||||
if (inode->i_gid == 0 || inode->i_gid == 0xFFFF)
|
||||
gid = inode->i_gid ^ ~0;
|
||||
if (uid == 0 || uid == 0xFFFF)
|
||||
uid = uid ^ ~0;
|
||||
if (gid == 0 || gid == 0xFFFF)
|
||||
gid = gid ^ ~0;
|
||||
}
|
||||
if (!(AFFS_SB(sb)->s_flags & SF_SETUID))
|
||||
tail->uid = cpu_to_be16(uid);
|
||||
|
@ -188,7 +188,7 @@ static const match_table_t tokens = {
|
||||
};
|
||||
|
||||
static int
|
||||
parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s32 *root,
|
||||
parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved, s32 *root,
|
||||
int *blocksize, char **prefix, char *volume, unsigned long *mount_opts)
|
||||
{
|
||||
char *p;
|
||||
@ -253,13 +253,17 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s
|
||||
case Opt_setgid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
*gid = option;
|
||||
*gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(*gid))
|
||||
return 0;
|
||||
*mount_opts |= SF_SETGID;
|
||||
break;
|
||||
case Opt_setuid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
*uid = option;
|
||||
*uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(*uid))
|
||||
return 0;
|
||||
*mount_opts |= SF_SETUID;
|
||||
break;
|
||||
case Opt_verbose:
|
||||
@ -301,8 +305,8 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
int num_bm;
|
||||
int i, j;
|
||||
s32 key;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
int reserved;
|
||||
unsigned long mount_flags;
|
||||
int tmp_flags; /* fix remount prototype... */
|
||||
@ -527,8 +531,8 @@ affs_remount(struct super_block *sb, int *flags, char *data)
|
||||
{
|
||||
struct affs_sb_info *sbi = AFFS_SB(sb);
|
||||
int blocksize;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
int mode;
|
||||
int reserved;
|
||||
int root_block;
|
||||
|
@ -20,8 +20,8 @@ typedef u64 befs_blocknr_t;
|
||||
*/
|
||||
|
||||
typedef struct befs_mount_options {
|
||||
gid_t gid;
|
||||
uid_t uid;
|
||||
kgid_t gid;
|
||||
kuid_t uid;
|
||||
int use_gid;
|
||||
int use_uid;
|
||||
int debug;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/vfs.h>
|
||||
#include <linux/parser.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "befs.h"
|
||||
#include "btree.h"
|
||||
@ -352,9 +353,11 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
|
||||
*/
|
||||
|
||||
inode->i_uid = befs_sb->mount_opts.use_uid ?
|
||||
befs_sb->mount_opts.uid : (uid_t) fs32_to_cpu(sb, raw_inode->uid);
|
||||
befs_sb->mount_opts.uid :
|
||||
make_kuid(&init_user_ns, fs32_to_cpu(sb, raw_inode->uid));
|
||||
inode->i_gid = befs_sb->mount_opts.use_gid ?
|
||||
befs_sb->mount_opts.gid : (gid_t) fs32_to_cpu(sb, raw_inode->gid);
|
||||
befs_sb->mount_opts.gid :
|
||||
make_kgid(&init_user_ns, fs32_to_cpu(sb, raw_inode->gid));
|
||||
|
||||
set_nlink(inode, 1);
|
||||
|
||||
@ -674,10 +677,12 @@ parse_options(char *options, befs_mount_options * opts)
|
||||
char *p;
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int option;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
|
||||
/* Initialize options */
|
||||
opts->uid = 0;
|
||||
opts->gid = 0;
|
||||
opts->uid = GLOBAL_ROOT_UID;
|
||||
opts->gid = GLOBAL_ROOT_GID;
|
||||
opts->use_uid = 0;
|
||||
opts->use_gid = 0;
|
||||
opts->iocharset = NULL;
|
||||
@ -696,23 +701,29 @@ parse_options(char *options, befs_mount_options * opts)
|
||||
case Opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
if (option < 0) {
|
||||
uid = INVALID_UID;
|
||||
if (option >= 0)
|
||||
uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(uid)) {
|
||||
printk(KERN_ERR "BeFS: Invalid uid %d, "
|
||||
"using default\n", option);
|
||||
break;
|
||||
}
|
||||
opts->uid = option;
|
||||
opts->uid = uid;
|
||||
opts->use_uid = 1;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
if (option < 0) {
|
||||
gid = INVALID_GID;
|
||||
if (option >= 0)
|
||||
gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(gid)) {
|
||||
printk(KERN_ERR "BeFS: Invalid gid %d, "
|
||||
"using default\n", option);
|
||||
break;
|
||||
}
|
||||
opts->gid = option;
|
||||
opts->gid = gid;
|
||||
opts->use_gid = 1;
|
||||
break;
|
||||
case Opt_charset:
|
||||
|
@ -76,8 +76,8 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
|
||||
BFS_I(inode)->i_sblock = le32_to_cpu(di->i_sblock);
|
||||
BFS_I(inode)->i_eblock = le32_to_cpu(di->i_eblock);
|
||||
BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino);
|
||||
inode->i_uid = le32_to_cpu(di->i_uid);
|
||||
inode->i_gid = le32_to_cpu(di->i_gid);
|
||||
i_uid_write(inode, le32_to_cpu(di->i_uid));
|
||||
i_gid_write(inode, le32_to_cpu(di->i_gid));
|
||||
set_nlink(inode, le32_to_cpu(di->i_nlink));
|
||||
inode->i_size = BFS_FILESIZE(di);
|
||||
inode->i_blocks = BFS_FILEBLOCKS(di);
|
||||
@ -139,8 +139,8 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
|
||||
|
||||
di->i_ino = cpu_to_le16(ino);
|
||||
di->i_mode = cpu_to_le32(inode->i_mode);
|
||||
di->i_uid = cpu_to_le32(inode->i_uid);
|
||||
di->i_gid = cpu_to_le32(inode->i_gid);
|
||||
di->i_uid = cpu_to_le32(i_uid_read(inode));
|
||||
di->i_gid = cpu_to_le32(i_gid_read(inode));
|
||||
di->i_nlink = cpu_to_le32(inode->i_nlink);
|
||||
di->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
|
||||
di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
|
||||
|
@ -61,7 +61,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
|
||||
size = __btrfs_getxattr(inode, name, value, size);
|
||||
}
|
||||
if (size > 0) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
} else if (size == -ENOENT || size == -ENODATA || size == 0) {
|
||||
/* FIXME, who returns -ENOENT? I think nobody */
|
||||
acl = NULL;
|
||||
@ -91,7 +91,7 @@ static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name,
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
ret = posix_acl_to_xattr(acl, value, size);
|
||||
ret = posix_acl_to_xattr(&init_user_ns, acl, value, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return ret;
|
||||
@ -141,7 +141,7 @@ static int btrfs_set_acl(struct btrfs_trans_handle *trans,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = posix_acl_to_xattr(acl, value, size);
|
||||
ret = posix_acl_to_xattr(&init_user_ns, acl, value, size);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
}
|
||||
@ -169,7 +169,7 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
|
||||
|
@ -1715,8 +1715,8 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_inode_item *inode_item,
|
||||
struct inode *inode)
|
||||
{
|
||||
btrfs_set_stack_inode_uid(inode_item, inode->i_uid);
|
||||
btrfs_set_stack_inode_gid(inode_item, inode->i_gid);
|
||||
btrfs_set_stack_inode_uid(inode_item, i_uid_read(inode));
|
||||
btrfs_set_stack_inode_gid(inode_item, i_gid_read(inode));
|
||||
btrfs_set_stack_inode_size(inode_item, BTRFS_I(inode)->disk_i_size);
|
||||
btrfs_set_stack_inode_mode(inode_item, inode->i_mode);
|
||||
btrfs_set_stack_inode_nlink(inode_item, inode->i_nlink);
|
||||
@ -1764,8 +1764,8 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
|
||||
|
||||
inode_item = &delayed_node->inode_item;
|
||||
|
||||
inode->i_uid = btrfs_stack_inode_uid(inode_item);
|
||||
inode->i_gid = btrfs_stack_inode_gid(inode_item);
|
||||
i_uid_write(inode, btrfs_stack_inode_uid(inode_item));
|
||||
i_gid_write(inode, btrfs_stack_inode_gid(inode_item));
|
||||
btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item));
|
||||
inode->i_mode = btrfs_stack_inode_mode(inode_item);
|
||||
set_nlink(inode, btrfs_stack_inode_nlink(inode_item));
|
||||
|
@ -2572,8 +2572,8 @@ static void btrfs_read_locked_inode(struct inode *inode)
|
||||
struct btrfs_inode_item);
|
||||
inode->i_mode = btrfs_inode_mode(leaf, inode_item);
|
||||
set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
|
||||
inode->i_uid = btrfs_inode_uid(leaf, inode_item);
|
||||
inode->i_gid = btrfs_inode_gid(leaf, inode_item);
|
||||
i_uid_write(inode, btrfs_inode_uid(leaf, inode_item));
|
||||
i_gid_write(inode, btrfs_inode_gid(leaf, inode_item));
|
||||
btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
|
||||
|
||||
tspec = btrfs_inode_atime(inode_item);
|
||||
@ -2651,8 +2651,8 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_inode_item *item,
|
||||
struct inode *inode)
|
||||
{
|
||||
btrfs_set_inode_uid(leaf, item, inode->i_uid);
|
||||
btrfs_set_inode_gid(leaf, item, inode->i_gid);
|
||||
btrfs_set_inode_uid(leaf, item, i_uid_read(inode));
|
||||
btrfs_set_inode_gid(leaf, item, i_gid_read(inode));
|
||||
btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
|
||||
btrfs_set_inode_mode(leaf, item, inode->i_mode);
|
||||
btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
|
||||
|
@ -575,13 +575,13 @@ fail:
|
||||
*/
|
||||
static inline int btrfs_check_sticky(struct inode *dir, struct inode *inode)
|
||||
{
|
||||
uid_t fsuid = current_fsuid();
|
||||
kuid_t fsuid = current_fsuid();
|
||||
|
||||
if (!(dir->i_mode & S_ISVTX))
|
||||
return 0;
|
||||
if (inode->i_uid == fsuid)
|
||||
if (uid_eq(inode->i_uid, fsuid))
|
||||
return 0;
|
||||
if (dir->i_uid == fsuid)
|
||||
if (uid_eq(dir->i_uid, fsuid))
|
||||
return 0;
|
||||
return !capable(CAP_FOWNER);
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
|
||||
return -ENOMEM;
|
||||
/* assign default attributes */
|
||||
sd_iattr->ia_mode = sd->s_mode;
|
||||
sd_iattr->ia_uid = 0;
|
||||
sd_iattr->ia_gid = 0;
|
||||
sd_iattr->ia_uid = GLOBAL_ROOT_UID;
|
||||
sd_iattr->ia_gid = GLOBAL_ROOT_GID;
|
||||
sd_iattr->ia_atime = sd_iattr->ia_mtime = sd_iattr->ia_ctime = CURRENT_TIME;
|
||||
sd->s_iattr = sd_iattr;
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
|
||||
}
|
||||
|
||||
inode->i_mode = cramfs_inode->mode;
|
||||
inode->i_uid = cramfs_inode->uid;
|
||||
inode->i_gid = cramfs_inode->gid;
|
||||
i_uid_write(inode, cramfs_inode->uid);
|
||||
i_gid_write(inode, cramfs_inode->gid);
|
||||
|
||||
/* if the lower 2 bits are zero, the inode contains data */
|
||||
if (!(inode->i_ino & 3)) {
|
||||
|
@ -128,8 +128,8 @@ static inline int debugfs_positive(struct dentry *dentry)
|
||||
}
|
||||
|
||||
struct debugfs_mount_opts {
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
umode_t mode;
|
||||
};
|
||||
|
||||
@ -156,6 +156,8 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int option;
|
||||
int token;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
char *p;
|
||||
|
||||
opts->mode = DEBUGFS_DEFAULT_MODE;
|
||||
@ -169,12 +171,18 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
|
||||
case Opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
return -EINVAL;
|
||||
opts->uid = option;
|
||||
uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(uid))
|
||||
return -EINVAL;
|
||||
opts->uid = uid;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_octal(&args[0], &option))
|
||||
return -EINVAL;
|
||||
opts->gid = option;
|
||||
gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(gid))
|
||||
return -EINVAL;
|
||||
opts->gid = gid;
|
||||
break;
|
||||
case Opt_mode:
|
||||
if (match_octal(&args[0], &option))
|
||||
@ -226,10 +234,12 @@ static int debugfs_show_options(struct seq_file *m, struct dentry *root)
|
||||
struct debugfs_fs_info *fsi = root->d_sb->s_fs_info;
|
||||
struct debugfs_mount_opts *opts = &fsi->mount_opts;
|
||||
|
||||
if (opts->uid != 0)
|
||||
seq_printf(m, ",uid=%u", opts->uid);
|
||||
if (opts->gid != 0)
|
||||
seq_printf(m, ",gid=%u", opts->gid);
|
||||
if (!uid_eq(opts->uid, GLOBAL_ROOT_UID))
|
||||
seq_printf(m, ",uid=%u",
|
||||
from_kuid_munged(&init_user_ns, opts->uid));
|
||||
if (!gid_eq(opts->gid, GLOBAL_ROOT_GID))
|
||||
seq_printf(m, ",gid=%u",
|
||||
from_kgid_munged(&init_user_ns, opts->gid));
|
||||
if (opts->mode != DEBUGFS_DEFAULT_MODE)
|
||||
seq_printf(m, ",mode=%o", opts->mode);
|
||||
|
||||
|
@ -545,11 +545,12 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
if (check_ruid && path.dentry->d_inode->i_uid != current_uid()) {
|
||||
if (check_ruid && !uid_eq(path.dentry->d_inode->i_uid, current_uid())) {
|
||||
rc = -EPERM;
|
||||
printk(KERN_ERR "Mount of device (uid: %d) not owned by "
|
||||
"requested user (uid: %d)\n",
|
||||
path.dentry->d_inode->i_uid, current_uid());
|
||||
i_uid_read(path.dentry->d_inode),
|
||||
from_kuid(&init_user_ns, current_uid()));
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ static struct hlist_head *ecryptfs_daemon_hash;
|
||||
struct mutex ecryptfs_daemon_hash_mux;
|
||||
static int ecryptfs_hash_bits;
|
||||
#define ecryptfs_current_euid_hash(uid) \
|
||||
hash_long((unsigned long)current_euid(), ecryptfs_hash_bits)
|
||||
hash_long((unsigned long)from_kuid(&init_user_ns, current_euid()), ecryptfs_hash_bits)
|
||||
|
||||
static u32 ecryptfs_msg_counter;
|
||||
static struct ecryptfs_msg_ctx *ecryptfs_msg_ctx_arr;
|
||||
@ -121,8 +121,7 @@ int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon)
|
||||
hlist_for_each_entry(*daemon, elem,
|
||||
&ecryptfs_daemon_hash[ecryptfs_current_euid_hash()],
|
||||
euid_chain) {
|
||||
if ((*daemon)->file->f_cred->euid == current_euid() &&
|
||||
(*daemon)->file->f_cred->user_ns == current_user_ns()) {
|
||||
if (uid_eq((*daemon)->file->f_cred->euid, current_euid())) {
|
||||
rc = 0;
|
||||
goto out;
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
|
||||
|
||||
inode->i_mode = be16_to_cpu(efs_inode->di_mode);
|
||||
set_nlink(inode, be16_to_cpu(efs_inode->di_nlink));
|
||||
inode->i_uid = (uid_t)be16_to_cpu(efs_inode->di_uid);
|
||||
inode->i_gid = (gid_t)be16_to_cpu(efs_inode->di_gid);
|
||||
i_uid_write(inode, (uid_t)be16_to_cpu(efs_inode->di_uid));
|
||||
i_gid_write(inode, (gid_t)be16_to_cpu(efs_inode->di_gid));
|
||||
inode->i_size = be32_to_cpu(efs_inode->di_size);
|
||||
inode->i_atime.tv_sec = be32_to_cpu(efs_inode->di_atime);
|
||||
inode->i_mtime.tv_sec = be32_to_cpu(efs_inode->di_mtime);
|
||||
|
@ -1172,8 +1172,8 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
|
||||
|
||||
/* copy stuff from on-disk struct to in-memory struct */
|
||||
inode->i_mode = le16_to_cpu(fcb.i_mode);
|
||||
inode->i_uid = le32_to_cpu(fcb.i_uid);
|
||||
inode->i_gid = le32_to_cpu(fcb.i_gid);
|
||||
i_uid_write(inode, le32_to_cpu(fcb.i_uid));
|
||||
i_gid_write(inode, le32_to_cpu(fcb.i_gid));
|
||||
set_nlink(inode, le16_to_cpu(fcb.i_links_count));
|
||||
inode->i_ctime.tv_sec = (signed)le32_to_cpu(fcb.i_ctime);
|
||||
inode->i_atime.tv_sec = (signed)le32_to_cpu(fcb.i_atime);
|
||||
@ -1385,8 +1385,8 @@ static int exofs_update_inode(struct inode *inode, int do_sync)
|
||||
fcb = &args->fcb;
|
||||
|
||||
fcb->i_mode = cpu_to_le16(inode->i_mode);
|
||||
fcb->i_uid = cpu_to_le32(inode->i_uid);
|
||||
fcb->i_gid = cpu_to_le32(inode->i_gid);
|
||||
fcb->i_uid = cpu_to_le32(i_uid_read(inode));
|
||||
fcb->i_gid = cpu_to_le32(i_gid_read(inode));
|
||||
fcb->i_links_count = cpu_to_le16(inode->i_nlink);
|
||||
fcb->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
|
||||
fcb->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
|
||||
|
@ -53,16 +53,23 @@ ext2_acl_from_disk(const void *value, size_t size)
|
||||
case ACL_OTHER:
|
||||
value = (char *)value +
|
||||
sizeof(ext2_acl_entry_short);
|
||||
acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
|
||||
break;
|
||||
|
||||
case ACL_USER:
|
||||
value = (char *)value + sizeof(ext2_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_uid =
|
||||
make_kuid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
value = (char *)value + sizeof(ext2_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_id =
|
||||
le32_to_cpu(entry->e_id);
|
||||
acl->a_entries[n].e_gid =
|
||||
make_kgid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -96,14 +103,19 @@ ext2_acl_to_disk(const struct posix_acl *acl, size_t *size)
|
||||
ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION);
|
||||
e = (char *)ext_acl + sizeof(ext2_acl_header);
|
||||
for (n=0; n < acl->a_count; n++) {
|
||||
const struct posix_acl_entry *acl_e = &acl->a_entries[n];
|
||||
ext2_acl_entry *entry = (ext2_acl_entry *)e;
|
||||
entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
|
||||
switch(acl->a_entries[n].e_tag) {
|
||||
entry->e_tag = cpu_to_le16(acl_e->e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl_e->e_perm);
|
||||
switch(acl_e->e_tag) {
|
||||
case ACL_USER:
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kuid(&init_user_ns, acl_e->e_uid));
|
||||
e += sizeof(ext2_acl_entry);
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
entry->e_id =
|
||||
cpu_to_le32(acl->a_entries[n].e_id);
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kgid(&init_user_ns, acl_e->e_gid));
|
||||
e += sizeof(ext2_acl_entry);
|
||||
break;
|
||||
|
||||
@ -350,7 +362,7 @@ ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
@ -371,7 +383,7 @@ ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
|
||||
return -EPERM;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
else if (acl) {
|
||||
|
@ -48,16 +48,23 @@ ext3_acl_from_disk(const void *value, size_t size)
|
||||
case ACL_OTHER:
|
||||
value = (char *)value +
|
||||
sizeof(ext3_acl_entry_short);
|
||||
acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
|
||||
break;
|
||||
|
||||
case ACL_USER:
|
||||
value = (char *)value + sizeof(ext3_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_uid =
|
||||
make_kuid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
value = (char *)value + sizeof(ext3_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_id =
|
||||
le32_to_cpu(entry->e_id);
|
||||
acl->a_entries[n].e_gid =
|
||||
make_kgid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -91,14 +98,19 @@ ext3_acl_to_disk(const struct posix_acl *acl, size_t *size)
|
||||
ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION);
|
||||
e = (char *)ext_acl + sizeof(ext3_acl_header);
|
||||
for (n=0; n < acl->a_count; n++) {
|
||||
const struct posix_acl_entry *acl_e = &acl->a_entries[n];
|
||||
ext3_acl_entry *entry = (ext3_acl_entry *)e;
|
||||
entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
|
||||
switch(acl->a_entries[n].e_tag) {
|
||||
entry->e_tag = cpu_to_le16(acl_e->e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl_e->e_perm);
|
||||
switch(acl_e->e_tag) {
|
||||
case ACL_USER:
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kuid(&init_user_ns, acl_e->e_uid));
|
||||
e += sizeof(ext3_acl_entry);
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
entry->e_id =
|
||||
cpu_to_le32(acl->a_entries[n].e_id);
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kgid(&init_user_ns, acl_e->e_gid));
|
||||
e += sizeof(ext3_acl_entry);
|
||||
break;
|
||||
|
||||
@ -369,7 +381,7 @@ ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
@ -392,7 +404,7 @@ ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
|
||||
return -EPERM;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
else if (acl) {
|
||||
|
@ -2803,7 +2803,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
|
||||
|
||||
static inline struct inode *dquot_to_inode(struct dquot *dquot)
|
||||
{
|
||||
return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type];
|
||||
return sb_dqopt(dquot->dq_sb)->files[dquot->dq_id.type];
|
||||
}
|
||||
|
||||
static int ext3_write_dquot(struct dquot *dquot)
|
||||
|
@ -55,16 +55,23 @@ ext4_acl_from_disk(const void *value, size_t size)
|
||||
case ACL_OTHER:
|
||||
value = (char *)value +
|
||||
sizeof(ext4_acl_entry_short);
|
||||
acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
|
||||
break;
|
||||
|
||||
case ACL_USER:
|
||||
value = (char *)value + sizeof(ext4_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_uid =
|
||||
make_kuid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
value = (char *)value + sizeof(ext4_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_id =
|
||||
le32_to_cpu(entry->e_id);
|
||||
acl->a_entries[n].e_gid =
|
||||
make_kgid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -98,13 +105,19 @@ ext4_acl_to_disk(const struct posix_acl *acl, size_t *size)
|
||||
ext_acl->a_version = cpu_to_le32(EXT4_ACL_VERSION);
|
||||
e = (char *)ext_acl + sizeof(ext4_acl_header);
|
||||
for (n = 0; n < acl->a_count; n++) {
|
||||
const struct posix_acl_entry *acl_e = &acl->a_entries[n];
|
||||
ext4_acl_entry *entry = (ext4_acl_entry *)e;
|
||||
entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
|
||||
switch (acl->a_entries[n].e_tag) {
|
||||
entry->e_tag = cpu_to_le16(acl_e->e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl_e->e_perm);
|
||||
switch (acl_e->e_tag) {
|
||||
case ACL_USER:
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kuid(&init_user_ns, acl_e->e_uid));
|
||||
e += sizeof(ext4_acl_entry);
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
entry->e_id = cpu_to_le32(acl->a_entries[n].e_id);
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kgid(&init_user_ns, acl_e->e_gid));
|
||||
e += sizeof(ext4_acl_entry);
|
||||
break;
|
||||
|
||||
@ -374,7 +387,7 @@ ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
@ -397,7 +410,7 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
|
||||
return -EPERM;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
else if (acl) {
|
||||
|
@ -4791,7 +4791,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
|
||||
|
||||
static inline struct inode *dquot_to_inode(struct dquot *dquot)
|
||||
{
|
||||
return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type];
|
||||
return sb_dqopt(dquot->dq_sb)->files[dquot->dq_id.type];
|
||||
}
|
||||
|
||||
static int ext4_write_dquot(struct dquot *dquot)
|
||||
|
@ -23,8 +23,8 @@
|
||||
#define FAT_ERRORS_RO 3 /* remount r/o on error */
|
||||
|
||||
struct fat_mount_options {
|
||||
uid_t fs_uid;
|
||||
gid_t fs_gid;
|
||||
kuid_t fs_uid;
|
||||
kgid_t fs_gid;
|
||||
unsigned short fs_fmask;
|
||||
unsigned short fs_dmask;
|
||||
unsigned short codepage; /* Codepage for shortname conversions */
|
||||
|
@ -352,7 +352,7 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode)
|
||||
{
|
||||
umode_t allow_utime = sbi->options.allow_utime;
|
||||
|
||||
if (current_fsuid() != inode->i_uid) {
|
||||
if (!uid_eq(current_fsuid(), inode->i_uid)) {
|
||||
if (in_group_p(inode->i_gid))
|
||||
allow_utime >>= 3;
|
||||
if (allow_utime & MAY_WRITE)
|
||||
@ -407,9 +407,9 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
}
|
||||
|
||||
if (((attr->ia_valid & ATTR_UID) &&
|
||||
(attr->ia_uid != sbi->options.fs_uid)) ||
|
||||
(!uid_eq(attr->ia_uid, sbi->options.fs_uid))) ||
|
||||
((attr->ia_valid & ATTR_GID) &&
|
||||
(attr->ia_gid != sbi->options.fs_gid)) ||
|
||||
(!gid_eq(attr->ia_gid, sbi->options.fs_gid))) ||
|
||||
((attr->ia_valid & ATTR_MODE) &&
|
||||
(attr->ia_mode & ~FAT_VALID_MODE)))
|
||||
error = -EPERM;
|
||||
|
@ -791,10 +791,12 @@ static int fat_show_options(struct seq_file *m, struct dentry *root)
|
||||
struct fat_mount_options *opts = &sbi->options;
|
||||
int isvfat = opts->isvfat;
|
||||
|
||||
if (opts->fs_uid != 0)
|
||||
seq_printf(m, ",uid=%u", opts->fs_uid);
|
||||
if (opts->fs_gid != 0)
|
||||
seq_printf(m, ",gid=%u", opts->fs_gid);
|
||||
if (!uid_eq(opts->fs_uid, GLOBAL_ROOT_UID))
|
||||
seq_printf(m, ",uid=%u",
|
||||
from_kuid_munged(&init_user_ns, opts->fs_uid));
|
||||
if (!gid_eq(opts->fs_gid, GLOBAL_ROOT_GID))
|
||||
seq_printf(m, ",gid=%u",
|
||||
from_kgid_munged(&init_user_ns, opts->fs_gid));
|
||||
seq_printf(m, ",fmask=%04o", opts->fs_fmask);
|
||||
seq_printf(m, ",dmask=%04o", opts->fs_dmask);
|
||||
if (opts->allow_utime)
|
||||
@ -1037,12 +1039,16 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
|
||||
case Opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
opts->fs_uid = option;
|
||||
opts->fs_uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(opts->fs_uid))
|
||||
return 0;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
opts->fs_gid = option;
|
||||
opts->fs_gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(opts->fs_gid))
|
||||
return 0;
|
||||
break;
|
||||
case Opt_umask:
|
||||
if (match_octal(&args[0], &option))
|
||||
|
@ -224,8 +224,8 @@ vxfs_iinit(struct inode *ip, struct vxfs_inode_info *vip)
|
||||
{
|
||||
|
||||
ip->i_mode = vxfs_transmod(vip);
|
||||
ip->i_uid = (uid_t)vip->vii_uid;
|
||||
ip->i_gid = (gid_t)vip->vii_gid;
|
||||
i_uid_write(ip, (uid_t)vip->vii_uid);
|
||||
i_gid_write(ip, (gid_t)vip->vii_gid);
|
||||
|
||||
set_nlink(ip, vip->vii_nlink);
|
||||
ip->i_size = vip->vii_size;
|
||||
|
@ -56,7 +56,7 @@ generic_acl_get(struct dentry *dentry, const char *name, void *buffer,
|
||||
acl = get_cached_acl(dentry->d_inode, type);
|
||||
if (!acl)
|
||||
return -ENODATA;
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
@ -77,7 +77,7 @@ generic_acl_set(struct dentry *dentry, const char *name, const void *value,
|
||||
if (!inode_owner_or_capable(inode))
|
||||
return -EPERM;
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ struct posix_acl *gfs2_get_acl(struct inode *inode, int type)
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
|
||||
acl = posix_acl_from_xattr(data, len);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, data, len);
|
||||
kfree(data);
|
||||
return acl;
|
||||
}
|
||||
@ -88,13 +88,13 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl)
|
||||
const char *name = gfs2_acl_name(type);
|
||||
|
||||
BUG_ON(name == NULL);
|
||||
len = posix_acl_to_xattr(acl, NULL, 0);
|
||||
len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
data = kmalloc(len, GFP_NOFS);
|
||||
if (data == NULL)
|
||||
return -ENOMEM;
|
||||
error = posix_acl_to_xattr(acl, data, len);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, data, len);
|
||||
if (error < 0)
|
||||
goto out;
|
||||
error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS);
|
||||
@ -166,12 +166,12 @@ int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
len = posix_acl_to_xattr(acl, NULL, 0);
|
||||
len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0);
|
||||
data = kmalloc(len, GFP_NOFS);
|
||||
error = -ENOMEM;
|
||||
if (data == NULL)
|
||||
goto out;
|
||||
posix_acl_to_xattr(acl, data, len);
|
||||
posix_acl_to_xattr(&init_user_ns, acl, data, len);
|
||||
error = gfs2_xattr_acl_chmod(ip, attr, data);
|
||||
kfree(data);
|
||||
set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl);
|
||||
@ -212,7 +212,7 @@ static int gfs2_xattr_system_get(struct dentry *dentry, const char *name,
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
@ -245,7 +245,7 @@ static int gfs2_xattr_system_set(struct dentry *dentry, const char *name,
|
||||
if (!value)
|
||||
goto set_acl;
|
||||
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (!acl) {
|
||||
/*
|
||||
* acl_set_file(3) may request that we set default ACLs with
|
||||
|
@ -1071,8 +1071,10 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
|
||||
|
||||
if (be64_to_cpu(qd->qd_qb.qb_limit) && (s64)be64_to_cpu(qd->qd_qb.qb_limit) < value) {
|
||||
print_message(qd, "exceeded");
|
||||
quota_send_warning(test_bit(QDF_USER, &qd->qd_flags) ?
|
||||
USRQUOTA : GRPQUOTA, qd->qd_id,
|
||||
quota_send_warning(make_kqid(&init_user_ns,
|
||||
test_bit(QDF_USER, &qd->qd_flags) ?
|
||||
USRQUOTA : GRPQUOTA,
|
||||
qd->qd_id),
|
||||
sdp->sd_vfs->s_dev, QUOTA_NL_BHARDWARN);
|
||||
|
||||
error = -EDQUOT;
|
||||
@ -1082,8 +1084,10 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
|
||||
time_after_eq(jiffies, qd->qd_last_warn +
|
||||
gfs2_tune_get(sdp,
|
||||
gt_quota_warn_period) * HZ)) {
|
||||
quota_send_warning(test_bit(QDF_USER, &qd->qd_flags) ?
|
||||
USRQUOTA : GRPQUOTA, qd->qd_id,
|
||||
quota_send_warning(make_kqid(&init_user_ns,
|
||||
test_bit(QDF_USER, &qd->qd_flags) ?
|
||||
USRQUOTA : GRPQUOTA,
|
||||
qd->qd_id),
|
||||
sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN);
|
||||
error = print_message(qd, "warning");
|
||||
qd->qd_last_warn = jiffies;
|
||||
@ -1470,7 +1474,7 @@ static int gfs2_quota_get_xstate(struct super_block *sb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gfs2_get_dqblk(struct super_block *sb, int type, qid_t id,
|
||||
static int gfs2_get_dqblk(struct super_block *sb, struct kqid qid,
|
||||
struct fs_disk_quota *fdq)
|
||||
{
|
||||
struct gfs2_sbd *sdp = sb->s_fs_info;
|
||||
@ -1478,20 +1482,21 @@ static int gfs2_get_dqblk(struct super_block *sb, int type, qid_t id,
|
||||
struct gfs2_quota_data *qd;
|
||||
struct gfs2_holder q_gh;
|
||||
int error;
|
||||
int type;
|
||||
|
||||
memset(fdq, 0, sizeof(struct fs_disk_quota));
|
||||
|
||||
if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
|
||||
return -ESRCH; /* Crazy XFS error code */
|
||||
|
||||
if (type == USRQUOTA)
|
||||
if (qid.type == USRQUOTA)
|
||||
type = QUOTA_USER;
|
||||
else if (type == GRPQUOTA)
|
||||
else if (qid.type == GRPQUOTA)
|
||||
type = QUOTA_GROUP;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
error = qd_get(sdp, type, id, &qd);
|
||||
error = qd_get(sdp, type, from_kqid(&init_user_ns, qid), &qd);
|
||||
if (error)
|
||||
return error;
|
||||
error = do_glock(qd, FORCE, &q_gh);
|
||||
@ -1501,7 +1506,7 @@ static int gfs2_get_dqblk(struct super_block *sb, int type, qid_t id,
|
||||
qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb;
|
||||
fdq->d_version = FS_DQUOT_VERSION;
|
||||
fdq->d_flags = (type == QUOTA_USER) ? FS_USER_QUOTA : FS_GROUP_QUOTA;
|
||||
fdq->d_id = id;
|
||||
fdq->d_id = from_kqid(&init_user_ns, qid);
|
||||
fdq->d_blk_hardlimit = be64_to_cpu(qlvb->qb_limit) << sdp->sd_fsb2bb_shift;
|
||||
fdq->d_blk_softlimit = be64_to_cpu(qlvb->qb_warn) << sdp->sd_fsb2bb_shift;
|
||||
fdq->d_bcount = be64_to_cpu(qlvb->qb_value) << sdp->sd_fsb2bb_shift;
|
||||
@ -1515,7 +1520,7 @@ out:
|
||||
/* GFS2 only supports a subset of the XFS fields */
|
||||
#define GFS2_FIELDMASK (FS_DQ_BSOFT|FS_DQ_BHARD|FS_DQ_BCOUNT)
|
||||
|
||||
static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
|
||||
static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid,
|
||||
struct fs_disk_quota *fdq)
|
||||
{
|
||||
struct gfs2_sbd *sdp = sb->s_fs_info;
|
||||
@ -1527,11 +1532,12 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
|
||||
int alloc_required;
|
||||
loff_t offset;
|
||||
int error;
|
||||
int type;
|
||||
|
||||
if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
|
||||
return -ESRCH; /* Crazy XFS error code */
|
||||
|
||||
switch(type) {
|
||||
switch(qid.type) {
|
||||
case USRQUOTA:
|
||||
type = QUOTA_USER;
|
||||
if (fdq->d_flags != FS_USER_QUOTA)
|
||||
@ -1548,10 +1554,10 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
|
||||
|
||||
if (fdq->d_fieldmask & ~GFS2_FIELDMASK)
|
||||
return -EINVAL;
|
||||
if (fdq->d_id != id)
|
||||
if (fdq->d_id != from_kqid(&init_user_ns, qid))
|
||||
return -EINVAL;
|
||||
|
||||
error = qd_get(sdp, type, id, &qd);
|
||||
error = qd_get(sdp, type, from_kqid(&init_user_ns, qid), &qd);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
|
@ -134,8 +134,8 @@ struct hfs_sb_info {
|
||||
permissions on all files */
|
||||
umode_t s_dir_umask; /* The umask applied to the
|
||||
permissions on all dirs */
|
||||
uid_t s_uid; /* The uid of all files */
|
||||
gid_t s_gid; /* The gid of all files */
|
||||
kuid_t s_uid; /* The uid of all files */
|
||||
kgid_t s_gid; /* The gid of all files */
|
||||
|
||||
int session, part;
|
||||
struct nls_table *nls_io, *nls_disk;
|
||||
|
@ -594,9 +594,9 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
|
||||
|
||||
/* no uig/gid changes and limit which mode bits can be set */
|
||||
if (((attr->ia_valid & ATTR_UID) &&
|
||||
(attr->ia_uid != hsb->s_uid)) ||
|
||||
(!uid_eq(attr->ia_uid, hsb->s_uid))) ||
|
||||
((attr->ia_valid & ATTR_GID) &&
|
||||
(attr->ia_gid != hsb->s_gid)) ||
|
||||
(!gid_eq(attr->ia_gid, hsb->s_gid))) ||
|
||||
((attr->ia_valid & ATTR_MODE) &&
|
||||
((S_ISDIR(inode->i_mode) &&
|
||||
(attr->ia_mode != inode->i_mode)) ||
|
||||
|
@ -138,7 +138,9 @@ static int hfs_show_options(struct seq_file *seq, struct dentry *root)
|
||||
seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator);
|
||||
if (sbi->s_type != cpu_to_be32(0x3f3f3f3f))
|
||||
seq_printf(seq, ",type=%.4s", (char *)&sbi->s_type);
|
||||
seq_printf(seq, ",uid=%u,gid=%u", sbi->s_uid, sbi->s_gid);
|
||||
seq_printf(seq, ",uid=%u,gid=%u",
|
||||
from_kuid_munged(&init_user_ns, sbi->s_uid),
|
||||
from_kgid_munged(&init_user_ns, sbi->s_gid));
|
||||
if (sbi->s_file_umask != 0133)
|
||||
seq_printf(seq, ",file_umask=%o", sbi->s_file_umask);
|
||||
if (sbi->s_dir_umask != 0022)
|
||||
@ -254,14 +256,22 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
|
||||
printk(KERN_ERR "hfs: uid requires an argument\n");
|
||||
return 0;
|
||||
}
|
||||
hsb->s_uid = (uid_t)tmp;
|
||||
hsb->s_uid = make_kuid(current_user_ns(), (uid_t)tmp);
|
||||
if (!uid_valid(hsb->s_uid)) {
|
||||
printk(KERN_ERR "hfs: invalid uid %d\n", tmp);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case opt_gid:
|
||||
if (match_int(&args[0], &tmp)) {
|
||||
printk(KERN_ERR "hfs: gid requires an argument\n");
|
||||
return 0;
|
||||
}
|
||||
hsb->s_gid = (gid_t)tmp;
|
||||
hsb->s_gid = make_kgid(current_user_ns(), (gid_t)tmp);
|
||||
if (!gid_valid(hsb->s_gid)) {
|
||||
printk(KERN_ERR "hfs: invalid gid %d\n", tmp);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case opt_umask:
|
||||
if (match_octal(&args[0], &tmp)) {
|
||||
|
@ -80,8 +80,8 @@ void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms)
|
||||
|
||||
perms->userflags = HFSPLUS_I(inode)->userflags;
|
||||
perms->mode = cpu_to_be16(inode->i_mode);
|
||||
perms->owner = cpu_to_be32(inode->i_uid);
|
||||
perms->group = cpu_to_be32(inode->i_gid);
|
||||
perms->owner = cpu_to_be32(i_uid_read(inode));
|
||||
perms->group = cpu_to_be32(i_gid_read(inode));
|
||||
|
||||
if (S_ISREG(inode->i_mode))
|
||||
perms->dev = cpu_to_be32(inode->i_nlink);
|
||||
|
@ -149,8 +149,8 @@ struct hfsplus_sb_info {
|
||||
u32 type;
|
||||
|
||||
umode_t umask;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
|
||||
int part, session;
|
||||
unsigned long flags;
|
||||
|
@ -233,12 +233,12 @@ static void hfsplus_get_perms(struct inode *inode,
|
||||
|
||||
mode = be16_to_cpu(perms->mode);
|
||||
|
||||
inode->i_uid = be32_to_cpu(perms->owner);
|
||||
if (!inode->i_uid && !mode)
|
||||
i_uid_write(inode, be32_to_cpu(perms->owner));
|
||||
if (!i_uid_read(inode) && !mode)
|
||||
inode->i_uid = sbi->uid;
|
||||
|
||||
inode->i_gid = be32_to_cpu(perms->group);
|
||||
if (!inode->i_gid && !mode)
|
||||
i_gid_write(inode, be32_to_cpu(perms->group));
|
||||
if (!i_gid_read(inode) && !mode)
|
||||
inode->i_gid = sbi->gid;
|
||||
|
||||
if (dir) {
|
||||
|
@ -135,14 +135,22 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
|
||||
printk(KERN_ERR "hfs: uid requires an argument\n");
|
||||
return 0;
|
||||
}
|
||||
sbi->uid = (uid_t)tmp;
|
||||
sbi->uid = make_kuid(current_user_ns(), (uid_t)tmp);
|
||||
if (!uid_valid(sbi->uid)) {
|
||||
printk(KERN_ERR "hfs: invalid uid specified\n");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case opt_gid:
|
||||
if (match_int(&args[0], &tmp)) {
|
||||
printk(KERN_ERR "hfs: gid requires an argument\n");
|
||||
return 0;
|
||||
}
|
||||
sbi->gid = (gid_t)tmp;
|
||||
sbi->gid = make_kgid(current_user_ns(), (gid_t)tmp);
|
||||
if (!gid_valid(sbi->gid)) {
|
||||
printk(KERN_ERR "hfs: invalid gid specified\n");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case opt_part:
|
||||
if (match_int(&args[0], &sbi->part)) {
|
||||
@ -215,7 +223,8 @@ int hfsplus_show_options(struct seq_file *seq, struct dentry *root)
|
||||
if (sbi->type != HFSPLUS_DEF_CR_TYPE)
|
||||
seq_printf(seq, ",type=%.4s", (char *)&sbi->type);
|
||||
seq_printf(seq, ",umask=%o,uid=%u,gid=%u", sbi->umask,
|
||||
sbi->uid, sbi->gid);
|
||||
from_kuid_munged(&init_user_ns, sbi->uid),
|
||||
from_kgid_munged(&init_user_ns, sbi->gid));
|
||||
if (sbi->part >= 0)
|
||||
seq_printf(seq, ",part=%u", sbi->part);
|
||||
if (sbi->session >= 0)
|
||||
|
@ -542,8 +542,8 @@ static int read_name(struct inode *ino, char *name)
|
||||
ino->i_ino = st.ino;
|
||||
ino->i_mode = st.mode;
|
||||
set_nlink(ino, st.nlink);
|
||||
ino->i_uid = st.uid;
|
||||
ino->i_gid = st.gid;
|
||||
i_uid_write(ino, st.uid);
|
||||
i_gid_write(ino, st.gid);
|
||||
ino->i_atime = st.atime;
|
||||
ino->i_mtime = st.mtime;
|
||||
ino->i_ctime = st.ctime;
|
||||
@ -808,11 +808,11 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
}
|
||||
if (attr->ia_valid & ATTR_UID) {
|
||||
attrs.ia_valid |= HOSTFS_ATTR_UID;
|
||||
attrs.ia_uid = attr->ia_uid;
|
||||
attrs.ia_uid = from_kuid(&init_user_ns, attr->ia_uid);
|
||||
}
|
||||
if (attr->ia_valid & ATTR_GID) {
|
||||
attrs.ia_valid |= HOSTFS_ATTR_GID;
|
||||
attrs.ia_gid = attr->ia_gid;
|
||||
attrs.ia_gid = from_kgid(&init_user_ns, attr->ia_gid);
|
||||
}
|
||||
if (attr->ia_valid & ATTR_SIZE) {
|
||||
attrs.ia_valid |= HOSTFS_ATTR_SIZE;
|
||||
|
@ -63,8 +63,8 @@ struct hpfs_sb_info {
|
||||
unsigned sb_dmap; /* sector number of dnode bit map */
|
||||
unsigned sb_n_free; /* free blocks for statfs, or -1 */
|
||||
unsigned sb_n_free_dnodes; /* free dnodes for statfs, or -1 */
|
||||
uid_t sb_uid; /* uid from mount options */
|
||||
gid_t sb_gid; /* gid from mount options */
|
||||
kuid_t sb_uid; /* uid from mount options */
|
||||
kgid_t sb_gid; /* gid from mount options */
|
||||
umode_t sb_mode; /* mode from mount options */
|
||||
unsigned sb_eas : 2; /* eas: 0-ignore, 1-ro, 2-rw */
|
||||
unsigned sb_err : 2; /* on errs: 0-cont, 1-ro, 2-panic */
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/user_namespace.h>
|
||||
#include "hpfs_fn.h"
|
||||
|
||||
void hpfs_init_inode(struct inode *i)
|
||||
@ -60,14 +61,14 @@ void hpfs_read_inode(struct inode *i)
|
||||
if (hpfs_sb(i->i_sb)->sb_eas) {
|
||||
if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) {
|
||||
if (ea_size == 2) {
|
||||
i->i_uid = le16_to_cpu(*(__le16*)ea);
|
||||
i_uid_write(i, le16_to_cpu(*(__le16*)ea));
|
||||
hpfs_inode->i_ea_uid = 1;
|
||||
}
|
||||
kfree(ea);
|
||||
}
|
||||
if ((ea = hpfs_get_ea(i->i_sb, fnode, "GID", &ea_size))) {
|
||||
if (ea_size == 2) {
|
||||
i->i_gid = le16_to_cpu(*(__le16*)ea);
|
||||
i_gid_write(i, le16_to_cpu(*(__le16*)ea));
|
||||
hpfs_inode->i_ea_gid = 1;
|
||||
}
|
||||
kfree(ea);
|
||||
@ -149,13 +150,13 @@ static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
|
||||
hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino);
|
||||
} else*/ if (hpfs_sb(i->i_sb)->sb_eas >= 2) {
|
||||
__le32 ea;
|
||||
if ((i->i_uid != hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
|
||||
ea = cpu_to_le32(i->i_uid);
|
||||
if (!uid_eq(i->i_uid, hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
|
||||
ea = cpu_to_le32(i_uid_read(i));
|
||||
hpfs_set_ea(i, fnode, "UID", (char*)&ea, 2);
|
||||
hpfs_inode->i_ea_uid = 1;
|
||||
}
|
||||
if ((i->i_gid != hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) {
|
||||
ea = cpu_to_le32(i->i_gid);
|
||||
if (!gid_eq(i->i_gid, hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) {
|
||||
ea = cpu_to_le32(i_gid_read(i));
|
||||
hpfs_set_ea(i, fnode, "GID", (char *)&ea, 2);
|
||||
hpfs_inode->i_ea_gid = 1;
|
||||
}
|
||||
@ -261,9 +262,11 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
hpfs_lock(inode->i_sb);
|
||||
if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
|
||||
goto out_unlock;
|
||||
if ((attr->ia_valid & ATTR_UID) && attr->ia_uid >= 0x10000)
|
||||
if ((attr->ia_valid & ATTR_UID) &&
|
||||
from_kuid(&init_user_ns, attr->ia_uid) >= 0x10000)
|
||||
goto out_unlock;
|
||||
if ((attr->ia_valid & ATTR_GID) && attr->ia_gid >= 0x10000)
|
||||
if ((attr->ia_valid & ATTR_GID) &&
|
||||
from_kgid(&init_user_ns, attr->ia_gid) >= 0x10000)
|
||||
goto out_unlock;
|
||||
if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
|
||||
goto out_unlock;
|
||||
|
@ -91,8 +91,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
inc_nlink(dir);
|
||||
insert_inode_hash(result);
|
||||
|
||||
if (result->i_uid != current_fsuid() ||
|
||||
result->i_gid != current_fsgid() ||
|
||||
if (!uid_eq(result->i_uid, current_fsuid()) ||
|
||||
!gid_eq(result->i_gid, current_fsgid()) ||
|
||||
result->i_mode != (mode | S_IFDIR)) {
|
||||
result->i_uid = current_fsuid();
|
||||
result->i_gid = current_fsgid();
|
||||
@ -179,8 +179,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
|
||||
|
||||
insert_inode_hash(result);
|
||||
|
||||
if (result->i_uid != current_fsuid() ||
|
||||
result->i_gid != current_fsgid() ||
|
||||
if (!uid_eq(result->i_uid, current_fsuid()) ||
|
||||
!gid_eq(result->i_gid, current_fsgid()) ||
|
||||
result->i_mode != (mode | S_IFREG)) {
|
||||
result->i_uid = current_fsuid();
|
||||
result->i_gid = current_fsgid();
|
||||
|
@ -251,7 +251,7 @@ static const match_table_t tokens = {
|
||||
{Opt_err, NULL},
|
||||
};
|
||||
|
||||
static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
|
||||
static int parse_opts(char *opts, kuid_t *uid, kgid_t *gid, umode_t *umask,
|
||||
int *lowercase, int *eas, int *chk, int *errs,
|
||||
int *chkdsk, int *timeshift)
|
||||
{
|
||||
@ -276,12 +276,16 @@ static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
|
||||
case Opt_uid:
|
||||
if (match_int(args, &option))
|
||||
return 0;
|
||||
*uid = option;
|
||||
*uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(*uid))
|
||||
return 0;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_int(args, &option))
|
||||
return 0;
|
||||
*gid = option;
|
||||
*gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(*gid))
|
||||
return 0;
|
||||
break;
|
||||
case Opt_umask:
|
||||
if (match_octal(args, &option))
|
||||
@ -378,8 +382,8 @@ HPFS filesystem options:\n\
|
||||
|
||||
static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
|
||||
{
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
umode_t umask;
|
||||
int lowercase, eas, chk, errs, chkdsk, timeshift;
|
||||
int o;
|
||||
@ -455,8 +459,8 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
|
||||
struct hpfs_sb_info *sbi;
|
||||
struct inode *root;
|
||||
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
umode_t umask;
|
||||
int lowercase, eas, chk, errs, chkdsk, timeshift;
|
||||
|
||||
|
@ -42,8 +42,8 @@ static const struct inode_operations hugetlbfs_dir_inode_operations;
|
||||
static const struct inode_operations hugetlbfs_inode_operations;
|
||||
|
||||
struct hugetlbfs_config {
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
umode_t mode;
|
||||
long nr_blocks;
|
||||
long nr_inodes;
|
||||
@ -785,13 +785,17 @@ hugetlbfs_parse_options(char *options, struct hugetlbfs_config *pconfig)
|
||||
case Opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
goto bad_val;
|
||||
pconfig->uid = option;
|
||||
pconfig->uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(pconfig->uid))
|
||||
goto bad_val;
|
||||
break;
|
||||
|
||||
case Opt_gid:
|
||||
if (match_int(&args[0], &option))
|
||||
goto bad_val;
|
||||
pconfig->gid = option;
|
||||
pconfig->gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(pconfig->gid))
|
||||
goto bad_val;
|
||||
break;
|
||||
|
||||
case Opt_mode:
|
||||
@ -924,7 +928,9 @@ static struct vfsmount *hugetlbfs_vfsmount;
|
||||
|
||||
static int can_do_hugetlb_shm(void)
|
||||
{
|
||||
return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
|
||||
kgid_t shm_group;
|
||||
shm_group = make_kgid(&init_user_ns, sysctl_hugetlb_shm_group);
|
||||
return capable(CAP_IPC_LOCK) || in_group_p(shm_group);
|
||||
}
|
||||
|
||||
struct file *hugetlb_file_setup(const char *name, unsigned long addr,
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <linux/cdrom.h>
|
||||
#include <linux/parser.h>
|
||||
#include <linux/mpage.h>
|
||||
#include <linux/user_namespace.h>
|
||||
|
||||
#include "isofs.h"
|
||||
#include "zisofs.h"
|
||||
@ -171,8 +172,8 @@ struct iso9660_options{
|
||||
unsigned int blocksize;
|
||||
umode_t fmode;
|
||||
umode_t dmode;
|
||||
gid_t gid;
|
||||
uid_t uid;
|
||||
kgid_t gid;
|
||||
kuid_t uid;
|
||||
char *iocharset;
|
||||
/* LVE */
|
||||
s32 session;
|
||||
@ -383,8 +384,8 @@ static int parse_options(char *options, struct iso9660_options *popt)
|
||||
popt->fmode = popt->dmode = ISOFS_INVALID_MODE;
|
||||
popt->uid_set = 0;
|
||||
popt->gid_set = 0;
|
||||
popt->gid = 0;
|
||||
popt->uid = 0;
|
||||
popt->gid = GLOBAL_ROOT_GID;
|
||||
popt->uid = GLOBAL_ROOT_UID;
|
||||
popt->iocharset = NULL;
|
||||
popt->utf8 = 0;
|
||||
popt->overriderockperm = 0;
|
||||
@ -460,13 +461,17 @@ static int parse_options(char *options, struct iso9660_options *popt)
|
||||
case Opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
popt->uid = option;
|
||||
popt->uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(popt->uid))
|
||||
return 0;
|
||||
popt->uid_set = 1;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
popt->gid = option;
|
||||
popt->gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(popt->gid))
|
||||
return 0;
|
||||
popt->gid_set = 1;
|
||||
break;
|
||||
case Opt_mode:
|
||||
|
@ -52,8 +52,8 @@ struct isofs_sb_info {
|
||||
|
||||
umode_t s_fmode;
|
||||
umode_t s_dmode;
|
||||
gid_t s_gid;
|
||||
uid_t s_uid;
|
||||
kgid_t s_gid;
|
||||
kuid_t s_uid;
|
||||
struct nls_table *s_nls_iocharset; /* Native language support table */
|
||||
};
|
||||
|
||||
|
@ -364,8 +364,8 @@ repeat:
|
||||
case SIG('P', 'X'):
|
||||
inode->i_mode = isonum_733(rr->u.PX.mode);
|
||||
set_nlink(inode, isonum_733(rr->u.PX.n_links));
|
||||
inode->i_uid = isonum_733(rr->u.PX.uid);
|
||||
inode->i_gid = isonum_733(rr->u.PX.gid);
|
||||
i_uid_write(inode, isonum_733(rr->u.PX.uid));
|
||||
i_gid_write(inode, isonum_733(rr->u.PX.gid));
|
||||
break;
|
||||
case SIG('P', 'N'):
|
||||
{
|
||||
|
@ -94,15 +94,23 @@ static struct posix_acl *jffs2_acl_from_medium(void *value, size_t size)
|
||||
case ACL_MASK:
|
||||
case ACL_OTHER:
|
||||
value += sizeof(struct jffs2_acl_entry_short);
|
||||
acl->a_entries[i].e_id = ACL_UNDEFINED_ID;
|
||||
break;
|
||||
|
||||
case ACL_USER:
|
||||
value += sizeof(struct jffs2_acl_entry);
|
||||
if (value > end)
|
||||
goto fail;
|
||||
acl->a_entries[i].e_uid =
|
||||
make_kuid(&init_user_ns,
|
||||
je32_to_cpu(entry->e_id));
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
value += sizeof(struct jffs2_acl_entry);
|
||||
if (value > end)
|
||||
goto fail;
|
||||
acl->a_entries[i].e_id = je32_to_cpu(entry->e_id);
|
||||
acl->a_entries[i].e_gid =
|
||||
make_kgid(&init_user_ns,
|
||||
je32_to_cpu(entry->e_id));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -131,13 +139,19 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
|
||||
header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
|
||||
e = header + 1;
|
||||
for (i=0; i < acl->a_count; i++) {
|
||||
const struct posix_acl_entry *acl_e = &acl->a_entries[i];
|
||||
entry = e;
|
||||
entry->e_tag = cpu_to_je16(acl->a_entries[i].e_tag);
|
||||
entry->e_perm = cpu_to_je16(acl->a_entries[i].e_perm);
|
||||
switch(acl->a_entries[i].e_tag) {
|
||||
entry->e_tag = cpu_to_je16(acl_e->e_tag);
|
||||
entry->e_perm = cpu_to_je16(acl_e->e_perm);
|
||||
switch(acl_e->e_tag) {
|
||||
case ACL_USER:
|
||||
entry->e_id = cpu_to_je32(
|
||||
from_kuid(&init_user_ns, acl_e->e_uid));
|
||||
e += sizeof(struct jffs2_acl_entry);
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
entry->e_id = cpu_to_je32(acl->a_entries[i].e_id);
|
||||
entry->e_id = cpu_to_je32(
|
||||
from_kgid(&init_user_ns, acl_e->e_gid));
|
||||
e += sizeof(struct jffs2_acl_entry);
|
||||
break;
|
||||
|
||||
@ -363,7 +377,7 @@ static int jffs2_acl_getxattr(struct dentry *dentry, const char *name,
|
||||
return PTR_ERR(acl);
|
||||
if (!acl)
|
||||
return -ENODATA;
|
||||
rc = posix_acl_to_xattr(acl, buffer, size);
|
||||
rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return rc;
|
||||
@ -381,7 +395,7 @@ static int jffs2_acl_setxattr(struct dentry *dentry, const char *name,
|
||||
return -EPERM;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
if (acl) {
|
||||
|
@ -175,8 +175,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
|
||||
ri.ino = cpu_to_je32(f->inocache->ino);
|
||||
ri.version = cpu_to_je32(++f->highest_version);
|
||||
ri.mode = cpu_to_jemode(inode->i_mode);
|
||||
ri.uid = cpu_to_je16(inode->i_uid);
|
||||
ri.gid = cpu_to_je16(inode->i_gid);
|
||||
ri.uid = cpu_to_je16(i_uid_read(inode));
|
||||
ri.gid = cpu_to_je16(i_gid_read(inode));
|
||||
ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
|
||||
ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds());
|
||||
ri.offset = cpu_to_je32(inode->i_size);
|
||||
@ -283,8 +283,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
|
||||
/* Set the fields that the generic jffs2_write_inode_range() code can't find */
|
||||
ri->ino = cpu_to_je32(inode->i_ino);
|
||||
ri->mode = cpu_to_jemode(inode->i_mode);
|
||||
ri->uid = cpu_to_je16(inode->i_uid);
|
||||
ri->gid = cpu_to_je16(inode->i_gid);
|
||||
ri->uid = cpu_to_je16(i_uid_read(inode));
|
||||
ri->gid = cpu_to_je16(i_gid_read(inode));
|
||||
ri->isize = cpu_to_je32((uint32_t)inode->i_size);
|
||||
ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds());
|
||||
|
||||
|
@ -99,8 +99,10 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
|
||||
ri->ino = cpu_to_je32(inode->i_ino);
|
||||
ri->version = cpu_to_je32(++f->highest_version);
|
||||
|
||||
ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
|
||||
ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
|
||||
ri->uid = cpu_to_je16((ivalid & ATTR_UID)?
|
||||
from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));
|
||||
ri->gid = cpu_to_je16((ivalid & ATTR_GID)?
|
||||
from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));
|
||||
|
||||
if (ivalid & ATTR_MODE)
|
||||
ri->mode = cpu_to_jemode(iattr->ia_mode);
|
||||
@ -147,8 +149,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
|
||||
inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
|
||||
inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
|
||||
inode->i_mode = jemode_to_cpu(ri->mode);
|
||||
inode->i_uid = je16_to_cpu(ri->uid);
|
||||
inode->i_gid = je16_to_cpu(ri->gid);
|
||||
i_uid_write(inode, je16_to_cpu(ri->uid));
|
||||
i_gid_write(inode, je16_to_cpu(ri->gid));
|
||||
|
||||
|
||||
old_metadata = f->metadata;
|
||||
@ -276,8 +278,8 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
inode->i_mode = jemode_to_cpu(latest_node.mode);
|
||||
inode->i_uid = je16_to_cpu(latest_node.uid);
|
||||
inode->i_gid = je16_to_cpu(latest_node.gid);
|
||||
i_uid_write(inode, je16_to_cpu(latest_node.uid));
|
||||
i_gid_write(inode, je16_to_cpu(latest_node.gid));
|
||||
inode->i_size = je32_to_cpu(latest_node.isize);
|
||||
inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
|
||||
inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
|
||||
@ -440,14 +442,14 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
|
||||
|
||||
memset(ri, 0, sizeof(*ri));
|
||||
/* Set OS-specific defaults for new inodes */
|
||||
ri->uid = cpu_to_je16(current_fsuid());
|
||||
ri->uid = cpu_to_je16(from_kuid(&init_user_ns, current_fsuid()));
|
||||
|
||||
if (dir_i->i_mode & S_ISGID) {
|
||||
ri->gid = cpu_to_je16(dir_i->i_gid);
|
||||
ri->gid = cpu_to_je16(i_gid_read(dir_i));
|
||||
if (S_ISDIR(mode))
|
||||
mode |= S_ISGID;
|
||||
} else {
|
||||
ri->gid = cpu_to_je16(current_fsgid());
|
||||
ri->gid = cpu_to_je16(from_kgid(&init_user_ns, current_fsgid()));
|
||||
}
|
||||
|
||||
/* POSIX ACLs have to be processed now, at least partly.
|
||||
@ -467,8 +469,8 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
|
||||
set_nlink(inode, 1);
|
||||
inode->i_ino = je32_to_cpu(ri->ino);
|
||||
inode->i_mode = jemode_to_cpu(ri->mode);
|
||||
inode->i_gid = je16_to_cpu(ri->gid);
|
||||
inode->i_uid = je16_to_cpu(ri->uid);
|
||||
i_gid_write(inode, je16_to_cpu(ri->gid));
|
||||
i_uid_write(inode, je16_to_cpu(ri->uid));
|
||||
inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
|
||||
ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
|
||||
|
||||
|
@ -27,8 +27,8 @@ struct kvec;
|
||||
|
||||
#define JFFS2_F_I_SIZE(f) (OFNI_EDONI_2SFFJ(f)->i_size)
|
||||
#define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode)
|
||||
#define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid)
|
||||
#define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
|
||||
#define JFFS2_F_I_UID(f) (i_uid_read(OFNI_EDONI_2SFFJ(f)))
|
||||
#define JFFS2_F_I_GID(f) (i_gid_read(OFNI_EDONI_2SFFJ(f)))
|
||||
#define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev)
|
||||
|
||||
#define ITIME(sec) ((struct timespec){sec, 0})
|
||||
|
@ -64,7 +64,7 @@ struct posix_acl *jfs_get_acl(struct inode *inode, int type)
|
||||
else
|
||||
acl = ERR_PTR(size);
|
||||
} else {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
}
|
||||
kfree(value);
|
||||
if (!IS_ERR(acl))
|
||||
@ -100,7 +100,7 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
|
||||
value = kmalloc(size, GFP_KERNEL);
|
||||
if (!value)
|
||||
return -ENOMEM;
|
||||
rc = posix_acl_to_xattr(acl, value, size);
|
||||
rc = posix_acl_to_xattr(&init_user_ns, acl, value, size);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
|
||||
|
||||
if (is_quota_modification(inode, iattr))
|
||||
dquot_initialize(inode);
|
||||
if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
|
||||
(iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
|
||||
if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
|
||||
(iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
|
||||
rc = dquot_transfer(inode, iattr);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
@ -3078,15 +3078,15 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
|
||||
}
|
||||
set_nlink(ip, le32_to_cpu(dip->di_nlink));
|
||||
|
||||
jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
|
||||
if (sbi->uid == -1)
|
||||
jfs_ip->saved_uid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
|
||||
if (!uid_valid(sbi->uid))
|
||||
ip->i_uid = jfs_ip->saved_uid;
|
||||
else {
|
||||
ip->i_uid = sbi->uid;
|
||||
}
|
||||
|
||||
jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
|
||||
if (sbi->gid == -1)
|
||||
jfs_ip->saved_gid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
|
||||
if (!gid_valid(sbi->gid))
|
||||
ip->i_gid = jfs_ip->saved_gid;
|
||||
else {
|
||||
ip->i_gid = sbi->gid;
|
||||
@ -3150,14 +3150,16 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip)
|
||||
dip->di_size = cpu_to_le64(ip->i_size);
|
||||
dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
|
||||
dip->di_nlink = cpu_to_le32(ip->i_nlink);
|
||||
if (sbi->uid == -1)
|
||||
dip->di_uid = cpu_to_le32(ip->i_uid);
|
||||
if (!uid_valid(sbi->uid))
|
||||
dip->di_uid = cpu_to_le32(i_uid_read(ip));
|
||||
else
|
||||
dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
|
||||
if (sbi->gid == -1)
|
||||
dip->di_gid = cpu_to_le32(ip->i_gid);
|
||||
dip->di_uid =cpu_to_le32(from_kuid(&init_user_ns,
|
||||
jfs_ip->saved_uid));
|
||||
if (!gid_valid(sbi->gid))
|
||||
dip->di_gid = cpu_to_le32(i_gid_read(ip));
|
||||
else
|
||||
dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
|
||||
dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
|
||||
jfs_ip->saved_gid));
|
||||
jfs_get_inode_flags(jfs_ip);
|
||||
/*
|
||||
* mode2 is only needed for storing the higher order bits.
|
||||
|
@ -38,8 +38,8 @@
|
||||
struct jfs_inode_info {
|
||||
int fileset; /* fileset number (always 16)*/
|
||||
uint mode2; /* jfs-specific mode */
|
||||
uint saved_uid; /* saved for uid mount option */
|
||||
uint saved_gid; /* saved for gid mount option */
|
||||
kuid_t saved_uid; /* saved for uid mount option */
|
||||
kgid_t saved_gid; /* saved for gid mount option */
|
||||
pxd_t ixpxd; /* inode extent descriptor */
|
||||
dxd_t acl; /* dxd describing acl */
|
||||
dxd_t ea; /* dxd describing ea */
|
||||
@ -192,8 +192,8 @@ struct jfs_sb_info {
|
||||
uint state; /* mount/recovery state */
|
||||
unsigned long flag; /* mount time flags */
|
||||
uint p_state; /* state prior to going no integrity */
|
||||
uint uid; /* uid to override on-disk uid */
|
||||
uint gid; /* gid to override on-disk gid */
|
||||
kuid_t uid; /* uid to override on-disk uid */
|
||||
kgid_t gid; /* gid to override on-disk gid */
|
||||
uint umask; /* umask to override on-disk umask */
|
||||
};
|
||||
|
||||
|
@ -321,13 +321,19 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
|
||||
case Opt_uid:
|
||||
{
|
||||
char *uid = args[0].from;
|
||||
sbi->uid = simple_strtoul(uid, &uid, 0);
|
||||
uid_t val = simple_strtoul(uid, &uid, 0);
|
||||
sbi->uid = make_kuid(current_user_ns(), val);
|
||||
if (!uid_valid(sbi->uid))
|
||||
goto cleanup;
|
||||
break;
|
||||
}
|
||||
case Opt_gid:
|
||||
{
|
||||
char *gid = args[0].from;
|
||||
sbi->gid = simple_strtoul(gid, &gid, 0);
|
||||
gid_t val = simple_strtoul(gid, &gid, 0);
|
||||
sbi->gid = make_kgid(current_user_ns(), val);
|
||||
if (!gid_valid(sbi->gid))
|
||||
goto cleanup;
|
||||
break;
|
||||
}
|
||||
case Opt_umask:
|
||||
@ -443,7 +449,9 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
sb->s_fs_info = sbi;
|
||||
sb->s_max_links = JFS_LINK_MAX;
|
||||
sbi->sb = sb;
|
||||
sbi->uid = sbi->gid = sbi->umask = -1;
|
||||
sbi->uid = INVALID_UID;
|
||||
sbi->gid = INVALID_GID;
|
||||
sbi->umask = -1;
|
||||
|
||||
/* initialize the mount flag and determine the default error handler */
|
||||
flag = JFS_ERR_REMOUNT_RO;
|
||||
@ -617,10 +625,10 @@ static int jfs_show_options(struct seq_file *seq, struct dentry *root)
|
||||
{
|
||||
struct jfs_sb_info *sbi = JFS_SBI(root->d_sb);
|
||||
|
||||
if (sbi->uid != -1)
|
||||
seq_printf(seq, ",uid=%d", sbi->uid);
|
||||
if (sbi->gid != -1)
|
||||
seq_printf(seq, ",gid=%d", sbi->gid);
|
||||
if (uid_valid(sbi->uid))
|
||||
seq_printf(seq, ",uid=%d", from_kuid(&init_user_ns, sbi->uid));
|
||||
if (gid_valid(sbi->gid))
|
||||
seq_printf(seq, ",gid=%d", from_kgid(&init_user_ns, sbi->gid));
|
||||
if (sbi->umask != -1)
|
||||
seq_printf(seq, ",umask=%03o", sbi->umask);
|
||||
if (sbi->flag & JFS_NOINTEGRITY)
|
||||
|
@ -685,7 +685,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
|
||||
* POSIX_ACL_XATTR_ACCESS is tied to i_mode
|
||||
*/
|
||||
if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) {
|
||||
acl = posix_acl_from_xattr(value, value_len);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, value_len);
|
||||
if (IS_ERR(acl)) {
|
||||
rc = PTR_ERR(acl);
|
||||
printk(KERN_ERR "posix_acl_from_xattr returned %d\n",
|
||||
@ -710,7 +710,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
|
||||
|
||||
return 0;
|
||||
} else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
|
||||
acl = posix_acl_from_xattr(value, value_len);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, value_len);
|
||||
if (IS_ERR(acl)) {
|
||||
rc = PTR_ERR(acl);
|
||||
printk(KERN_ERR "posix_acl_from_xattr returned %d\n",
|
||||
|
@ -208,8 +208,8 @@ static void logfs_init_inode(struct super_block *sb, struct inode *inode)
|
||||
li->li_height = 0;
|
||||
li->li_used_bytes = 0;
|
||||
li->li_block = NULL;
|
||||
inode->i_uid = 0;
|
||||
inode->i_gid = 0;
|
||||
i_uid_write(inode, 0);
|
||||
i_gid_write(inode, 0);
|
||||
inode->i_size = 0;
|
||||
inode->i_blocks = 0;
|
||||
inode->i_ctime = CURRENT_TIME;
|
||||
|
@ -119,8 +119,8 @@ static void logfs_disk_to_inode(struct logfs_disk_inode *di, struct inode*inode)
|
||||
inode->i_mode = be16_to_cpu(di->di_mode);
|
||||
li->li_height = di->di_height;
|
||||
li->li_flags = be32_to_cpu(di->di_flags);
|
||||
inode->i_uid = be32_to_cpu(di->di_uid);
|
||||
inode->i_gid = be32_to_cpu(di->di_gid);
|
||||
i_uid_write(inode, be32_to_cpu(di->di_uid));
|
||||
i_gid_write(inode, be32_to_cpu(di->di_gid));
|
||||
inode->i_size = be64_to_cpu(di->di_size);
|
||||
logfs_set_blocks(inode, be64_to_cpu(di->di_used_bytes));
|
||||
inode->i_atime = be64_to_timespec(di->di_atime);
|
||||
@ -156,8 +156,8 @@ static void logfs_inode_to_disk(struct inode *inode, struct logfs_disk_inode*di)
|
||||
di->di_height = li->li_height;
|
||||
di->di_pad = 0;
|
||||
di->di_flags = cpu_to_be32(li->li_flags);
|
||||
di->di_uid = cpu_to_be32(inode->i_uid);
|
||||
di->di_gid = cpu_to_be32(inode->i_gid);
|
||||
di->di_uid = cpu_to_be32(i_uid_read(inode));
|
||||
di->di_gid = cpu_to_be32(i_gid_read(inode));
|
||||
di->di_size = cpu_to_be64(i_size_read(inode));
|
||||
di->di_used_bytes = cpu_to_be64(li->li_used_bytes);
|
||||
di->di_atime = timespec_to_be64(inode->i_atime);
|
||||
|
@ -460,8 +460,8 @@ static struct inode *V1_minix_iget(struct inode *inode)
|
||||
return ERR_PTR(-EIO);
|
||||
}
|
||||
inode->i_mode = raw_inode->i_mode;
|
||||
inode->i_uid = (uid_t)raw_inode->i_uid;
|
||||
inode->i_gid = (gid_t)raw_inode->i_gid;
|
||||
i_uid_write(inode, raw_inode->i_uid);
|
||||
i_gid_write(inode, raw_inode->i_gid);
|
||||
set_nlink(inode, raw_inode->i_nlinks);
|
||||
inode->i_size = raw_inode->i_size;
|
||||
inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = raw_inode->i_time;
|
||||
@ -493,8 +493,8 @@ static struct inode *V2_minix_iget(struct inode *inode)
|
||||
return ERR_PTR(-EIO);
|
||||
}
|
||||
inode->i_mode = raw_inode->i_mode;
|
||||
inode->i_uid = (uid_t)raw_inode->i_uid;
|
||||
inode->i_gid = (gid_t)raw_inode->i_gid;
|
||||
i_uid_write(inode, raw_inode->i_uid);
|
||||
i_gid_write(inode, raw_inode->i_gid);
|
||||
set_nlink(inode, raw_inode->i_nlinks);
|
||||
inode->i_size = raw_inode->i_size;
|
||||
inode->i_mtime.tv_sec = raw_inode->i_mtime;
|
||||
@ -545,8 +545,8 @@ static struct buffer_head * V1_minix_update_inode(struct inode * inode)
|
||||
if (!raw_inode)
|
||||
return NULL;
|
||||
raw_inode->i_mode = inode->i_mode;
|
||||
raw_inode->i_uid = fs_high2lowuid(inode->i_uid);
|
||||
raw_inode->i_gid = fs_high2lowgid(inode->i_gid);
|
||||
raw_inode->i_uid = fs_high2lowuid(i_uid_read(inode));
|
||||
raw_inode->i_gid = fs_high2lowgid(i_gid_read(inode));
|
||||
raw_inode->i_nlinks = inode->i_nlink;
|
||||
raw_inode->i_size = inode->i_size;
|
||||
raw_inode->i_time = inode->i_mtime.tv_sec;
|
||||
@ -572,8 +572,8 @@ static struct buffer_head * V2_minix_update_inode(struct inode * inode)
|
||||
if (!raw_inode)
|
||||
return NULL;
|
||||
raw_inode->i_mode = inode->i_mode;
|
||||
raw_inode->i_uid = fs_high2lowuid(inode->i_uid);
|
||||
raw_inode->i_gid = fs_high2lowgid(inode->i_gid);
|
||||
raw_inode->i_uid = fs_high2lowuid(i_uid_read(inode));
|
||||
raw_inode->i_gid = fs_high2lowgid(i_gid_read(inode));
|
||||
raw_inode->i_nlinks = inode->i_nlink;
|
||||
raw_inode->i_size = inode->i_size;
|
||||
raw_inode->i_mtime = inode->i_mtime.tv_sec;
|
||||
|
@ -680,7 +680,7 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
|
||||
|
||||
/* Allowed if owner and follower match. */
|
||||
inode = link->dentry->d_inode;
|
||||
if (current_cred()->fsuid == inode->i_uid)
|
||||
if (uid_eq(current_cred()->fsuid, inode->i_uid))
|
||||
return 0;
|
||||
|
||||
/* Allowed if parent directory not sticky and world-writable. */
|
||||
@ -689,7 +689,7 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
|
||||
return 0;
|
||||
|
||||
/* Allowed if parent directory and link owner match. */
|
||||
if (parent->i_uid == inode->i_uid)
|
||||
if (uid_eq(parent->i_uid, inode->i_uid))
|
||||
return 0;
|
||||
|
||||
path_put_conditional(link, nd);
|
||||
@ -759,7 +759,7 @@ static int may_linkat(struct path *link)
|
||||
/* Source inode owner (or CAP_FOWNER) can hardlink all they like,
|
||||
* otherwise, it must be a safe source.
|
||||
*/
|
||||
if (cred->fsuid == inode->i_uid || safe_hardlink_source(inode) ||
|
||||
if (uid_eq(cred->fsuid, inode->i_uid) || safe_hardlink_source(inode) ||
|
||||
capable(CAP_FOWNER))
|
||||
return 0;
|
||||
|
||||
|
@ -70,7 +70,7 @@ ssize_t nfs3_getxattr(struct dentry *dentry, const char *name,
|
||||
if (type == ACL_TYPE_ACCESS && acl->a_count == 0)
|
||||
error = -ENODATA;
|
||||
else
|
||||
error = posix_acl_to_xattr(acl, buffer, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
} else
|
||||
error = -ENODATA;
|
||||
@ -92,7 +92,7 @@ int nfs3_setxattr(struct dentry *dentry, const char *name,
|
||||
else
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
error = nfs3_proc_setacl(inode, type, acl);
|
||||
|
@ -480,7 +480,7 @@ set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key)
|
||||
if (buf == NULL)
|
||||
goto out;
|
||||
|
||||
len = posix_acl_to_xattr(pacl, buf, buflen);
|
||||
len = posix_acl_to_xattr(&init_user_ns, pacl, buf, buflen);
|
||||
if (len < 0) {
|
||||
error = len;
|
||||
goto out;
|
||||
@ -549,7 +549,7 @@ _get_posix_acl(struct dentry *dentry, char *key)
|
||||
if (buflen <= 0)
|
||||
return ERR_PTR(buflen);
|
||||
|
||||
pacl = posix_acl_from_xattr(buf, buflen);
|
||||
pacl = posix_acl_from_xattr(&init_user_ns, buf, buflen);
|
||||
kfree(buf);
|
||||
return pacl;
|
||||
}
|
||||
@ -2264,7 +2264,7 @@ nfsd_get_posix_acl(struct svc_fh *fhp, int type)
|
||||
if (size < 0)
|
||||
return ERR_PTR(size);
|
||||
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
kfree(value);
|
||||
return acl;
|
||||
}
|
||||
@ -2297,7 +2297,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
|
||||
value = kmalloc(size, GFP_KERNEL);
|
||||
if (!value)
|
||||
return -ENOMEM;
|
||||
error = posix_acl_to_xattr(acl, value, size);
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
|
||||
if (error < 0)
|
||||
goto getout;
|
||||
size = error;
|
||||
|
@ -401,8 +401,8 @@ int nilfs_read_inode_common(struct inode *inode,
|
||||
int err;
|
||||
|
||||
inode->i_mode = le16_to_cpu(raw_inode->i_mode);
|
||||
inode->i_uid = (uid_t)le32_to_cpu(raw_inode->i_uid);
|
||||
inode->i_gid = (gid_t)le32_to_cpu(raw_inode->i_gid);
|
||||
i_uid_write(inode, le32_to_cpu(raw_inode->i_uid));
|
||||
i_gid_write(inode, le32_to_cpu(raw_inode->i_gid));
|
||||
set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
|
||||
inode->i_size = le64_to_cpu(raw_inode->i_size);
|
||||
inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
|
||||
@ -590,8 +590,8 @@ void nilfs_write_inode_common(struct inode *inode,
|
||||
struct nilfs_inode_info *ii = NILFS_I(inode);
|
||||
|
||||
raw_inode->i_mode = cpu_to_le16(inode->i_mode);
|
||||
raw_inode->i_uid = cpu_to_le32(inode->i_uid);
|
||||
raw_inode->i_gid = cpu_to_le32(inode->i_gid);
|
||||
raw_inode->i_uid = cpu_to_le32(i_uid_read(inode));
|
||||
raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));
|
||||
raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
|
||||
raw_inode->i_size = cpu_to_le64(inode->i_size);
|
||||
raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
|
||||
|
@ -2124,7 +2124,8 @@ int ntfs_read_inode_mount(struct inode *vi)
|
||||
* ntfs_read_inode() will have set up the default ones.
|
||||
*/
|
||||
/* Set uid and gid to root. */
|
||||
vi->i_uid = vi->i_gid = 0;
|
||||
vi->i_uid = GLOBAL_ROOT_UID;
|
||||
vi->i_gid = GLOBAL_ROOT_GID;
|
||||
/* Regular file. No access for anyone. */
|
||||
vi->i_mode = S_IFREG;
|
||||
/* No VFS initiated operations allowed for $MFT. */
|
||||
@ -2312,8 +2313,8 @@ int ntfs_show_options(struct seq_file *sf, struct dentry *root)
|
||||
ntfs_volume *vol = NTFS_SB(root->d_sb);
|
||||
int i;
|
||||
|
||||
seq_printf(sf, ",uid=%i", vol->uid);
|
||||
seq_printf(sf, ",gid=%i", vol->gid);
|
||||
seq_printf(sf, ",uid=%i", from_kuid_munged(&init_user_ns, vol->uid));
|
||||
seq_printf(sf, ",gid=%i", from_kgid_munged(&init_user_ns, vol->gid));
|
||||
if (vol->fmask == vol->dmask)
|
||||
seq_printf(sf, ",umask=0%o", vol->fmask);
|
||||
else {
|
||||
|
@ -102,8 +102,8 @@ static bool parse_options(ntfs_volume *vol, char *opt)
|
||||
char *p, *v, *ov;
|
||||
static char *utf8 = "utf8";
|
||||
int errors = 0, sloppy = 0;
|
||||
uid_t uid = (uid_t)-1;
|
||||
gid_t gid = (gid_t)-1;
|
||||
kuid_t uid = INVALID_UID;
|
||||
kgid_t gid = INVALID_GID;
|
||||
umode_t fmask = (umode_t)-1, dmask = (umode_t)-1;
|
||||
int mft_zone_multiplier = -1, on_errors = -1;
|
||||
int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1;
|
||||
@ -128,6 +128,30 @@ static bool parse_options(ntfs_volume *vol, char *opt)
|
||||
if (*v) \
|
||||
goto needs_val; \
|
||||
}
|
||||
#define NTFS_GETOPT_UID(option, variable) \
|
||||
if (!strcmp(p, option)) { \
|
||||
uid_t uid_value; \
|
||||
if (!v || !*v) \
|
||||
goto needs_arg; \
|
||||
uid_value = simple_strtoul(ov = v, &v, 0); \
|
||||
if (*v) \
|
||||
goto needs_val; \
|
||||
variable = make_kuid(current_user_ns(), uid_value); \
|
||||
if (!uid_valid(variable)) \
|
||||
goto needs_val; \
|
||||
}
|
||||
#define NTFS_GETOPT_GID(option, variable) \
|
||||
if (!strcmp(p, option)) { \
|
||||
gid_t gid_value; \
|
||||
if (!v || !*v) \
|
||||
goto needs_arg; \
|
||||
gid_value = simple_strtoul(ov = v, &v, 0); \
|
||||
if (*v) \
|
||||
goto needs_val; \
|
||||
variable = make_kgid(current_user_ns(), gid_value); \
|
||||
if (!gid_valid(variable)) \
|
||||
goto needs_val; \
|
||||
}
|
||||
#define NTFS_GETOPT_OCTAL(option, variable) \
|
||||
if (!strcmp(p, option)) { \
|
||||
if (!v || !*v) \
|
||||
@ -165,8 +189,8 @@ static bool parse_options(ntfs_volume *vol, char *opt)
|
||||
while ((p = strsep(&opt, ","))) {
|
||||
if ((v = strchr(p, '=')))
|
||||
*v++ = 0;
|
||||
NTFS_GETOPT("uid", uid)
|
||||
else NTFS_GETOPT("gid", gid)
|
||||
NTFS_GETOPT_UID("uid", uid)
|
||||
else NTFS_GETOPT_GID("gid", gid)
|
||||
else NTFS_GETOPT_OCTAL("umask", fmask = dmask)
|
||||
else NTFS_GETOPT_OCTAL("fmask", fmask)
|
||||
else NTFS_GETOPT_OCTAL("dmask", dmask)
|
||||
@ -283,9 +307,9 @@ no_mount_options:
|
||||
vol->on_errors = on_errors;
|
||||
if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER)
|
||||
vol->on_errors |= ON_ERRORS_CONTINUE;
|
||||
if (uid != (uid_t)-1)
|
||||
if (uid_valid(uid))
|
||||
vol->uid = uid;
|
||||
if (gid != (gid_t)-1)
|
||||
if (gid_valid(gid))
|
||||
vol->gid = gid;
|
||||
if (fmask != (umode_t)-1)
|
||||
vol->fmask = fmask;
|
||||
@ -1023,7 +1047,8 @@ static bool load_and_init_mft_mirror(ntfs_volume *vol)
|
||||
* ntfs_read_inode() will have set up the default ones.
|
||||
*/
|
||||
/* Set uid and gid to root. */
|
||||
tmp_ino->i_uid = tmp_ino->i_gid = 0;
|
||||
tmp_ino->i_uid = GLOBAL_ROOT_UID;
|
||||
tmp_ino->i_gid = GLOBAL_ROOT_GID;
|
||||
/* Regular file. No access for anyone. */
|
||||
tmp_ino->i_mode = S_IFREG;
|
||||
/* No VFS initiated operations allowed for $MFTMirr. */
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define _LINUX_NTFS_VOLUME_H
|
||||
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/uidgid.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "layout.h"
|
||||
@ -46,8 +47,8 @@ typedef struct {
|
||||
sized blocks on the device. */
|
||||
/* Configuration provided by user at mount time. */
|
||||
unsigned long flags; /* Miscellaneous flags, see below. */
|
||||
uid_t uid; /* uid that files will be mounted as. */
|
||||
gid_t gid; /* gid that files will be mounted as. */
|
||||
kuid_t uid; /* uid that files will be mounted as. */
|
||||
kgid_t gid; /* gid that files will be mounted as. */
|
||||
umode_t fmask; /* The mask for file permissions. */
|
||||
umode_t dmask; /* The mask for directory
|
||||
permissions. */
|
||||
|
@ -452,7 +452,7 @@ static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name,
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
ret = posix_acl_to_xattr(acl, buffer, size);
|
||||
ret = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return ret;
|
||||
@ -475,7 +475,7 @@ static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name,
|
||||
return -EPERM;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(value, size);
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
else if (acl) {
|
||||
|
@ -1184,8 +1184,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
|
||||
&& OCFS2_HAS_RO_COMPAT_FEATURE(sb,
|
||||
OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
|
||||
transfer_to[USRQUOTA] = dqget(sb, attr->ia_uid,
|
||||
USRQUOTA);
|
||||
transfer_to[USRQUOTA] = dqget(sb, make_kqid_uid(attr->ia_uid));
|
||||
if (!transfer_to[USRQUOTA]) {
|
||||
status = -ESRCH;
|
||||
goto bail_unlock;
|
||||
@ -1194,8 +1193,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
|
||||
if (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid
|
||||
&& OCFS2_HAS_RO_COMPAT_FEATURE(sb,
|
||||
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
|
||||
transfer_to[GRPQUOTA] = dqget(sb, attr->ia_gid,
|
||||
GRPQUOTA);
|
||||
transfer_to[GRPQUOTA] = dqget(sb, make_kqid_gid(attr->ia_gid));
|
||||
if (!transfer_to[GRPQUOTA]) {
|
||||
status = -ESRCH;
|
||||
goto bail_unlock;
|
||||
|
@ -95,7 +95,7 @@ static void ocfs2_global_mem2diskdqb(void *dp, struct dquot *dquot)
|
||||
struct ocfs2_global_disk_dqblk *d = dp;
|
||||
struct mem_dqblk *m = &dquot->dq_dqb;
|
||||
|
||||
d->dqb_id = cpu_to_le32(dquot->dq_id);
|
||||
d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id));
|
||||
d->dqb_use_count = cpu_to_le32(OCFS2_DQUOT(dquot)->dq_use_count);
|
||||
d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
|
||||
d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
|
||||
@ -112,11 +112,14 @@ static int ocfs2_global_is_id(void *dp, struct dquot *dquot)
|
||||
{
|
||||
struct ocfs2_global_disk_dqblk *d = dp;
|
||||
struct ocfs2_mem_dqinfo *oinfo =
|
||||
sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
|
||||
sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
|
||||
|
||||
if (qtree_entry_unused(&oinfo->dqi_gi, dp))
|
||||
return 0;
|
||||
return le32_to_cpu(d->dqb_id) == dquot->dq_id;
|
||||
|
||||
return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type,
|
||||
le32_to_cpu(d->dqb_id)),
|
||||
dquot->dq_id);
|
||||
}
|
||||
|
||||
struct qtree_fmt_operations ocfs2_global_ops = {
|
||||
@ -475,7 +478,7 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
|
||||
{
|
||||
int err, err2;
|
||||
struct super_block *sb = dquot->dq_sb;
|
||||
int type = dquot->dq_type;
|
||||
int type = dquot->dq_id.type;
|
||||
struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
|
||||
struct ocfs2_global_disk_dqblk dqblk;
|
||||
s64 spacechange, inodechange;
|
||||
@ -504,7 +507,8 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
|
||||
olditime = dquot->dq_dqb.dqb_itime;
|
||||
oldbtime = dquot->dq_dqb.dqb_btime;
|
||||
ocfs2_global_disk2memdqb(dquot, &dqblk);
|
||||
trace_ocfs2_sync_dquot(dquot->dq_id, dquot->dq_dqb.dqb_curspace,
|
||||
trace_ocfs2_sync_dquot(from_kqid(&init_user_ns, dquot->dq_id),
|
||||
dquot->dq_dqb.dqb_curspace,
|
||||
(long long)spacechange,
|
||||
dquot->dq_dqb.dqb_curinodes,
|
||||
(long long)inodechange);
|
||||
@ -555,8 +559,8 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
|
||||
err = ocfs2_qinfo_lock(info, freeing);
|
||||
if (err < 0) {
|
||||
mlog(ML_ERROR, "Failed to lock quota info, losing quota write"
|
||||
" (type=%d, id=%u)\n", dquot->dq_type,
|
||||
(unsigned)dquot->dq_id);
|
||||
" (type=%d, id=%u)\n", dquot->dq_id.type,
|
||||
(unsigned)from_kqid(&init_user_ns, dquot->dq_id));
|
||||
goto out;
|
||||
}
|
||||
if (freeing)
|
||||
@ -591,9 +595,10 @@ static int ocfs2_sync_dquot_helper(struct dquot *dquot, unsigned long type)
|
||||
struct ocfs2_super *osb = OCFS2_SB(sb);
|
||||
int status = 0;
|
||||
|
||||
trace_ocfs2_sync_dquot_helper(dquot->dq_id, dquot->dq_type,
|
||||
trace_ocfs2_sync_dquot_helper(from_kqid(&init_user_ns, dquot->dq_id),
|
||||
dquot->dq_id.type,
|
||||
type, sb->s_id);
|
||||
if (type != dquot->dq_type)
|
||||
if (type != dquot->dq_id.type)
|
||||
goto out;
|
||||
status = ocfs2_lock_global_qf(oinfo, 1);
|
||||
if (status < 0)
|
||||
@ -643,7 +648,8 @@ static int ocfs2_write_dquot(struct dquot *dquot)
|
||||
struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
|
||||
int status = 0;
|
||||
|
||||
trace_ocfs2_write_dquot(dquot->dq_id, dquot->dq_type);
|
||||
trace_ocfs2_write_dquot(from_kqid(&init_user_ns, dquot->dq_id),
|
||||
dquot->dq_id.type);
|
||||
|
||||
handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS);
|
||||
if (IS_ERR(handle)) {
|
||||
@ -677,11 +683,12 @@ static int ocfs2_release_dquot(struct dquot *dquot)
|
||||
{
|
||||
handle_t *handle;
|
||||
struct ocfs2_mem_dqinfo *oinfo =
|
||||
sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
|
||||
sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
|
||||
struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
|
||||
int status = 0;
|
||||
|
||||
trace_ocfs2_release_dquot(dquot->dq_id, dquot->dq_type);
|
||||
trace_ocfs2_release_dquot(from_kqid(&init_user_ns, dquot->dq_id),
|
||||
dquot->dq_id.type);
|
||||
|
||||
mutex_lock(&dquot->dq_lock);
|
||||
/* Check whether we are not racing with some other dqget() */
|
||||
@ -691,7 +698,7 @@ static int ocfs2_release_dquot(struct dquot *dquot)
|
||||
if (status < 0)
|
||||
goto out;
|
||||
handle = ocfs2_start_trans(osb,
|
||||
ocfs2_calc_qdel_credits(dquot->dq_sb, dquot->dq_type));
|
||||
ocfs2_calc_qdel_credits(dquot->dq_sb, dquot->dq_id.type));
|
||||
if (IS_ERR(handle)) {
|
||||
status = PTR_ERR(handle);
|
||||
mlog_errno(status);
|
||||
@ -733,13 +740,14 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
|
||||
int ex = 0;
|
||||
struct super_block *sb = dquot->dq_sb;
|
||||
struct ocfs2_super *osb = OCFS2_SB(sb);
|
||||
int type = dquot->dq_type;
|
||||
int type = dquot->dq_id.type;
|
||||
struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
|
||||
struct inode *gqinode = info->dqi_gqinode;
|
||||
int need_alloc = ocfs2_global_qinit_alloc(sb, type);
|
||||
handle_t *handle;
|
||||
|
||||
trace_ocfs2_acquire_dquot(dquot->dq_id, type);
|
||||
trace_ocfs2_acquire_dquot(from_kqid(&init_user_ns, dquot->dq_id),
|
||||
type);
|
||||
mutex_lock(&dquot->dq_lock);
|
||||
/*
|
||||
* We need an exclusive lock, because we're going to update use count
|
||||
@ -821,12 +829,13 @@ static int ocfs2_mark_dquot_dirty(struct dquot *dquot)
|
||||
int sync = 0;
|
||||
int status;
|
||||
struct super_block *sb = dquot->dq_sb;
|
||||
int type = dquot->dq_type;
|
||||
int type = dquot->dq_id.type;
|
||||
struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
|
||||
handle_t *handle;
|
||||
struct ocfs2_super *osb = OCFS2_SB(sb);
|
||||
|
||||
trace_ocfs2_mark_dquot_dirty(dquot->dq_id, type);
|
||||
trace_ocfs2_mark_dquot_dirty(from_kqid(&init_user_ns, dquot->dq_id),
|
||||
type);
|
||||
|
||||
/* In case user set some limits, sync dquot immediately to global
|
||||
* quota file so that information propagates quicker */
|
||||
|
@ -501,7 +501,9 @@ static int ocfs2_recover_local_quota_file(struct inode *lqinode,
|
||||
}
|
||||
dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data +
|
||||
ol_dqblk_block_off(sb, chunk, bit));
|
||||
dquot = dqget(sb, le64_to_cpu(dqblk->dqb_id), type);
|
||||
dquot = dqget(sb,
|
||||
make_kqid(&init_user_ns, type,
|
||||
le64_to_cpu(dqblk->dqb_id)));
|
||||
if (!dquot) {
|
||||
status = -EIO;
|
||||
mlog(ML_ERROR, "Failed to get quota structure "
|
||||
@ -881,7 +883,8 @@ static void olq_set_dquot(struct buffer_head *bh, void *private)
|
||||
dqblk = (struct ocfs2_local_disk_dqblk *)(bh->b_data
|
||||
+ ol_dqblk_block_offset(sb, od->dq_local_off));
|
||||
|
||||
dqblk->dqb_id = cpu_to_le64(od->dq_dquot.dq_id);
|
||||
dqblk->dqb_id = cpu_to_le64(from_kqid(&init_user_ns,
|
||||
od->dq_dquot.dq_id));
|
||||
spin_lock(&dq_data_lock);
|
||||
dqblk->dqb_spacemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curspace -
|
||||
od->dq_origspace);
|
||||
@ -891,7 +894,7 @@ static void olq_set_dquot(struct buffer_head *bh, void *private)
|
||||
trace_olq_set_dquot(
|
||||
(unsigned long long)le64_to_cpu(dqblk->dqb_spacemod),
|
||||
(unsigned long long)le64_to_cpu(dqblk->dqb_inodemod),
|
||||
od->dq_dquot.dq_id);
|
||||
from_kqid(&init_user_ns, od->dq_dquot.dq_id));
|
||||
}
|
||||
|
||||
/* Write dquot to local quota file */
|
||||
@ -900,7 +903,7 @@ int ocfs2_local_write_dquot(struct dquot *dquot)
|
||||
struct super_block *sb = dquot->dq_sb;
|
||||
struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
|
||||
struct buffer_head *bh;
|
||||
struct inode *lqinode = sb_dqopt(sb)->files[dquot->dq_type];
|
||||
struct inode *lqinode = sb_dqopt(sb)->files[dquot->dq_id.type];
|
||||
int status;
|
||||
|
||||
status = ocfs2_read_quota_phys_block(lqinode, od->dq_local_phys_blk,
|
||||
@ -1221,7 +1224,7 @@ static void olq_alloc_dquot(struct buffer_head *bh, void *private)
|
||||
int ocfs2_create_local_dquot(struct dquot *dquot)
|
||||
{
|
||||
struct super_block *sb = dquot->dq_sb;
|
||||
int type = dquot->dq_type;
|
||||
int type = dquot->dq_id.type;
|
||||
struct inode *lqinode = sb_dqopt(sb)->files[type];
|
||||
struct ocfs2_quota_chunk *chunk;
|
||||
struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
|
||||
@ -1275,7 +1278,7 @@ out:
|
||||
int ocfs2_local_release_dquot(handle_t *handle, struct dquot *dquot)
|
||||
{
|
||||
int status;
|
||||
int type = dquot->dq_type;
|
||||
int type = dquot->dq_id.type;
|
||||
struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
|
||||
struct super_block *sb = dquot->dq_sb;
|
||||
struct ocfs2_local_disk_chunk *dchunk;
|
||||
|
@ -391,12 +391,16 @@ static int parse_options(char *options, struct omfs_sb_info *sbi)
|
||||
case Opt_uid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
sbi->s_uid = option;
|
||||
sbi->s_uid = make_kuid(current_user_ns(), option);
|
||||
if (!uid_valid(sbi->s_uid))
|
||||
return 0;
|
||||
break;
|
||||
case Opt_gid:
|
||||
if (match_int(&args[0], &option))
|
||||
return 0;
|
||||
sbi->s_gid = option;
|
||||
sbi->s_gid = make_kgid(current_user_ns(), option);
|
||||
if (!gid_valid(sbi->s_gid))
|
||||
return 0;
|
||||
break;
|
||||
case Opt_umask:
|
||||
if (match_octal(&args[0], &option))
|
||||
|
@ -19,8 +19,8 @@ struct omfs_sb_info {
|
||||
unsigned long **s_imap;
|
||||
int s_imap_size;
|
||||
struct mutex s_bitmap_lock;
|
||||
int s_uid;
|
||||
int s_gid;
|
||||
kuid_t s_uid;
|
||||
kgid_t s_gid;
|
||||
int s_dmask;
|
||||
int s_fmask;
|
||||
};
|
||||
|
@ -534,7 +534,7 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
|
||||
newattrs.ia_valid |=
|
||||
ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
|
||||
mutex_lock(&inode->i_mutex);
|
||||
error = security_path_chown(path, user, group);
|
||||
error = security_path_chown(path, uid, gid);
|
||||
if (!error)
|
||||
error = notify_change(path->dentry, &newattrs);
|
||||
mutex_unlock(&inode->i_mutex);
|
||||
|
@ -78,7 +78,8 @@ posix_acl_valid(const struct posix_acl *acl)
|
||||
{
|
||||
const struct posix_acl_entry *pa, *pe;
|
||||
int state = ACL_USER_OBJ;
|
||||
unsigned int id = 0; /* keep gcc happy */
|
||||
kuid_t prev_uid = INVALID_UID;
|
||||
kgid_t prev_gid = INVALID_GID;
|
||||
int needs_mask = 0;
|
||||
|
||||
FOREACH_ACL_ENTRY(pa, acl, pe) {
|
||||
@ -87,7 +88,6 @@ posix_acl_valid(const struct posix_acl *acl)
|
||||
switch (pa->e_tag) {
|
||||
case ACL_USER_OBJ:
|
||||
if (state == ACL_USER_OBJ) {
|
||||
id = 0;
|
||||
state = ACL_USER;
|
||||
break;
|
||||
}
|
||||
@ -96,16 +96,17 @@ posix_acl_valid(const struct posix_acl *acl)
|
||||
case ACL_USER:
|
||||
if (state != ACL_USER)
|
||||
return -EINVAL;
|
||||
if (pa->e_id == ACL_UNDEFINED_ID ||
|
||||
pa->e_id < id)
|
||||
if (!uid_valid(pa->e_uid))
|
||||
return -EINVAL;
|
||||
id = pa->e_id + 1;
|
||||
if (uid_valid(prev_uid) &&
|
||||
uid_lte(pa->e_uid, prev_uid))
|
||||
return -EINVAL;
|
||||
prev_uid = pa->e_uid;
|
||||
needs_mask = 1;
|
||||
break;
|
||||
|
||||
case ACL_GROUP_OBJ:
|
||||
if (state == ACL_USER) {
|
||||
id = 0;
|
||||
state = ACL_GROUP;
|
||||
break;
|
||||
}
|
||||
@ -114,10 +115,12 @@ posix_acl_valid(const struct posix_acl *acl)
|
||||
case ACL_GROUP:
|
||||
if (state != ACL_GROUP)
|
||||
return -EINVAL;
|
||||
if (pa->e_id == ACL_UNDEFINED_ID ||
|
||||
pa->e_id < id)
|
||||
if (!gid_valid(pa->e_gid))
|
||||
return -EINVAL;
|
||||
id = pa->e_id + 1;
|
||||
if (gid_valid(prev_gid) &&
|
||||
gid_lte(pa->e_gid, prev_gid))
|
||||
return -EINVAL;
|
||||
prev_gid = pa->e_gid;
|
||||
needs_mask = 1;
|
||||
break;
|
||||
|
||||
@ -195,15 +198,12 @@ posix_acl_from_mode(umode_t mode, gfp_t flags)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
acl->a_entries[0].e_tag = ACL_USER_OBJ;
|
||||
acl->a_entries[0].e_id = ACL_UNDEFINED_ID;
|
||||
acl->a_entries[0].e_perm = (mode & S_IRWXU) >> 6;
|
||||
|
||||
acl->a_entries[1].e_tag = ACL_GROUP_OBJ;
|
||||
acl->a_entries[1].e_id = ACL_UNDEFINED_ID;
|
||||
acl->a_entries[1].e_perm = (mode & S_IRWXG) >> 3;
|
||||
|
||||
acl->a_entries[2].e_tag = ACL_OTHER;
|
||||
acl->a_entries[2].e_id = ACL_UNDEFINED_ID;
|
||||
acl->a_entries[2].e_perm = (mode & S_IRWXO);
|
||||
return acl;
|
||||
}
|
||||
@ -224,11 +224,11 @@ posix_acl_permission(struct inode *inode, const struct posix_acl *acl, int want)
|
||||
switch(pa->e_tag) {
|
||||
case ACL_USER_OBJ:
|
||||
/* (May have been checked already) */
|
||||
if (inode->i_uid == current_fsuid())
|
||||
if (uid_eq(inode->i_uid, current_fsuid()))
|
||||
goto check_perm;
|
||||
break;
|
||||
case ACL_USER:
|
||||
if (pa->e_id == current_fsuid())
|
||||
if (uid_eq(pa->e_uid, current_fsuid()))
|
||||
goto mask;
|
||||
break;
|
||||
case ACL_GROUP_OBJ:
|
||||
@ -239,7 +239,7 @@ posix_acl_permission(struct inode *inode, const struct posix_acl *acl, int want)
|
||||
}
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
if (in_group_p(pa->e_id)) {
|
||||
if (in_group_p(pa->e_gid)) {
|
||||
found = 1;
|
||||
if ((pa->e_perm & want) == want)
|
||||
goto mask;
|
||||
|
@ -1089,7 +1089,8 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
|
||||
if (!task)
|
||||
return -ESRCH;
|
||||
length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
|
||||
audit_get_loginuid(task));
|
||||
from_kuid(file->f_cred->user_ns,
|
||||
audit_get_loginuid(task)));
|
||||
put_task_struct(task);
|
||||
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
|
||||
}
|
||||
@ -1101,6 +1102,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
|
||||
char *page, *tmp;
|
||||
ssize_t length;
|
||||
uid_t loginuid;
|
||||
kuid_t kloginuid;
|
||||
|
||||
rcu_read_lock();
|
||||
if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) {
|
||||
@ -1130,7 +1132,13 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
|
||||
goto out_free_page;
|
||||
|
||||
}
|
||||
length = audit_set_loginuid(loginuid);
|
||||
kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
|
||||
if (!uid_valid(kloginuid)) {
|
||||
length = -EINVAL;
|
||||
goto out_free_page;
|
||||
}
|
||||
|
||||
length = audit_set_loginuid(kloginuid);
|
||||
if (likely(length == 0))
|
||||
length = count;
|
||||
|
||||
@ -2983,6 +2991,11 @@ static int proc_gid_map_open(struct inode *inode, struct file *file)
|
||||
return proc_id_map_open(inode, file, &proc_gid_seq_operations);
|
||||
}
|
||||
|
||||
static int proc_projid_map_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return proc_id_map_open(inode, file, &proc_projid_seq_operations);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_uid_map_operations = {
|
||||
.open = proc_uid_map_open,
|
||||
.write = proc_uid_map_write,
|
||||
@ -2998,6 +3011,14 @@ static const struct file_operations proc_gid_map_operations = {
|
||||
.llseek = seq_lseek,
|
||||
.release = proc_id_map_release,
|
||||
};
|
||||
|
||||
static const struct file_operations proc_projid_map_operations = {
|
||||
.open = proc_projid_map_open,
|
||||
.write = proc_projid_map_write,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = proc_id_map_release,
|
||||
};
|
||||
#endif /* CONFIG_USER_NS */
|
||||
|
||||
static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns,
|
||||
@ -3105,6 +3126,7 @@ static const struct pid_entry tgid_base_stuff[] = {
|
||||
#ifdef CONFIG_USER_NS
|
||||
REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
|
||||
REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
|
||||
REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -3468,6 +3490,7 @@ static const struct pid_entry tid_base_stuff[] = {
|
||||
#ifdef CONFIG_USER_NS
|
||||
REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
|
||||
REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
|
||||
REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -312,8 +312,8 @@ struct inode *qnx4_iget(struct super_block *sb, unsigned long ino)
|
||||
(ino % QNX4_INODES_PER_BLOCK);
|
||||
|
||||
inode->i_mode = le16_to_cpu(raw_inode->di_mode);
|
||||
inode->i_uid = (uid_t)le16_to_cpu(raw_inode->di_uid);
|
||||
inode->i_gid = (gid_t)le16_to_cpu(raw_inode->di_gid);
|
||||
i_uid_write(inode, (uid_t)le16_to_cpu(raw_inode->di_uid));
|
||||
i_gid_write(inode, (gid_t)le16_to_cpu(raw_inode->di_gid));
|
||||
set_nlink(inode, le16_to_cpu(raw_inode->di_nlink));
|
||||
inode->i_size = le32_to_cpu(raw_inode->di_size);
|
||||
inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->di_mtime);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user