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

Commit e0b93edd authored by Jeff Layton's avatar Jeff Layton
Browse files

security: make security_file_set_fowner, f_setown and __f_setown void return



security_file_set_fowner always returns 0, so make it f_setown and
__f_setown void return functions and fix up the error handling in the
callers.

Cc: linux-security-module@vger.kernel.org
Signed-off-by: default avatarJeff Layton <jlayton@primarydata.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 1c994a09
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -2152,9 +2152,7 @@ static int tun_chr_fasync(int fd, struct file *file, int on)
		goto out;
		goto out;


	if (on) {
	if (on) {
		ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0);
		__f_setown(file, task_pid(current), PIDTYPE_PID, 0);
		if (ret)
			goto out;
		tfile->flags |= TUN_FASYNC;
		tfile->flags |= TUN_FASYNC;
	} else
	} else
		tfile->flags &= ~TUN_FASYNC;
		tfile->flags &= ~TUN_FASYNC;
+2 −1
Original line number Original line Diff line number Diff line
@@ -2163,8 +2163,9 @@ static int __tty_fasync(int fd, struct file *filp, int on)
		}
		}
		get_pid(pid);
		get_pid(pid);
		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
		retval = __f_setown(filp, pid, type, 0);
		__f_setown(filp, pid, type, 0);
		put_pid(pid);
		put_pid(pid);
		retval = 0;
	}
	}
out:
out:
	return retval;
	return retval;
+7 −14
Original line number Original line Diff line number Diff line
@@ -98,26 +98,19 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
	write_unlock_irq(&filp->f_owner.lock);
	write_unlock_irq(&filp->f_owner.lock);
}
}


int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
		int force)
		int force)
{
{
	int err;
	security_file_set_fowner(filp);

	err = security_file_set_fowner(filp);
	if (err)
		return err;

	f_modown(filp, pid, type, force);
	f_modown(filp, pid, type, force);
	return 0;
}
}
EXPORT_SYMBOL(__f_setown);
EXPORT_SYMBOL(__f_setown);


int f_setown(struct file *filp, unsigned long arg, int force)
void f_setown(struct file *filp, unsigned long arg, int force)
{
{
	enum pid_type type;
	enum pid_type type;
	struct pid *pid;
	struct pid *pid;
	int who = arg;
	int who = arg;
	int result;
	type = PIDTYPE_PID;
	type = PIDTYPE_PID;
	if (who < 0) {
	if (who < 0) {
		type = PIDTYPE_PGID;
		type = PIDTYPE_PGID;
@@ -125,9 +118,8 @@ int f_setown(struct file *filp, unsigned long arg, int force)
	}
	}
	rcu_read_lock();
	rcu_read_lock();
	pid = find_vpid(who);
	pid = find_vpid(who);
	result = __f_setown(filp, pid, type, force);
	__f_setown(filp, pid, type, force);
	rcu_read_unlock();
	rcu_read_unlock();
	return result;
}
}
EXPORT_SYMBOL(f_setown);
EXPORT_SYMBOL(f_setown);


@@ -181,7 +173,7 @@ static int f_setown_ex(struct file *filp, unsigned long arg)
	if (owner.pid && !pid)
	if (owner.pid && !pid)
		ret = -ESRCH;
		ret = -ESRCH;
	else
	else
		ret = __f_setown(filp, pid, type, 1);
		 __f_setown(filp, pid, type, 1);
	rcu_read_unlock();
	rcu_read_unlock();


	return ret;
	return ret;
@@ -302,7 +294,8 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
		force_successful_syscall_return();
		force_successful_syscall_return();
		break;
		break;
	case F_SETOWN:
	case F_SETOWN:
		err = f_setown(filp, arg, 1);
		f_setown(filp, arg, 1);
		err = 0;
		break;
		break;
	case F_GETOWN_EX:
	case F_GETOWN_EX:
		err = f_getown_ex(filp, arg);
		err = f_getown_ex(filp, arg);
+1 −1
Original line number Original line Diff line number Diff line
@@ -1776,7 +1776,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
	if (!fasync_insert_entry(fd, filp, &ret->fl_fasync, new))
	if (!fasync_insert_entry(fd, filp, &ret->fl_fasync, new))
		new = NULL;
		new = NULL;


	error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
	__f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
out_unlock:
out_unlock:
	spin_unlock(&inode->i_lock);
	spin_unlock(&inode->i_lock);
	if (fl)
	if (fl)
+1 −7
Original line number Original line Diff line number Diff line
@@ -346,13 +346,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
		goto out;
		goto out;
	}
	}


	error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
	__f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
	if (error) {
		/* if we added, we must shoot */
		if (dn_mark == new_dn_mark)
			destroy = 1;
		goto out;
	}


	error = attach_dn(dn, dn_mark, id, fd, filp, mask);
	error = attach_dn(dn, dn_mark, id, fd, filp, mask);
	/* !error means that we attached the dn to the dn_mark, so don't free it */
	/* !error means that we attached the dn to the dn_mark, so don't free it */
Loading