Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6dff3ec authored by David Howells's avatar David Howells Committed by James Morris
Browse files

CRED: Separate task security context from task_struct



Separate the task security context from task_struct.  At this point, the
security data is temporarily embedded in the task_struct with two pointers
pointing to it.

Note that the Alpha arch is altered as it refers to (E)UID and (E)GID in
entry.S via asm-offsets.

With comment fixes Signed-off-by: default avatarMarc Dionne <marc.c.dionne@gmail.com>

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarJames Morris <jmorris@namei.org>
Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 15a2460e
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -19,15 +19,18 @@ void foo(void)
	BLANK();

        DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
        DEFINE(TASK_UID, offsetof(struct task_struct, uid));
        DEFINE(TASK_EUID, offsetof(struct task_struct, euid));
        DEFINE(TASK_GID, offsetof(struct task_struct, gid));
        DEFINE(TASK_EGID, offsetof(struct task_struct, egid));
        DEFINE(TASK_CRED, offsetof(struct task_struct, cred));
        DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent));
        DEFINE(TASK_GROUP_LEADER, offsetof(struct task_struct, group_leader));
        DEFINE(TASK_TGID, offsetof(struct task_struct, tgid));
        BLANK();

        DEFINE(CRED_UID,  offsetof(struct cred, uid));
        DEFINE(CRED_EUID, offsetof(struct cred, euid));
        DEFINE(CRED_GID,  offsetof(struct cred, gid));
        DEFINE(CRED_EGID, offsetof(struct cred, egid));
        BLANK();

	DEFINE(SIZEOF_PT_REGS, sizeof(struct pt_regs));
	DEFINE(PT_PTRACED, PT_PTRACED);
	DEFINE(CLONE_VM, CLONE_VM);
+6 −4
Original line number Diff line number Diff line
@@ -850,8 +850,9 @@ osf_getpriority:
sys_getxuid:
	.prologue 0
	ldq	$2, TI_TASK($8)
	ldl	$0, TASK_UID($2)
	ldl	$1, TASK_EUID($2)
	ldq	$3, TASK_CRED($2)
	ldl	$0, CRED_UID($3)
	ldl	$1, CRED_EUID($3)
	stq	$1, 80($sp)
	ret
.end sys_getxuid
@@ -862,8 +863,9 @@ sys_getxuid:
sys_getxgid:
	.prologue 0
	ldq	$2, TI_TASK($8)
	ldl	$0, TASK_GID($2)
	ldl	$1, TASK_EGID($2)
	ldq	$3, TASK_CRED($2)
	ldl	$0, CRED_GID($3)
	ldl	$1, CRED_EGID($3)
	stq	$1, 80($sp)
	ret
.end sys_getxgid
+4 −4
Original line number Diff line number Diff line
@@ -1772,20 +1772,20 @@ sys32_getgroups16 (int gidsetsize, short __user *grouplist)
	if (gidsetsize < 0)
		return -EINVAL;

	get_group_info(current->group_info);
	i = current->group_info->ngroups;
	get_group_info(current->cred->group_info);
	i = current->cred->group_info->ngroups;
	if (gidsetsize) {
		if (i > gidsetsize) {
			i = -EINVAL;
			goto out;
		}
		if (groups16_to_user(grouplist, current->group_info)) {
		if (groups16_to_user(grouplist, current->cred->group_info)) {
			i = -EFAULT;
			goto out;
		}
	}
out:
	put_group_info(current->group_info);
	put_group_info(current->cred->group_info);
	return i;
}

+2 −2
Original line number Diff line number Diff line
@@ -174,8 +174,8 @@ static unsigned int translate_open_flags(int flags)

static void sp_setfsuidgid( uid_t uid, gid_t gid)
{
	current->fsuid = uid;
	current->fsgid = gid;
	current->cred->fsuid = uid;
	current->cred->fsgid = gid;

	key_fsuid_changed(current);
	key_fsgid_changed(current);
+14 −14
Original line number Diff line number Diff line
@@ -148,9 +148,9 @@ asmlinkage long sys32_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user
{
	int retval;

	if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
	    !(retval = put_user(high2lowuid(current->euid), euid)))
		retval = put_user(high2lowuid(current->suid), 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);

	return retval;
}
@@ -165,9 +165,9 @@ asmlinkage long sys32_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user
{
	int retval;

	if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
	    !(retval = put_user(high2lowgid(current->egid), egid)))
		retval = put_user(high2lowgid(current->sgid), 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);

	return retval;
}
@@ -217,20 +217,20 @@ asmlinkage long sys32_getgroups16(int gidsetsize, u16 __user *grouplist)
	if (gidsetsize < 0)
		return -EINVAL;

	get_group_info(current->group_info);
	i = current->group_info->ngroups;
	get_group_info(current->cred->group_info);
	i = current->cred->group_info->ngroups;
	if (gidsetsize) {
		if (i > gidsetsize) {
			i = -EINVAL;
			goto out;
		}
		if (groups16_to_user(grouplist, current->group_info)) {
		if (groups16_to_user(grouplist, current->cred->group_info)) {
			i = -EFAULT;
			goto out;
		}
	}
out:
	put_group_info(current->group_info);
	put_group_info(current->cred->group_info);
	return i;
}

@@ -261,22 +261,22 @@ asmlinkage long sys32_setgroups16(int gidsetsize, u16 __user *grouplist)

asmlinkage long sys32_getuid16(void)
{
	return high2lowuid(current->uid);
	return high2lowuid(current->cred->uid);
}

asmlinkage long sys32_geteuid16(void)
{
	return high2lowuid(current->euid);
	return high2lowuid(current->cred->euid);
}

asmlinkage long sys32_getgid16(void)
{
	return high2lowgid(current->gid);
	return high2lowgid(current->cred->gid);
}

asmlinkage long sys32_getegid16(void)
{
	return high2lowgid(current->egid);
	return high2lowgid(current->cred->egid);
}

/*
Loading