mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Samuelson <peter@cadcamlab.org>
To: BERECZ Szabolcs <szabi@inf.elte.hu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] new setprocuid syscall
Date: Mon, 19 Feb 2001 23:01:06 -0600	[thread overview]
Message-ID: <20010219230106.A23699@cadcamlab.org> (raw)
In-Reply-To: <Pine.A41.4.31.0102192312330.174604-100000@pandora.inf.elte.hu>
In-Reply-To: <Pine.A41.4.31.0102192312330.174604-100000@pandora.inf.elte.hu>; from szabi@inf.elte.hu on Mon, Feb 19, 2001 at 11:18:27PM +0100


[BERECZ Szabolcs]
> Here is a new syscall. With this you can change the owner of a running
> procces.

> +       if (current->euid)
> +               return -EPERM;

Use capable().

> +       p = find_task_by_pid(pid);
> +       p->fsuid = p->euid = p->suid = p->uid = uid;

Race -- you need to make sure the task_struct doesn't disappear out
from under you.

Anyway, why not use the interface 'chown uid /proc/pid'?  No new
syscall, no arch-dependent part, no user-space tool, etc.

The following is untested and almost certainly broken (I'm a lousy
kernel hacker), but should be at least somewhat close....

Peter


--- fs/proc/base.c.orig	Thu Nov 16 22:11:22 2000
+++ fs/proc/base.c	Mon Feb 19 22:51:59 2001
@@ -873,6 +873,27 @@
 	return ERR_PTR(error);
 }
 
+static int proc_base_chown (struct dentry *dentry, struct iattr *attr)
+{
+	struct task_struct *task;
+
+	if (!capable (CAP_SETUID))
+		return -EPERM;
+
+	if (!(attr->ia_valid & ATTR_UID))
+		return -EINVAL;
+
+	read_lock (&tasklist_lock);
+	task = dentry->d_inode->u.proc_i.task;
+	if (task)
+		task->fsuid = task->euid = task->suid = task->uid = attr->ia_uid;
+	read_unlock (&tasklist_lock);
+	if (!task)
+		return -ENOENT;
+
+	return 0;
+}
+
 static struct file_operations proc_base_operations = {
 	read:		generic_read_dir,
 	readdir:	proc_base_readdir,
@@ -880,6 +901,7 @@
 
 static struct inode_operations proc_base_inode_operations = {
 	lookup:		proc_base_lookup,
+	setattr:	proc_base_chown,
 };
 
 /*

  reply	other threads:[~2001-02-20  5:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-19 22:18 BERECZ Szabolcs
2001-02-20  5:01 ` Peter Samuelson [this message]
2001-02-20 10:53   ` Martin Dalecki
2001-02-20 13:00     ` Peter Samuelson
2001-02-20 11:42   ` Alan Cox
2001-02-20 13:11     ` Peter Samuelson
2001-02-20 13:52       ` Alan Cox
2001-02-20 17:04         ` BERECZ Szabolcs
2000-01-01  0:28           ` Pavel Machek
2001-02-21  4:19           ` Peter Samuelson
2001-02-20 12:14   ` BERECZ Szabolcs
2001-02-20 12:52     ` Peter Samuelson
2001-02-20 12:02 ` Philipp Rumpf
2001-02-20 14:19 Petr Vandrovec
2001-02-23 17:13 Bernd Jendrissek

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=20010219230106.A23699@cadcamlab.org \
    --to=peter@cadcamlab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=szabi@inf.elte.hu \
    /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

all inboxes | Powered by JetHome®