All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Dmitry Safonov <0x7f454c46@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>, Sebastian Mayr <me@sam.st>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Subject: Re: get_unmapped_area && in_ia32_syscall (Was: [PATCH] uprobes/x86: fix detection of 32-bit user mode)
Date: Wed, 28 Aug 2019 13:37:43 +0200	[thread overview]
Message-ID: <20190828113743.GA3721@redhat.com> (raw)
In-Reply-To: <459fdf33-1290-2651-6344-0ff9e466ddfc@gmail.com>

On 08/28, Dmitry Safonov wrote:
>
> > On 8/27/19 3:00 PM, Oleg Nesterov wrote:
> > [..]
> >> But to remind, there is another problem with in_ia32_syscall() && uprobes.
> >>
> >> get_unmapped_area() paths use in_ia32_syscall() and this is wrong in case
> >> when the caller is xol_add_vma(), in this case TS_COMPAT won't be set.>
> >> Usually the addr = TASK_SIZE - PAGE_SIZE passed to get_unmapped_area() should
> >> work, mm->get_unmapped_area() won't be even called. But if this addr is already
> >> occupied get_area() can return addr > TASK_SIZE.
> >
> > Technically, it's not bigger than TASK_SIZE that's supplied
> > get_unmapped_area() as an argument..

Hmm. What do you mean?

Just in case, TASK_SIZE checks TIF_ADDR32, not TS_COMPAT.

> >>  	if (!area->vaddr) {
> >> +		if(!is_64bit_mm(mm))
> >> +			current_thread_info()->status |= TS_COMPAT;
> >>  		/* Try to map as high as possible, this is only a hint. */
> >>  		area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE,
> >>  						PAGE_SIZE, 0, 0);
> >> +		if(!is_64bit_mm(mm))
> >> +			current_thread_info()->status &= ~TS_COMPAT;;
> >>  		if (area->vaddr & ~PAGE_MASK) {
> >>  			ret = area->vaddr;
> >>  			goto fail;
> >
> > It could have been TASK_SIZE_OF(),

tsk is always current, why do we need TASK_SIZE_OF() ?

> > I see that arch_uprobe_analyze_insn() uses is_64bit_mm() which
> > is correct the majority of time, but not for processes those jump
> > switching CS..

Heh. it's actually even worse. Just suppose a 32-bit application simply
mmaps a 64-bit executable which has a probe. But this is off-topic.

> > Do I read the code properly and xol is always one page?

Yes,

> > Could that page be reserved on the top of mmap_base/mmap_compat_base at
> > the binfmt loading time?

How? I don't understand...

> (I would need than to add .mremap() for
> > restoring sake).

for what? I don't think you can restore a probed process anyway... OK,
right now this is off-topic too.

Oleg.


  reply	other threads:[~2019-08-28 11:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-28 15:26 [PATCH] uprobes/x86: fix detection of 32-bit user mode Sebastian Mayr
2019-08-19 18:40 ` Sebastian Mayr
2019-08-19 18:43   ` Thomas Gleixner
2019-08-23 23:30 ` Thomas Gleixner
2019-08-23 23:44   ` Thomas Gleixner
2019-08-23 23:57     ` Andy Lutomirski
2019-08-24  0:00       ` Thomas Gleixner
2019-08-24  0:03         ` Thomas Gleixner
2019-08-24  0:13           ` Andy Lutomirski
2019-08-24  0:20             ` Thomas Gleixner
2019-08-26 13:48               ` Thomas Gleixner
2019-08-27 14:00   ` get_unmapped_area && in_ia32_syscall (Was: [PATCH] uprobes/x86: fix detection of 32-bit user mode) Oleg Nesterov
2019-08-27 17:03     ` Dmitry Safonov
2019-08-27 23:40       ` Dmitry Safonov
2019-08-28 11:37         ` Oleg Nesterov [this message]
2019-08-26 14:02 ` [tip: x86/urgent] uprobes/x86: Fix detection of 32-bit user mode tip-bot2 for Sebastian Mayr

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=20190828113743.GA3721@redhat.com \
    --to=oleg@redhat.com \
    --cc=0x7f454c46@gmail.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=me@sam.st \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.