Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch > #31765

Re: Fractal Variable-Length Instructions?

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.arch
Subject Re: Fractal Variable-Length Instructions?
Date 2015-12-12 17:06 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2015Dec12.180623@mips.complang.tuwien.ac.at> (permalink)
References (4 earlier) <b563f684-3846-47e3-83d2-706226d409ed@googlegroups.com> <2015Dec8.144301@mips.complang.tuwien.ac.at> <47675b7d-fb17-4412-84ec-b0e48cc3ab73@googlegroups.com> <2015Dec8.170828@mips.complang.tuwien.ac.at> <b478a6df-afd9-4ead-b5a0-e45b109ceda9@googlegroups.com>

Show all headers | View raw


Quadibloc <jsavard@ecn.ab.ca> writes:
>On Tuesday, December 8, 2015 at 9:26:46 AM UTC-7, Anton Ertl wrote:
>
>> Right, and I have not noticed any sign of the OS not "want"ing to do
>> that.
>
>Oh, you're complaining about anthropomorphisms now.

Not particularly.  But if he is using imprecise and suggestive
language, he should not complain about my taking his language in the
way it suggests itself.

> Rather than admitting he is 
>right, and if you have to call mprotect() because storage is, by default, not 
>writeable and executable at the same time, it means that *the guys who wrote 
>the OS* considered self-modifying code either bad practice or a security hole 
>or both - you're basically saying that if the OS has an mprotect() call, it's 
>obviously easy.

So you are interpreting his language in the way he suggested.

The primary memory allocation mechanism of a modern Unix is the mmap()
system call, and it has no default for the protections/permissions;
you have to specify explicitly what protections/permissions you want.
Specifying PROT_READ|PROT_WRITE|PROT_EXEC is not any more difficult
than specifying just PROT_READ|PROT_WRITE (well, it's a little more to
type).  I don't have to call mprotect() to make anything executable,
and Gforth does not do so (it only uses mprotect() to remove
permissions).

There is a C library function called malloc(), and modern
implementations of malloc() call mmap() with PROT_READ|PROT_WRITE,
without PROT_EXEC?  Why?  Because in C you normally don't execute code
from malloc()ed memory, and not making it executable breaks some
attacks, and those programmers who need executable memory can still
use mmap() directly (and of course, the C library programmers might
also maintain the beliefs that you ascribe to "*the guys who wrote the
OS*"; there's little in their position that would correct such
beliefs).  But the malloc() is just a C library function, designed for
C programmers; it's not the "OS default".

And while it's likely that malloc()ed memory was allocated with mmap()
and can therefore be mprotect()ed, I don't think that this is
guaranteed.  I am cautious and only mprotect() memory that I have
mmap()ed, not malloc()ed memory.  And if I mmap() anyway, I use the
permissions I need from the start.

- anton
-- 
M. Anton Ertl                    Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html

Back to comp.arch | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-24 06:44 -0800
  Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-24 06:59 -0800
    Re: Fractal Variable-Length Instructions? Ivan Godard <ivan@millcomputing.com> - 2015-11-24 16:42 -0800
  Re: Fractal Variable-Length Instructions? mrs@kithrup.com (Mike Stump) - 2015-11-24 22:27 +0000
    Re: Fractal Variable-Length Instructions? Terje Mathisen <terje.mathisen@tmsw.no> - 2015-11-25 07:48 +0100
      Re: Fractal Variable-Length Instructions? mrs@kithrup.com (Mike Stump) - 2015-11-26 18:21 +0000
  Re: Fractal Variable-Length Instructions? MitchAlsup <MitchAlsup@aol.com> - 2015-11-24 15:01 -0800
    Re: Fractal Variable-Length Instructions? mrs@kithrup.com (Mike Stump) - 2015-11-24 23:33 +0000
    Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-24 16:44 -0800
      Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-27 18:07 -0800
        Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-27 18:11 -0800
          Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-12-04 22:56 -0800
        Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-28 08:30 -0800
    Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-24 17:35 -0800
      Re: Fractal Variable-Length Instructions? Terje Mathisen <terje.mathisen@tmsw.no> - 2015-11-25 08:21 +0100
        Re: Fractal Variable-Length Instructions? Ivan Godard <ivan@millcomputing.com> - 2015-11-24 23:31 -0800
          Re: Fractal Variable-Length Instructions? Terje Mathisen <terje.mathisen@tmsw.no> - 2015-11-25 08:38 +0100
        Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-11-25 03:23 -0800
          Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-25 06:20 -0800
            Re: Fractal Variable-Length Instructions? Walter Banks <walter@bytecraft.com> - 2015-11-25 11:50 -0500
          Re: Fractal Variable-Length Instructions? Megol <golem960@gmail.com> - 2015-11-25 12:30 -0800
            Re: Fractal Variable-Length Instructions? MitchAlsup <MitchAlsup@aol.com> - 2015-11-25 17:53 -0800
          Re: Fractal Variable-Length Instructions? George Neuner <gneuner2@comcast.net> - 2015-11-25 20:35 -0500
            Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-11-26 00:34 -0800
              Re: Fractal Variable-Length Instructions? George Neuner <gneuner2@comcast.net> - 2015-11-26 12:53 -0500
                Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-11-26 10:32 -0800
              Re: Fractal Variable-Length Instructions? Stefan Monnier <monnier@iro.umontreal.ca> - 2015-12-01 14:45 -0500
                Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-01 12:12 -0800
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-05 14:19 +0000
                Re: Fractal Variable-Length Instructions? nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-05 14:56 +0000
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-05 16:48 +0000
                Re: Fractal Variable-Length Instructions? nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-05 17:38 +0000
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-06 15:21 +0000
                Re: Fractal Variable-Length Instructions? nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-06 16:43 +0000
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-08 13:55 +0000
                Re: Fractal Variable-Length Instructions? Chris Gray <cg@GraySage.COM> - 2015-12-05 11:05 -0700
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-06 14:04 +0000
                Re: Fractal Variable-Length Instructions? Chris Gray <cg@GraySage.COM> - 2015-12-06 11:09 -0700
                Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-06 09:15 -0800
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-08 13:43 +0000
                Re: Fractal Variable-Length Instructions? nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-08 14:01 +0000
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-08 16:57 +0000
                Re: Fractal Variable-Length Instructions? nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-08 18:02 +0000
                Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-08 06:11 -0800
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-08 16:08 +0000
                Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-12-08 10:43 -0800
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-12 17:06 +0000
                Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-08 11:29 -0800
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-12 18:10 +0000
                Re: Fractal Variable-Length Instructions? Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-12 15:00 -0800
                Re: Fractal Variable-Length Instructions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-13 16:12 +0000
                Re: Fractal Variable-Length Instructions? George Neuner <gneuner2@comcast.net> - 2015-12-01 21:27 -0500
  Re: Fractal Variable-Length Instructions? Quadibloc <jsavard@ecn.ab.ca> - 2015-11-24 16:39 -0800

csiph-web