Skip to content

nginx: upgrade pcre to pcre2 - #355989

Merged
emilazy merged 2 commits into
NixOS:masterfrom
deshaw:upstream/nginx-pcre2
Nov 19, 2024
Merged

emilazy merged 2 commits into
NixOS:masterfrom
deshaw:upstream/nginx-pcre2

Conversation

@de11n

@de11n de11n commented Nov 14, 2024

Copy link
Copy Markdown

Nginx builds with pcre2 by default as of version 1.21.5.

I've tested with both nginx and nginxMainline.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Nginx builds with pcre2 by default as of version 1.21.5.
@nix-owners
nix-owners Bot requested a review from RaitoBezarius November 14, 2024 20:10
@emilazy

emilazy commented Nov 14, 2024 •

Copy link
Copy Markdown
Member

Do we have a tracking issue for this? I learned the other day that Debian is phasing out PCRE because of security concerns, so we should probably follow suit.

@de11n

de11n commented Nov 14, 2024

Copy link
Copy Markdown
Author

If there is, I'm not aware of it.

@ofborg ofborg Bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Nov 15, 2024
@Izorkin

Izorkin commented Nov 15, 2024

Copy link
Copy Markdown
Contributor

Do the lua modules work?

@emilazy

emilazy commented Nov 16, 2024

Copy link
Copy Markdown
Member

I’ve opened #356387 to track this.

@emilazy

emilazy commented Nov 16, 2024

Copy link
Copy Markdown
Member

@Izorkin Debian already started working on removing PCRE in 2021 and the library is EOL. The latest Debian stable release doesn’t ship it at all. I doubt anything significant is broken by this (and anything that is broken by it is probably in a dire maintenance state).

@emilazy

emilazy commented Nov 16, 2024

Copy link
Copy Markdown
Member

@ofborg build nginx.passthru.tests

@ulrikstrid

Copy link
Copy Markdown
Member

Should we wait for after the stable release?

@emilazy

emilazy commented Nov 16, 2024

Copy link
Copy Markdown
Member

I think the opposite – we should backport this to 24.11 because we’re exposing a library that went EOL in 2021 and hasn’t been updated since to untrusted user input. My previous comment was wrong on the timeline: Debian considered it too risky for that purpose at the time, which is why they’ve already removed it. It’s concerning that we’ve fallen so far behind, especially for something as security‐critical as Nginx.

@ulrikstrid

Copy link
Copy Markdown
Member

Then I think we should go for it

@emilazy

emilazy commented Nov 17, 2024 •

Copy link
Copy Markdown
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 355989


x86_64-linux

❌ 2 packages failed to build:
  • openresty
  • openresty.doc
✅ 17 packages built:
  • angie
  • angie.doc
  • angieQuic
  • angieQuic.doc
  • devpi-client
  • devpi-client.dist
  • devpi-server
  • devpi-server.dist
  • nginx (nginxStable)
  • nginx.doc (nginxStable.doc)
  • nginxMainline
  • nginxMainline.doc
  • nginxQuic
  • nginxQuic.doc
  • nginxShibboleth
  • nginxShibboleth.doc
  • tests.testers.lycheeLinkCheck.network

Looks like this breaks OpenResty:

./configure: error: the HTTP rewrite module requires the PCRE library.

We can probably backport the upstream fix. (Or just bump to 1.27?)

@wegank wegank added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Nov 17, 2024
@emilazy

emilazy commented Nov 18, 2024

Copy link
Copy Markdown
Member

cc @thoughtpolice @lblasc @kalekseev for OpenResty

@emilazy

emilazy commented Nov 18, 2024

Copy link
Copy Markdown
Member

(Pinging because this would break OpenResty unless we presumably backport a patch from upstream Nginx or perhaps bump the version 😅)

@de11n

de11n commented Nov 18, 2024

Copy link
Copy Markdown
Author

I'll look today.

@de11n

de11n commented Nov 18, 2024

Copy link
Copy Markdown
Author

Upgrading openresty to 1.27.1.1 fixed the build. The NixOS tests also pass.

@emilazy emilazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me! Looks like it should be backwards‐compatible enough for the backport. I’ll let @lblasc take another look before merging.

@lblasc

lblasc commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

@emilazy sorry, I've reacted too fast on your comment, best way to handle openresty is to bump the version, they don't brake compatibility, should be safe for backporting.

@de11n thx for doing the bump.

@wegank wegank added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Nov 19, 2024
@ofborg
ofborg Bot requested review from lblasc and ulrikstrid November 19, 2024 15:16
@emilazy
emilazy merged commit fc1a0e3 into NixOS:master Nov 19, 2024
@github-actions

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-24.11:

@de11n
de11n deleted the upstream/nginx-pcre2 branch November 19, 2024 15:38
@SuperSandro2000

Copy link
Copy Markdown
Member

With this change my nginx fails to start with bad system call. I confirmed this by deploying it with an override on pcre2 to pcre.

systemd[1]: nginx.service: Control process exited, code=exited, status=159/n/a
nginx-pre-start[4083150]: /nix/store/pjw413fdjq9fmnr718c6y3mai5v1bgng-unit-script-nginx-pre-start/bin/nginx-pre-start: line 7: 4083151 Bad system call         (core
 dumped) /nix/store/gs6s5r211gbd2banxkfxq80j4nmx6jbh-nginxQuic-1.27.2/bin/nginx -c /etc/nginx/nginx.conf -t
systemd[1]: nginx.service: Failed with result 'exit-code'.

dmesg contains:

audit: type=1326 audit(1732833069.740:14): auid=4294967295 uid=60 gid=60 ses=4294967295 subj=kernel pid=4082877 comm="nginx" exe="/nix/store/gs6s5r211gbd2banxkfxq
80j4nmx6jbh-nginxQuic-1.27.2/bin/nginx" sig=31 arch=c000003e syscall=319 compat=0 ip=0x7fc61bf4ddcb code=0x80000000
audit: type=1326 audit(1732833080.876:15): auid=4294967295 uid=60 gid=60 ses=4294967295 subj=kernel pid=4083151 comm="nginx" exe="/nix/store/gs6s5r211gbd2banxkfxq
80j4nmx6jbh-nginxQuic-1.27.2/bin/nginx" sig=31 arch=c000003e syscall=319 compat=0 ip=0x7f7a0ba68dcb code=0x80000000

syscall 319 maps to memfd_create.

It feels similar to #179444 but neither disabling MemoryDenyWriteExecute nor allowing memfd_create fixed the crash.

SuperSandro2000 added a commit to SuperSandro2000/nixpkgs that referenced this pull request Nov 28, 2024
This also disables the memfd_create syscall which is required for
certain regex's when using pcre2.

see NixOS#355989 (comment)
@SuperSandro2000 SuperSandro2000 mentioned this pull request Nov 28, 2024
3 of 13 tasks
@SuperSandro2000

Copy link
Copy Markdown
Member

I did a fix in #360008

fpletz added a commit to fpletz/nixpkgs that referenced this pull request Nov 29, 2024
This reverts commit 861b05c.

See NixOS#355989 & NixOS#360008. This needs more testing and polish.
nixpkgs-ci Bot pushed a commit that referenced this pull request Dec 9, 2024
This also disables the memfd_create syscall which is required for
certain regex's when using pcre2.

see #355989 (comment)

(cherry picked from commit 996f9e4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants