lkml.org 
[lkml]   [2000]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Changes in fork ?
Date
ksi@ksi-linux.com (Sergey Kubushin) writes:
> On 23 Jan 2000, Nick Holloway wrote:
> > Normally the implementations of setproctitle() are a little more careful
> > than that. They use the processes environment space in addition to the
> > argument space. This does rely on them being contiguous memory areas.
>
> Can one rely on argv and env being contigous memory area? Getting it another
> way - can the proposed patch be applied with no side effects? Sendmail's
> setproctitle does work the a.m. way, i.e. it uses the environment space in
> addition to the argument space so it looks like a right way to set a proc
> title...

I think the only thing that would break would be applications that
used "setproctitle", but then they would probably fail spectacularly.
I suspect that changing the process layout so the environment wasn't
immediately after the arguments would break applications for no gain,
so is unlikely to happen.

> What was the reason behind making such a change? It could be simply an
> overlooked typo, but it could also be done for some good reason. Can
> somebody enlighten me? It have to be fixed if it IS a typo. And it looks
> like a typo, 'coz we have to fix helluva lotta programs which do use
> setproctitle if it is not. Falling back to the old kernel behaviour would
> be much less pain then fixing all the applications that use to change their
> argv for ps...

I've looked into the source of 2.2 and 2.3 a little more, and the change
looks to be a side-effect of the clean-up done by Al Viro (author listed
in comment in fs/proc/base.c).

It appears to be down to a difference in the semantics of "get_array"
which is used in 2.2, and "access_process_vm" in 2.3.

It looks as if "access_process_vm" will return exactly the memory region
specified, but "get_array" would continue past the end of the memory
region specified looking for a null terminator.

So, although the 2.2 code used arg_end in "get_arg", this was only
the point to start looking for the end, rather than the actual end.
Thus "get_arg" would fetch the whole string used in "setproctitle"
by wandering into the environment area.

It means that my previous simple patch means that /proc/$$/cmdline will
contain all of the command line and environment, which isn't right.

--
`O O' | Nick.Holloway@alfie.demon.co.uk
// ^ \\ | http://www.alfie.demon.co.uk/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.067 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site