/* change the user struct in a credentials set to match the new UID  */
static int set_user(struct cred *new)
/* change the user struct in a credentials set to match the new UID  */
static int set_user(struct cred *new)
{
	struct user_struct *new_user;
	new_user = alloc_uid(current_user_ns(), new->uid);
	if (!new_user)
		return -EAGAIN;
	if (!task_can_switch_user(new_user, current)) {
		free_uid(new_user);
		return -EINVAL;
	}
	if (atomic_read(&new_user->processes) >=
				current->signal->rlim[RLIMIT_NPROC].rlim_cur &&
			new_user != INIT_USER) {
		free_uid(new_user);
		return -EAGAIN;
	}
	free_uid(new->user);
	new->user = new_user;
	return 0;
}