git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 1/2] grep: fallback to interpreter if JIT fails with pcre1

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Dec 10, 2018, 00:42 UTC
Message-ID
<20181210004252.GK890086@genre.crustytoothpaste.net>
In-Reply-To
<87r2eqxnru.fsf@evledraar.gmail.com>
On Mon, Dec 10, 2018 at 12:51:01AM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> Obviously this & what you have in 2/2 needs to be fixed in some way.
> 
> Is the issue on SELinux, OpenBSD, NetBSD etc. *how* PCRE is creating the
> the JIT'd code? I.e. presumably Google Chrome's JIT engine, Java JIT and
> the like work on those setup, or not? I.e. is this something upstream
> can/is likely to fix eventually?

From the cover letter (but without testing), it seems like it would probably be fine to first map the pages read-write to write the code and then, once that's done, to map them read-executable. I know JIT compilation does work on the BSDs, so presumably that's the technique to make it do so.

Both versions of PCRE map pages both write and executable at the same time, which is presumably where things go wrong. I assume it can be fixed, but whether that's easy in the context of PCRE, I wouldn't know.

> Are we mixing a condition where one some OS's or OS versions this just
> won't work at all, and thus maybe should be something turned on in
> config.mak.uname, v.s. e.g. SELinux where presumably it'll dynamically
> change.

Considering that some Linux users use PaX kernels with standard distributions and that most BSD kernels can be custom-compiled with a variety of options enabled or disabled, I think this is something we should detect dynamically.

Show 5 quoted lines
> I'm inclined to suggest that we should have another ifdef here for "if
> JIT fails I'd like it to die", so that e.g. packages I build (for
> internal use) don't silently slow down in the future, only for me to
> find some months later that someone enabled an overzealous SELinux
> policy and we swept this under the rug.
My view is that JIT is a nice performance optimization, but it's
optional. I honestly don't think it should even be exposed through the
API: if it works, then things are faster, and if it doesn't, then
they're not. I don't see the value in an option for causing things to be
broken if someone improves the security of the system.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Ævar Arnfjörð BjarmasonNext: Carlo Arenas
Message 4 of 13 in “fallback to interpreter if JIT fails with pcre”
  1. 0/2 fallback to interpreter if JIT fails with pcreCarlo Marcelo Arenas Belón, Dec 9, 2018
  2. 1/2 grep: fallback to interpreter if JIT fails with pcre1Carlo Marcelo Arenas Belón, Dec 9, 2018
  3. Ævar Arnfjörð BjarmasonDec 9, 2018
  4. brian m. carlsonDec 10, 2018
  5. Carlo ArenasDec 10, 2018
  6. Junio C HamanoDec 10, 2018
  7. Ævar Arnfjörð BjarmasonDec 10, 2018
  8. Carlo ArenasDec 11, 2018
  9. Ævar Arnfjörð BjarmasonDec 11, 2018
  10. Junio C HamanoDec 10, 2018
  11. Junio C HamanoDec 10, 2018
  12. 2/2 grep: fallback to interpreter if JIT fails with pcre2Carlo Marcelo Arenas Belón, Dec 9, 2018
  13. Junio C HamanoDec 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.