patchelf icon indicating copy to clipboard operation
patchelf copied to clipboard

--set-interpreter lost compatibility with Linux 5.17 and below

Open avikivity opened this issue 5 months ago • 2 comments

Describe the bug

Linux 5.17 and below have a bug, later fixed by torvalds/linux@0da1d5002745cdc721bc018b582a8a9704d56c42. That bug was accounted for in patchelf, but a recent patch (43b75fbc9ffbc1190fee7c8693ad74cb8286cfd4) broke compatibility with these older kernels.

Steps To Reproduce

  1. patchelf --set-interpreter /path/to/new/interpreter
  2. patchelf allocates new sections at the end
  3. run on Linux 5.17 or below
  4. crash

I can supply a full reproducer if needed, but since the regression was deliberate, I don't think it's necessary. I can do it if required.

Expected behavior

A clear and concise description of what you expected to happen.

I'd like to restore compatibility with Linux 5.17, perhaps with a switch.

patchelf --version output

patchelf 0.18.0

Additional context

Running patchelf on Fedora 42 (patchelf-0.18.0-8.fc42.x86_64) and the patched binary on CentOS 9.

avikivity avatar Jun 22 '25 07:06 avikivity

https://github.com/NixOS/patchelf/commit/43b75fbc9ffbc1190fee7c8693ad74cb8286cfd4 was fairly involved. Do you see a way to put the original behavior behind a flag in way that doesn't add significant complexity?

Ericson2314 avatar Aug 12 '25 17:08 Ericson2314

This sounds like a job for copilot, it would gladly take an instruction like that and generate a patch in a few minutes. As I don't know anything about patchelf, it would take me hours or days.

In fact, to solve the problem with this regression, I asked it to write a new patchelf, which it did: scylladb/scylladb@07c5edcc30145277e803fec75472faf030b97d97.

If upstream patchelf fixes the regression I'll use it again, but it's not a burning problem for me.

avikivity avatar Aug 13 '25 09:08 avikivity