From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: Bryan Donlan <bdonlan@gmail.com>
Cc: Timo Sirainen <tss@iki.fi>,
linux-kernel@vger.kernel.org, Ulrich Drepper <drepper@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Subject: Re: [PATCH] Added PR_SET_PROCTITLE_AREA option for prctl()
Date: Sun, 4 Oct 2009 23:44:19 +0900 [thread overview]
Message-ID: <2f11576a0910040744u575d3afbwd2e27e811060f206@mail.gmail.com> (raw)
In-Reply-To: <3e8340490910021959n304e6870r6df97cfd637283c4@mail.gmail.com>
Hi
>>>> - // If the nul at the end of args has been overwritten, then
>>>> - // assume application is using setproctitle(3).
>>>> - if (res > 0 && buffer[res-1] != '\0' && len < PAGE_SIZE) {
>>>> + if (mm->arg_end != mm->env_start) {
>>>> + // PR_SET_PROCTITLE_AREA used
>>>> + res = strnlen(buffer, res);
>>>
>>> Is this check really needed? Surely it's enough to simply state that
>>> behavior if the area isn't null-terminated is undefined.
>>
>> Well, that depends. I was hoping to use the syscall only once per process.
>> That would allow me to just update the process title whenever I feel like
>> it, possibly hundreds of times per second. This is much cheaper if I don't
>> have to use a syscall every time.
>>
>> So if I'm setting the PR_SET_PROCTITLE_AREA initially to e.g. 1 kB memory
>> area, without the above code ps will show it entirely regardless of any \0
>> characters (because parameters are separated by \0).
>
> That makes sense - but note that it's not completely atomic still -
> with a syscall you could insert some kind of barrier (rwsem?) to
> ensure other processes don't see a halfway updated process name. With
> infrequent updates this isn't a problem, but if you're really
> intending to update it at a rate where syscall overhead becomes a
> problem, then you're also going to see these kinds of issues as well.
Yes. this patch seems buggy. The lock is necessary.
following scenario makes disaster, I think.
CPU0 (prctl caller) CPU1 (ps)
-------------------------------------------------------------------------------------------
mm->arg_start = arg2;
len =
mm->arg_end - mm->arg_start; in proc_pid_cmdline()
mm->arg_end = arg3;
next prev parent reply other threads:[~2009-10-04 14:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-02 21:23 Timo Sirainen
2009-10-03 2:01 ` Bryan Donlan
2009-10-03 2:47 ` Timo Sirainen
2009-10-03 2:59 ` Bryan Donlan
2009-10-03 3:21 ` Timo Sirainen
2009-10-04 14:44 ` KOSAKI Motohiro [this message]
2009-10-04 18:05 ` Bryan Donlan
2009-10-05 0:55 ` KOSAKI Motohiro
2009-10-05 1:38 ` KOSAKI Motohiro
2009-10-05 1:44 ` Bryan Donlan
2009-10-05 1:59 ` KOSAKI Motohiro
2009-10-05 2:21 ` Bryan Donlan
2009-10-05 2:24 ` KOSAKI Motohiro
2009-10-05 2:48 ` KOSAKI Motohiro
2009-10-05 3:22 ` Bryan Donlan
2009-10-05 3:29 ` KOSAKI Motohiro
2009-10-05 3:39 ` Bryan Donlan
2009-10-05 7:18 ` KOSAKI Motohiro
2009-10-05 22:56 ` Timo Sirainen
2009-10-03 11:18 ` matthieu castet
2009-10-04 15:10 ` 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=2f11576a0910040744u575d3afbwd2e27e811060f206@mail.gmail.com \
--to=kosaki.motohiro@gmail.com \
--cc=bdonlan@gmail.com \
--cc=drepper@redhat.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tss@iki.fi \
/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®