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

Commit af60a1a1 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Sanitize 'move_pages()' permission checks"

parents 8963fc36 3374c398
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -6535,17 +6535,19 @@ long group_norm_util(struct energy_env *eenv, struct sched_group *sg)
static int find_new_capacity(struct energy_env *eenv,
	const struct sched_group_energy * const sge)
{
	int idx;
	int idx, max_idx = sge->nr_cap_states - 1;
	unsigned long util = group_max_util(eenv);

	 /* default is max_cap if we don't find a match */
	eenv->cap_idx = max_idx;

	for (idx = 0; idx < sge->nr_cap_states; idx++) {
		if (sge->cap_states[idx].cap >= util)
			eenv->cap_idx = idx;
			break;
	}

	eenv->cap_idx = idx;

	return idx;
	return eenv->cap_idx;
}

static int group_idle_state(struct sched_group *sg)
+3 −8
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include <linux/mmu_notifier.h>
#include <linux/page_idle.h>
#include <linux/page_owner.h>
#include <linux/ptrace.h>

#include <asm/tlbflush.h>

@@ -1649,7 +1650,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
		const int __user *, nodes,
		int __user *, status, int, flags)
{
	const struct cred *cred = current_cred(), *tcred;
	struct task_struct *task;
	struct mm_struct *mm;
	int err;
@@ -1673,14 +1673,9 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,

	/*
	 * Check if this process has the right to modify the specified
	 * process. The right exists if the process has administrative
	 * capabilities, superuser privileges or the same
	 * userid as the target process.
	 */
	tcred = __task_cred(task);
	if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
	    !uid_eq(cred->uid,  tcred->suid) && !uid_eq(cred->uid,  tcred->uid) &&
	    !capable(CAP_SYS_NICE)) {
	 * process. Use the regular "ptrace_may_access()" checks.
	 */
	if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
		rcu_read_unlock();
		err = -EPERM;
		goto out;