Re: [RFC][PATCHSET] mremap/mmap mess

From: Linus Torvalds
Date: Sun Dec 06 2009 - 13:00:39 EST



On Sun, 6 Dec 2009, Hugh Dickins wrote:
>
> I've never found out why we need access_process_vm() to expand a stack:
> shall we see what breaks if we just forbid expand_stack() on another mm?

Hmm. If you want to actually emulate some stack instruction using ptrace,
you'd need to be able to extend the stack.

The classic example of this might be to do some crazy user-space emulation
of 'pushf' for virtualization.

And emulating pushf is not theory: at least KVM does actually do exactly
that (although KVM obviously does it from kernel space and from within the
process that faulted). Same goes for vm86 mode (again, we do that
emulation in kernel) and for ptrace single-stepping (which we actually
don't bother emulating).

The point being that at least 'pushf' really _is_ an instruction that (a)
might want to extend the stack and (b) does tend to need emulation or
fixup in some virtualized/emulated environments. I just don't know if you
actually ever have user space doing so.

But I could imagine that Wine does some pushf emulation using ptrace, for
example.

Linus
--
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/