Re: [PATCH try #4] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline

From: Alexey Dobriyan
Date: Wed May 27 2015 - 07:09:06 EST


On Wed, May 27, 2015 at 1:56 PM, Jan Stancek <jstancek@xxxxxxxxxx> wrote:
> On Wed, May 27, 2015 at 01:27:13AM -0400, Jarod Wilson wrote:
>> On May 26, 2015, at 5:24 PM, Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
>> >> Should have tested on more than just x86, it appears. We've started
>> >> hammering on this internally across all arches, and its exploded
>> >> multiple times on ppc64 now:
>> >>
>> >> [ 2717.074699] ------------[ cut here ]------------
>> >> [ 2717.074787] kernel BUG at fs/proc/base.c:244!
>> >
>> >> OE-------------- 3.10.0-255.el7.ppc64.debug #1
>> >
>> > Which BUG_ON is this?
>> >
>> > BUG_ON(*pos < 0);
>> > BUG_ON(arg_start > arg_end);
>> > BUG_ON(env_start > env_end);
>>
>
> Is create_elf_tables() taking mm->mmap_sem when it's initialising env_start/end?
>
> I could reproduce it on x86_64 as well, just by doing exec in loop
> and "ps afx" in other window:

OK.

I've reproduced BUG_ON by running this program which sets arg_start>arg_end:

#include <sys/mman.h>
#include <sys/prctl.h>
#include <unistd.h>

enum {PAGE_SIZE=4096};

int main(void)
{
unsigned long env_start, env_end;
void *p;

p = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

#define PR_SET_MM 35
#define PR_SET_MM_ARG_START 8
#define PR_SET_MM_ARG_END 9
#define PR_SET_MM_ENV_START 10
#define PR_SET_MM_ENV_END 11
prctl(PR_SET_MM, PR_SET_MM_ARG_START, (unsigned long)p +
PAGE_SIZE - 1, 0, 0);
prctl(PR_SET_MM, PR_SET_MM_ARG_END, (unsigned long)p, 0, 0);

pause();
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/