X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.4 required=5.0	tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,TW_CP,TW_RG,UNPARSEABLE_RELAY
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o-
Date: Mon, 17 Oct 2011 10:18:48 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: /proc/*/cmdline corrupted
Message-ID: <20111017141848.GD2054@ednor.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <CAG_2cT=rmeJpmZbYDo7RAwjNcTTDSTH1SMhuzzL9qi09ZJwGyA@mail.gmail.com> <32663265.post@talk.nabble.com> <j7fr4c$mmf$1@dough.gmane.org> <20111017082718.GC30527@calimero.vinschen.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20111017082718.GC30527@calimero.vinschen.de>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Mon, Oct 17, 2011 at 10:27:18AM +0200, Corinna Vinschen wrote:
>On Linux, /proc/$PID/cmdline always contains the full command line as
>it has been when the process got started, irrespectively of changes
>after process startup.  It looks like the loader creates a copy of the
>argv array before calling main.

You can change the contents of what __argv[n] points to to modify what
/proc/<pid>/cmdline displays though.

i.e.,

    strcpy (__argv[1], "a");

That's pretty risky though.

>Cygwin doesn't generate a copy of the argv array at startup, so the
>processes __argv is the one used to call the main function.  And I'm
>reluctant to do that since it costs just more time for a process to
>start again.

Just creating a copy of argv without copying what it points to should be
pretty inexpensive.  It's too bad that we export __argv and __argc.  I
don't see Linux doing anything like that and it seems like a way for
a Cygwin program to cause mischief.

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

