[libvirt] [PATCH] tests: Add getuid() to virnetdevbandwidthmock
Daniel P. Berrangé
berrange at redhat.com
Tue Jul 9 09:21:07 UTC 2019
On Mon, Jul 08, 2019 at 06:03:10PM +0200, Andrea Bolognani wrote:
> When only geteuid() is mocked, the test crashes on Debian 10.
>
> Fatal: failed to reset uid: No such file or directory
>
> Program received signal SIGABRT, Aborted.
> __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> (gdb) t a a bt
>
> Thread 1 (Thread 0x7ffff3b3e080 (LWP 12003)):
> #0 __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1 0x00007ffff7798535 in __GI_abort () at abort.c:79
> #2 0x00007ffff485ca20 in _gcry_logv (level=level at entry=40, fmt=fmt at entry=0x7ffff4929126 "failed to reset uid: %s\n", arg_ptr=arg_ptr at entry=0x7fffffffe4a0) at ../../src/misc.c:142
> #3 0x00007ffff485cd61 in _gcry_log_fatal (fmt=fmt at entry=0x7ffff4929126 "failed to reset uid: %s\n") at ../../src/misc.c:218
> #4 0x00007ffff48639d1 in lock_pool_pages (n=<optimized out>, p=<optimized out>) at ../../src/secmem.c:340
> #5 _gcry_secmem_init_internal (n=<optimized out>) at ../../src/secmem.c:563
> #6 0x00007ffff4863d78 in _gcry_secmem_init (n=4096) at ../../src/secmem.c:581
> #7 0x00007ffff485e4e6 in _gcry_vcontrol (cmd=<optimized out>, arg_ptr=arg_ptr at entry=0x7fffffffe5e0) at ../../src/global.c:506
> #8 0x00007ffff485a789 in gcry_control (cmd=cmd at entry=GCRYCTL_INIT_SECMEM) at ../../src/visibility.c:79
> #9 0x00007ffff71af10f in ssh_crypto_init () at ./src/libgcrypt.c:621
> #10 0x00007ffff7193796 in _ssh_init (constructor=constructor at entry=1) at ./src/init.c:79
> #11 0x00007ffff71834de in libssh_constructor () at ./src/init.c:116
Ewww, so its crashing in a ELF library constructor for libssh, which
is in turn calling into libgcrypt.
Obviously nothing todo with the test cases we're actually running.
I guess we're confusing the code into thinking it has some wierd
privilege by having geteuid() return 0, while getuid() returns
the normal UID.
Mocking getuid() is ok, but I fear its just a targetting one
specific problem we happen to be hitting today.
So I think we probably ought to make geteuid() delegate the
real getuid() function instead. Have a global flag we can set
& unset just before & after executing the real test code. That
way libraries will see correct UID info in general.
> #12 0x00007ffff7fe437a in call_init (l=<optimized out>, argc=argc at entry=1, argv=argv at entry=0x7fffffffe778, env=env at entry=0x7fffffffe788) at dl-init.c:72
> #13 0x00007ffff7fe4476 in call_init (env=0x7fffffffe788, argv=0x7fffffffe778, argc=1, l=<optimized out>) at dl-init.c:30
> #14 _dl_init (main_map=0x7ffff7ffe190, argc=1, argv=0x7fffffffe778, env=0x7fffffffe788) at dl-init.c:119
> #15 0x00007ffff7fd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
> #16 0x0000000000000001 in ?? ()
> #17 0x00007fffffffea26 in ?? ()
> #18 0x0000000000000000 in ?? ()
>
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
> tests/virnetdevbandwidthmock.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tests/virnetdevbandwidthmock.c b/tests/virnetdevbandwidthmock.c
> index cb48933447..f0c6b22c5f 100644
> --- a/tests/virnetdevbandwidthmock.c
> +++ b/tests/virnetdevbandwidthmock.c
> @@ -24,3 +24,8 @@ uid_t geteuid(void)
> {
> return 0;
> }
> +
> +uid_t getuid(void)
> +{
> + return 0;
> +}
> --
> 2.21.0
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list