mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: kosaki.motohiro@jp.fujitsu.com, Bryan Donlan <bdonlan@gmail.com>,
	Ulrich Drepper <drepper@redhat.com>, Timo Sirainen <tss@iki.fi>,
	WANG Cong <xiyou.wangcong@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v6] Added PR_SET_PROCTITLE_AREA option for prctl()
Date: Tue,  8 Dec 2009 14:10:19 +0900 (JST)	[thread overview]
Message-ID: <20091208135010.B5A8.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20091208044605.GA32669@elte.hu>

> 
> * KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> 
> > +	/*
> > +	 * If argv and environ aren't continuous (i.e. the process used
> > +	 * prctl(PR_SET_PROCTITLE_AREA)), we don't care environ override.
> 
> s/dont't care environ override/don't care about the evironment override/

Thanks. I'll fix.

> 
> > +		case PR_SET_PROCTITLE_AREA: {
> > +			struct mm_struct *mm = current->mm;
> > +			unsigned long addr = arg2;
> > +			unsigned long len = arg3;
> > +			unsigned long end = arg2 + arg3;
> 
> would be cleaner to write the latter as 'addr + len'.

Will fix.

> 
> > +			if (len > PAGE_SIZE)
> > +				return -EINVAL;
> > +
> > +			if (addr >= end)
> > +				return -EINVAL;
> > +
> > +			/*
> > +			 * If the process pass broken pointer, EFAULT is might better
> > +			 * than ps output zero-length proctitle. Plus if
> > +			 * the process pass kernel address (or something-else),
> > +			 * We have to block it. Oherwise, strange exploit
> > +			 * chance is there.
> > +			 */
> > +			if (!access_ok(VERIFY_READ, addr, len))
> > +				return -EFAULT;
> 
> the addr >= end check looks (partly) duplicative of the access_ok() 
> check.

ok.

> > +
> > +			down_write(&mm->mmap_sem);
> > +			mm->arg_start = addr;
> > +			mm->arg_end = end;
> > +			up_write(&mm->mmap_sem);
> 
> well we might as well name 'addr' as 'start' and have a match then here 
> too.

I'll do.


> The feature looks useful, but the choice of a prctl as an API is strange 
> - it limits us to the current task only - while the ability to set 
> arguments for another task looks a more generic (and potentially more 
> useful) solution.

No. It's impossible.
/proc/{pid}/cmdline read user process's memory. iow, this prctl() don't
receive string, it receive virtual address itself. I don't want any task
allow to change another task's memory except ptrace.

Plus, glibc don't need such capability. setproctitle() can only cahnge
own task's title.

Of cource, we can change argv is held in kernel structure (e.g. task_struct or
mm_struct). but it increase kernel memory footprint and I'm not sure its worth.




  reply	other threads:[~2009-12-08  5:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08  3:15 KOSAKI Motohiro
2009-12-08  4:46 ` Ingo Molnar
2009-12-08  5:10   ` KOSAKI Motohiro [this message]
2009-12-08  5:38     ` Ingo Molnar
2009-12-08  5:56       ` KOSAKI Motohiro
2009-12-08  6:53         ` KOSAKI Motohiro
2009-12-08  6:58           ` Ingo Molnar
2009-12-08  6:28       ` Bryan Donlan
2009-12-08  6:57         ` Ingo Molnar
2009-12-08  7:19           ` KOSAKI Motohiro
2009-12-09  9:10             ` Ingo Molnar
2009-12-10  0:16               ` KOSAKI Motohiro

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=20091208135010.B5A8.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=bdonlan@gmail.com \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=tss@iki.fi \
    --cc=xiyou.wangcong@gmail.com \
    /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®