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
Carlo Arenas <carenas@gmail.com>
Date
Dec 10, 2018, 01:25 UTC
Message-ID
<CAPUEspjApDZ3MQr1D1Qu9UNq0QSB_9BKMUUogvABo2VJqao+xw@mail.gmail.com>
In-Reply-To
<20181210004252.GK890086@genre.crustytoothpaste.net>

On Sun, Dec 9, 2018 at 4:42 PM brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 14 quoted lines
>
> On Mon, Dec 10, 2018 at 12:51:01AM +0100, Ævar Arnfjörð Bjarmason wrote:
> > 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.

and that has been implemented (sljitProtExecAllocator.c) as part of the work triggered by the bug I linked about [1], deep inside sljit (which is what pcre uses for JIT)

the code AS-IS wouldn't compile for the BSD[2] but that is easy to fix and sure works as expected but I am under the impression that is not something that can be considered as a solution as explained by the open issues described with crashes after a fork()

note that changing the map from read-write to executable will be prevented by the same policy so you have to create 2 maps (and therefore a backing file) and I don't think there is a way to solve that in a foolproof way in a library which is why I mentioned more work might be needed to define the right interfaces so it can be solved by the application, and that is unlikely to happen with the old library.

Carlo

[1] https://bugs.exim.org/show_bug.cgi?id=1749 [2] https://bugs.exim.org/show_bug.cgi?id=2155

Previous: brian m. carlsonNext: Junio C Hamano
Message 5 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.