Bug 15723 - priv-wrapper: self-check error on armhf/armel, 32-bit file offset issue?
Summary: priv-wrapper: self-check error on armhf/armel, 32-bit file offset issue?
Status: NEW
Alias: None
Product: cwrap
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: Other All
: P5 normal
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-25 08:25 UTC by Simon Josefsson
Modified: 2024-09-27 14:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Josefsson 2024-09-25 08:25:05 UTC
Hi.

We got this bug report:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069486

I was able to reproduce this on an armel machine.  This may be another 32-bit vs 64-bit file offset problem.

Any ideas?

/Simon
Comment 1 Andreas Schneider 2024-09-26 09:14:55 UTC
priv_wrapper doesn't implement setrlimit64 nor __prctl_time64.
Comment 2 Simon Josefsson 2024-09-26 17:49:52 UTC
It seems priv-wrapper is binding setrlimit somehow, and on #debian-arm it was suggested that the following patch would solve this on 32-bit arm's.  Thoughts?

--- orig/priv-wrapper-1.0.1/src/priv_wrapper.c  2022-11-24 14:06:06.000000000 +0000
+++ priv-wrapper-1.0.1/src/priv_wrapper.c       2024-09-25 20:28:52.994318068 +0000
@@ -335,11 +335,18 @@
                        _privwrap_bind_symbol(PRIVWRAP_LIBC, #sym_name); \
        }

+
+#define privwrap_bind_symbol_libc2(sym_name, libc_sym_name) \
+       if (privwrap.libc.symbols._libc_##sym_name.obj == NULL) { \
+               privwrap.libc.symbols._libc_##sym_name.obj = \
+                       _privwrap_bind_symbol(PRIVWRAP_LIBC, #libc_sym_name); \
+       }
+
 DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
 static void __pwrap_bind_symbol_all_once(void)
 {
 #ifdef HAVE_SETRLIMIT
-       privwrap_bind_symbol_libc(setrlimit);
+       privwrap_bind_symbol_libc2(setrlimit, setrlimit64);
 #endif
        privwrap_bind_symbol_libc(chroot);
 #ifdef HAVE_PRCTL
Comment 3 Andreas Schneider 2024-09-27 14:07:59 UTC
This is not the right thing to do. It needs to work with binaries compiled with 64bit file support and without.

So you need to implement setrlimit64 in priv_wrapper. See also like socket_wrapper is doing it.