linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: James Morris <jmorris@namei.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: akpm@osdl.org, linux-mm@kvack.org
Subject: Re: Extract have_task_perm() from kill and migrate functions.
Date: Mon, 22 May 2006 11:03:21 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0605221047070.25125@d.namei> (raw)
In-Reply-To: <Pine.LNX.4.64.0605220719310.3432@schroedinger.engr.sgi.com>

On Mon, 22 May 2006, Christoph Lameter wrote:

> +int have_task_perm(struct task_struct *t, int capability)
> +{
> +	if (capable(capability))
> +		return 1;
> +
> +	return (current->euid == t->suid || current->euid == t->uid ||
> +		  current->uid == t->suid || current->uid == t->uid);
> +}

There's another fairly common variant of this, for example, in 
sys_get_robust_list():

	if ((current->euid != p->euid) && (current->euid != p->uid) &&
                                !capable(CAP_SYS_PTRACE))

So I'd suggest a function for each.

Not sure this stuff belongs in kernel/signal.c.  What about 
kernel/capability.c and name the functions something like:

task_cap_or_perm_euid(task, cap)
task_cap_or_perm_suid(task, cap)

As for the rights stored in various kernel structures, I gather you mean 
examples like the calls in sys_shmctl().  In that case, perhaps make the 
above wrappers for functions which take the uid/euid/suid values as 
parameters:

cap_or_perm_euid(uid, euid, cap)
cap_or_perm_suid(uid, suid, cap)

then

static inline int task_cap_or_perm_euid(task, cap)
{
	return cap_or_perm_euid(task->uid, task->euid, cap);
}

Or similar.


- James
-- 
James Morris
<jmorris@namei.org>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      parent reply	other threads:[~2006-05-22 15:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-22 14:21 Christoph Lameter
2006-05-22 14:36 ` Andi Kleen
2006-05-22 15:03 ` James Morris [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0605221047070.25125@d.namei \
    --to=jmorris@namei.org \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox