Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions #2

Closed
ghost opened this issue Apr 27, 2020 · 2 comments
Closed

Some questions #2

ghost opened this issue Apr 27, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 27, 2020

Sorry for bothering you, it's 5 am and I could not sleep the whole night, so I read about l4 kernels. I am just curious about what is missing from l4re to run pytorch or tensorflow for example? I am not entirely sure I understand the whole concept here, I try to learn about how operating systems work and as far as I understand l4re would give a lot more performance compared to linux in exchange for less features. But I don't fully understand what features and if I really require them, when all I need is running a program fast and deliver the results somehow to a different computer that runs the HTTP or websocket server. Probably it is an oversimplification of the whole thing, but I am not that educated in the topic. Can you explain me?

@jermar
Copy link
Contributor

jermar commented Apr 28, 2020

I am not familiar with either pytorch or tensorflow. Generally, L4Re is a framework of basic components that are useful for creating e.g. virtualization scenarios with different instances of (Linux) VMs. As such, it is not a full-fledged OS itself, but can be used for building one provided you can source the missing components from somewhere else or write them from scratch.

Let me briefly theorize on what is needed to achieve your goal. From the components that are available here on GH, you can use l4virtio to write a VIRTIO net client and connect it via virtio-net to a Linux VM. Your client will probably need a networking stack to sit on top of the virtual NIC, which you'll need to source from somewhere. If you need this to work on real hw, you'll also need to provide the respective drivers (for example from the rumpkernel project or by writing them from scratch). The easiest is to use a VM with a guest OS which already comes with all these components, but then you also get all the other stuff that your application doesn't need. There are different approaches with different trade-offs.

I am going to close this ticket now as this is a question rather than an actual issue.

@jermar jermar closed this as completed Apr 28, 2020
@ghost
Copy link
Author

ghost commented Apr 30, 2020

@jermar Thanks! Both are machine learning libraries, they need Python and GPU. I am just trying to estimate how hard would be filling the gap between these libraries and what L4Re currently offers. But it would have been simpler to ask what I need to run a hellow world in C for example using L4Re on real hardware? I guess the mentioned libraries only need a GPU driver on top of it. Is there a forum where I can ask this or maybe a documentation or article that contains this info?

kk-infra pushed a commit that referenced this issue Apr 29, 2021
This is e3848e3dd64a8d6437531488fe341354bc02eaed from uclibc-ng

The 'BLT' instruction checks for *signed* values. So if a3, length
parameter of memset, is negative, then value added to the PC will be
large.

memset(buf, 0xaa, 0xffff0000) triggers the bug.

GDB session without the patch:

"""
$ gdb ./main-buggy-memset.elf -q
Reading symbols from ./main-buggy-memset.elf...done.
(gdb) x/i memset
   0x8770 <memset>:     mov     r3, r0
(gdb) r
Starting program: /root/memset/main-buggy-memset.elf

Program received signal SIGSEGV, Segmentation fault.
0x00048808 in ?? ()
"""

The $pc is outside of the memset function because:

"""
(gdb) x/i $pc
=> 0x87e4 <memset+116>: add     pc, pc, r2, lsl #2
(gdb) info reg $r2
r2             0x10007  65543
"""

GDB session with the bug fixed (patch applied):

"""
$ gdb ./main-fixed-memset.elf -q
Reading symbols from ./main-fixed-memset.elf...done.
(gdb) x/i memset
   0x8770 <memset>:     mov     r3, r0
(gdb) r
Starting program: /root/memset/main-fixed-memset.elf

Program received signal SIGSEGV, Segmentation fault.
memset () at libc/string/arm/memset.S:92
92      libc/string/arm/memset.S: No such file or directory.
(gdb) x/i $pc
=> 0x87b0 <memset+64>:  stmia   r3!, {r1, r12}
(gdb) info reg $r3
r3             0x15000  86016
(gdb) info proc mappings
process 5822
Mapped address spaces:

        Start Addr   End Addr       Size     Offset objfile
            0x8000     0xb000     0x3000        0x0
/root/memset/main-fixed-memset.elf
           0x12000    0x15000     0x3000     0x2000
/root/memset/main-fixed-memset.elf
        0xb6fff000 0xb7000000     0x1000        0x0 [sigpage]
        0xbefdf000 0xbf000000    0x21000        0x0
        0xffff0000 0xffff1000     0x1000        0x0 [vectors]
(gdb) info reg $sp
sp             0x14d78  0x14d78
"""

GDB crashes inside the memset function, on the store instruction.  This
time the crash is (as expected) because of a memory access imediately
after the memory region that contains the stack -- the buffer that's
being memset'd is allocated on the stack.

Change-Id: Ie1e2a574fc73b27f4a1383cbf1f6210047292ffc
Signed-off-by: Lucian Cojocar <lucian.cojocar@vu.nl>
kk-infra pushed a commit that referenced this issue Oct 26, 2023
On execution of "inet/gethost_r-align" test I noticed failure due
to unaligned access (instaed of 4-byte aligned 1-byte aligned
address was attempted to be accessed).

Further investigation confirmed this nice and helpful test failure.
Following commit removed usage of ALIGN_BUFFER_OFFSET on entry to
__read_etc_hosts_r():
http://git.uclibc.org/uClibc/commit/?id=f65e66078b9f4d2d7f0fc336dee36e78fc467c0f

So indeed if target architecture doesn't allow unaligned access
and provided tmp buffer is not word aligned (and we will deal with pointers
which means word-sized data units), then CPU will fail during execution.

In case of ARC we'll see "Unaligned access" exception like this:
 --->8---
 # potentially unexpected fatal signal 7.
 Path: /root/uClibc/test/inet/gethost_r-align
 CPU: 0 PID: 5514 Comm: gethost_r-align Not tainted 3.13.11 #2
 task: 8f42a580 ti: 8f40e000 task.ti: 8f40e000

 [ECR   ]: 0x00230400 => Misaligned r/w from 0x5fdab341
 [EFA   ]: 0x5fdab341
 [BLINK ]: 0x20032a18
 [ERET  ]: 0x20032a3c
     @off 0x12a3c in [/lib/libuClibc-0.9.34-git.so]
     VMA: 0x20020000 to 0x20062000
 [STAT32]: 0x00000086 : U         E2 E1
 BTA: 0x20046014  SP: 0x5fdab260  FP: 0x00000000
 LPS: 0x20046064 LPE: 0x20046068 LPC: 0x00000000
 r00: 0x5fdab341 r01: 0x00000005 r02: 0x00000015
 r03: 0x00000000 r04: 0x5fdab358 r05: 0x00000000
 r06: 0x0a0a0a00 r07: 0x00000000 r08: 0x0000003f
 r09: 0x20067050 r10: 0x00000000 r11: 0x00000014
 r12: 0x00000001 r13: 0x00000000 r14: 0x20060660
 r15: 0x20060661 r16: 0x00000006 r17: 0x5fdab371
 r18: 0x00000018 r19: 0x5fdab2b4 r20: 0x00020000
 r21: 0x00000000 r22: 0x00029068 r23: 0x5fdab371
 r24: 0x00010000 r25: 0x00000000
 --->8---

To fix this problem we'll re-introduce tmp buffer force alignment
before config parser invocation.

Change-Id: Ifcc2197af1f8c2ca35fbb6970b3467cfe1b67262
Signed-off-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
kk-infra pushed a commit that referenced this issue Feb 29, 2024
This commit squashes the following upstream changes to architectures
not currently supported by L4Re (such as arc or microblaze):

microblaze: add NPTL/TLS support from GNU libc
nios2: sync support with glibc
Revert "sh: fix static linking issue"
sh: remove duplicate code
microblaze: sync sysdep-cancel.h/sydep.h with GNU libc
microblaze: fixup gcc warnings
nds32: in latest gcc from Andes, this got renamed
bfin: fix a gcc warning

--

ARC: nptl: cancellable wrappers were broken
ARC: nptl: cancellable wrappers were broken #2

Reported-by: Eugeniy Paltsev <paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

ARC: update .note.ABI-tag for ABIv4
ARC: build: don't force usage of llock and swape instructions
ARC: string: handle gcc 6.x macro changes
NPTL/ARC: implement __arch_exchange_32_acq using native EX
ARC: introduce explicit support for atomics

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

microblaze: use assembly version of clone, fix vfork

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>

--

NPTL/ARC: provide a kernel assisted atomic cmpxchg

Reported-by: Avinash Patil <avinashp@quantenna.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

uclibc/arch: xtensa: fix static linking

Change-Id: Iab35671ede6c7a094bebc0a1f720c63bcaf9ceea
Signed-off-by: Alexey Neyman <stilor@att.net>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
kk-infra pushed a commit that referenced this issue Feb 29, 2024
This commit collects the following upstream updates to uclibc-ng in
features that are not currently used by L4Re, such as the ARC and nds32
architectures or nptl:

add init_module/delete_module syscall wrappers
use multiline comment for better copyright parsing
nptl: remove pthread_attr_init/pthread_create weak aliases
nptl_db: fix gcc compiler warnings

--

fts: fix gcc compiler warning

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

--

ARC: ldso: don't use _DYNAMIC@gotpc construct #1
ARC: ldso: don't use _DYNAMIC@gotpc construct #2

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

nds32: add NPTL/TLS, *context function, libm changes and code cleanup

Signed-off-by: Vincent Ren-Wei Chen <vincentc@andestech.com>

--

remove PID caching

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Acked-by: Matthew Fortune <Matthew.Fortune@imgtec.com>
Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>

--

extract six-argument syscalls from the rest
use safe, even if possibly a few cycles slower, six-argument syscall implementation

Signed-off-by: mirabilos <m@mirbsd.org>
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

Change-Id: I3cabbe3768071c547d1b19eb9aa9360a72712aa3
scholzp pushed a commit to scholzp/l4re-core that referenced this issue Jun 5, 2024
This commit squashes the following upstream changes to architectures
not currently supported by L4Re (such as arc or microblaze):

microblaze: add NPTL/TLS support from GNU libc
nios2: sync support with glibc
Revert "sh: fix static linking issue"
sh: remove duplicate code
microblaze: sync sysdep-cancel.h/sydep.h with GNU libc
microblaze: fixup gcc warnings
nds32: in latest gcc from Andes, this got renamed
bfin: fix a gcc warning

--

ARC: nptl: cancellable wrappers were broken
ARC: nptl: cancellable wrappers were broken kernkonzept#2

Reported-by: Eugeniy Paltsev <paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

ARC: update .note.ABI-tag for ABIv4
ARC: build: don't force usage of llock and swape instructions
ARC: string: handle gcc 6.x macro changes
NPTL/ARC: implement __arch_exchange_32_acq using native EX
ARC: introduce explicit support for atomics

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

microblaze: use assembly version of clone, fix vfork

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>

--

NPTL/ARC: provide a kernel assisted atomic cmpxchg

Reported-by: Avinash Patil <avinashp@quantenna.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

uclibc/arch: xtensa: fix static linking

Change-Id: Iab35671ede6c7a094bebc0a1f720c63bcaf9ceea
Signed-off-by: Alexey Neyman <stilor@att.net>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
scholzp pushed a commit to scholzp/l4re-core that referenced this issue Jun 5, 2024
This commit collects the following upstream updates to uclibc-ng in
features that are not currently used by L4Re, such as the ARC and nds32
architectures or nptl:

add init_module/delete_module syscall wrappers
use multiline comment for better copyright parsing
nptl: remove pthread_attr_init/pthread_create weak aliases
nptl_db: fix gcc compiler warnings

--

fts: fix gcc compiler warning

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

--

ARC: ldso: don't use _DYNAMIC@gotpc construct kernkonzept#1
ARC: ldso: don't use _DYNAMIC@gotpc construct kernkonzept#2

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

nds32: add NPTL/TLS, *context function, libm changes and code cleanup

Signed-off-by: Vincent Ren-Wei Chen <vincentc@andestech.com>

--

remove PID caching

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Acked-by: Matthew Fortune <Matthew.Fortune@imgtec.com>
Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>

--

extract six-argument syscalls from the rest
use safe, even if possibly a few cycles slower, six-argument syscall implementation

Signed-off-by: mirabilos <m@mirbsd.org>
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

Change-Id: I3cabbe3768071c547d1b19eb9aa9360a72712aa3
scholzp pushed a commit to scholzp/l4re-core that referenced this issue Jun 5, 2024
This commit squashes the following upstream changes to architectures
not currently supported by L4Re (such as arc or microblaze):

microblaze: add NPTL/TLS support from GNU libc
nios2: sync support with glibc
Revert "sh: fix static linking issue"
sh: remove duplicate code
microblaze: sync sysdep-cancel.h/sydep.h with GNU libc
microblaze: fixup gcc warnings
nds32: in latest gcc from Andes, this got renamed
bfin: fix a gcc warning

--

ARC: nptl: cancellable wrappers were broken
ARC: nptl: cancellable wrappers were broken kernkonzept#2

Reported-by: Eugeniy Paltsev <paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

ARC: update .note.ABI-tag for ABIv4
ARC: build: don't force usage of llock and swape instructions
ARC: string: handle gcc 6.x macro changes
NPTL/ARC: implement __arch_exchange_32_acq using native EX
ARC: introduce explicit support for atomics

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

microblaze: use assembly version of clone, fix vfork

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>

--

NPTL/ARC: provide a kernel assisted atomic cmpxchg

Reported-by: Avinash Patil <avinashp@quantenna.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

uclibc/arch: xtensa: fix static linking

Change-Id: Iab35671ede6c7a094bebc0a1f720c63bcaf9ceea
Signed-off-by: Alexey Neyman <stilor@att.net>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
scholzp pushed a commit to scholzp/l4re-core that referenced this issue Jun 5, 2024
This commit collects the following upstream updates to uclibc-ng in
features that are not currently used by L4Re, such as the ARC and nds32
architectures or nptl:

add init_module/delete_module syscall wrappers
use multiline comment for better copyright parsing
nptl: remove pthread_attr_init/pthread_create weak aliases
nptl_db: fix gcc compiler warnings

--

fts: fix gcc compiler warning

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

--

ARC: ldso: don't use _DYNAMIC@gotpc construct kernkonzept#1
ARC: ldso: don't use _DYNAMIC@gotpc construct kernkonzept#2

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

nds32: add NPTL/TLS, *context function, libm changes and code cleanup

Signed-off-by: Vincent Ren-Wei Chen <vincentc@andestech.com>

--

remove PID caching

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Acked-by: Matthew Fortune <Matthew.Fortune@imgtec.com>
Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>

--

extract six-argument syscalls from the rest
use safe, even if possibly a few cycles slower, six-argument syscall implementation

Signed-off-by: mirabilos <m@mirbsd.org>
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

Change-Id: I3cabbe3768071c547d1b19eb9aa9360a72712aa3
scholzp pushed a commit to scholzp/l4re-core that referenced this issue Jun 5, 2024
This commit squashes the following upstream changes to architectures
not currently supported by L4Re (such as arc or microblaze):

microblaze: add NPTL/TLS support from GNU libc
nios2: sync support with glibc
Revert "sh: fix static linking issue"
sh: remove duplicate code
microblaze: sync sysdep-cancel.h/sydep.h with GNU libc
microblaze: fixup gcc warnings
nds32: in latest gcc from Andes, this got renamed
bfin: fix a gcc warning

--

ARC: nptl: cancellable wrappers were broken
ARC: nptl: cancellable wrappers were broken kernkonzept#2

Reported-by: Eugeniy Paltsev <paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

ARC: update .note.ABI-tag for ABIv4
ARC: build: don't force usage of llock and swape instructions
ARC: string: handle gcc 6.x macro changes
NPTL/ARC: implement __arch_exchange_32_acq using native EX
ARC: introduce explicit support for atomics

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

microblaze: use assembly version of clone, fix vfork

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>

--

NPTL/ARC: provide a kernel assisted atomic cmpxchg

Reported-by: Avinash Patil <avinashp@quantenna.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

uclibc/arch: xtensa: fix static linking

Change-Id: Iab35671ede6c7a094bebc0a1f720c63bcaf9ceea
Signed-off-by: Alexey Neyman <stilor@att.net>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
scholzp pushed a commit to scholzp/l4re-core that referenced this issue Jun 5, 2024
This commit collects the following upstream updates to uclibc-ng in
features that are not currently used by L4Re, such as the ARC and nds32
architectures or nptl:

add init_module/delete_module syscall wrappers
use multiline comment for better copyright parsing
nptl: remove pthread_attr_init/pthread_create weak aliases
nptl_db: fix gcc compiler warnings

--

fts: fix gcc compiler warning

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

--

ARC: ldso: don't use _DYNAMIC@gotpc construct kernkonzept#1
ARC: ldso: don't use _DYNAMIC@gotpc construct kernkonzept#2

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

--

nds32: add NPTL/TLS, *context function, libm changes and code cleanup

Signed-off-by: Vincent Ren-Wei Chen <vincentc@andestech.com>

--

remove PID caching

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Acked-by: Matthew Fortune <Matthew.Fortune@imgtec.com>
Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>

--

extract six-argument syscalls from the rest
use safe, even if possibly a few cycles slower, six-argument syscall implementation

Signed-off-by: mirabilos <m@mirbsd.org>
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

Change-Id: I3cabbe3768071c547d1b19eb9aa9360a72712aa3
kk-infra pushed a commit that referenced this issue Jul 17, 2024
- use the provided __res_state() method instead of direct access
  to struct __res_state pointer &_res/*__resp

- change the __UCLIBC_HAS_TLS__ protected __res_state() implementation
  to the one where the comment 'When threaded, _res may be a per-thread
  variable.' indicates this should be used with threads/TLS enabled

Fixes the following segfaults with buildroot raspberrypi3_64_defconfig
(uclibc, -Os, Note: runs fine using the raspberrypi3_defconfig):

  $ /usr/sbin/ntpd -n -d
  1970-01-01T00:01:49 ntpd[249]: INIT: ntpd ntpsec-1.2.0 2021-11-03T20:39:50Z: Starting
  1970-01-01T00:01:49 ntpd[249]: INIT: Command line: /usr/sbin/ntpd -n -d
  1970-01-01T00:01:49 ntpd[249]: INIT: precision = 7.240 usec (-17)
  1970-01-01T00:01:49 ntpd[249]: INIT: successfully locked into RAM
  1970-01-01T00:01:49 ntpd[249]: CONFIG: readconfig: parsing file: /etc/ntp.conf
  1970-01-01T00:01:49 ntpd[249]: CONFIG: restrict nopeer ignored
  1970-01-01T00:01:49 ntpd[249]: INIT: Using SO_TIMESTAMPNS
  1970-01-01T00:01:49 ntpd[249]: IO: Listen and drop on 0 v6wildcard [::]:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen and drop on 1 v4wildcard 0.0.0.0:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 2 lo 127.0.0.1:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 3 eth0 172.16.0.30:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 4 lo [::1]:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 5 eth0 [fe80::ba27:ebff:fea6:340%2]:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listening on routing socket on fd #22 for interface updates
  1970-01-01T00:01:50 ntpd[249]: SYNC: Found 10 servers, suggest minsane at least 3
  1970-01-01T00:01:50 ntpd[249]: INIT: MRU 10922 entries, 13 hash bits, 65536 bytes
  1970-01-01T00:01:50 ntpd[249]: statistics directory /var/NTP/ does not exist or is unwriteable, error No such file or directory
  1970-01-01T00:01:51 ntpd[249]: DNS: dns_probe: 0.pool.ntp.org, cast_flags:8, flags:101
  Segmentation fault (core dumped)

  $ ./host/bin/aarch64-buildroot-linux-uclibc-gdb ./build/ntpsec-1_2_0/build/main/ntpd/ntpd core
  Core was generated by `/usr/sbin/ntpd -n -d'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  (gdb) where
  #0  0x0000007f8ff1f150 in res_sync_func () at libc/inet/resolv.c:3356
  #1  0x0000007f8ff1c468 in __open_nameservers () at libc/inet/resolv.c:949
  #2  0x0000007f8ff1b498 in __dns_lookup (name=0x55943c67f0 "0.pool.ntp.org",
      type=1, outpacket=0x7f8fe91c48, a=0x7f8fe91c08) at libc/inet/resolv.c:1134
  #3  0x0000007f8ff1d744 in __GI_gethostbyname_r (
      name=0x55943c67f0 "0.pool.ntp.org", result_buf=0x7f8fe92628,
      buf=0x7f8fe91d90 "", buflen=992, result=0x7f8fe92670,
      h_errnop=0x7f8fe92668) at libc/inet/resolv.c:1966
  #4  0x0000007f8ff1d9a0 in __GI_gethostbyname2_r (
      name=0x55943c67f0 "0.pool.ntp.org", family=2, result_buf=0x7f8fe92628,
      buf=0x7f8fe91d70 "0.pool.ntp.org", buflen=1024, result=0x7f8fe92670,
      h_errnop=0x7f8fe92668) at libc/inet/resolv.c:2065
  #5  0x0000007f8ff16924 in gaih_inet (name=0x55943c67f0 "0.pool.ntp.org",
      service=0x7f8fe92828, req=0x7f8fe92890, pai=0x7f8fe92838)
      at libc/inet/getaddrinfo.c:596
  #6  0x0000007f8ff17624 in __GI_getaddrinfo (
      name=0x55943c67f0 "0.pool.ntp.org",
      service=0x5582eb8acd "\377H\213D$\bL\211\367H\213\260\270",
      hints=0x7f8fe92890, pai=0x5582ee1bf8) at libc/inet/getaddrinfo.c:957
  #7  0x0000005582ea60f4 in _start ()
  (gdb) p _res
  $1 = {options = 0, nsaddr_list = {{sin_family = 0, sin_port = 0, sin_addr = {
          s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"}, {
        sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0},
        sin_zero = "\000\000\000\000\000\000\000"}, {sin_family = 0,
        sin_port = 0, sin_addr = {s_addr = 0},
        sin_zero = "\000\000\000\000\000\000\000"}}, dnsrch = {0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0}, nscount = 0 '\000', ndots = 0 '\000',
    retrans = 0 '\000', retry = 0 '\000', defdname = '\000' <repeats 255 times>,
    nsort = 0 '\000', pfcode = 0, id = 0, res_h_errno = 0, sort_list = {{addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}}, _u = {
      _ext = {nsaddrs = {0x0, 0x0, 0x0}, nscount = 0 '\000', nstimes = {0, 0,
          0}, nssocks = {0, 0, 0}, nscount6 = 0, nsinit = 0}}}
  (gdb) p &_res
  $2 = (struct __res_state *) 0x7f8ff8fd98 <_res>
  (gdb) p rp
  $3 = (struct __res_state *) 0x7fffffffff

  And the following uclibc code at libc/inet/resolv.c:3356:

  3345 static void res_sync_func(void)
  3346 {
  3347         struct __res_state *rp = &(_res);
  3348         int n;
  3349
  3350         /* If we didn't get malloc failure earlier... */
  3351         if (__nameserver != (void*) &__local_nameserver) {
  3352                 /* TODO:
  3353                  * if (__nameservers < rp->nscount) - try to grow __nameserver[]?
  3354                  */
  3355 #ifdef __UCLIBC_HAS_IPV6__
  3356                 if (__nameservers > rp->_u._ext.nscount)
  3357                         __nameservers = rp->_u._ext.nscount;
  3358                 n = __nameservers;

  The special thing about ntpsec is the DNS lookup in an extra thread
  and/or the call to res_init(), see ntpsec-1_2_0/ntpd/ntp_dns.c:

   69         msyslog(LOG_INFO, "DNS: dns_probe: %s, cast_flags:%x, flags:%x%s",
   70                 hostname, pp->cast_flags, pp->cfg.flags, busy);
   71         if (NULL != active)     /* normally redundant */
   72                 return false;
   73
   74         active = pp;
   75
   76         sigfillset(&block_mask);
   77         pthread_sigmask(SIG_BLOCK, &block_mask, &saved_sig_mask);
   78         rc = pthread_create(&worker, NULL, dns_lookup, pp);

  and

  165 static void* dns_lookup(void* arg)
  166 {
  167         struct peer *pp = (struct peer *) arg;
  168         struct addrinfo hints;
  169
  170 #ifdef HAVE_SECCOMP_H
  171         setup_SIGSYS_trap();      /* enable trap for this thread */
  172 #endif
  173
  174 #ifdef HAVE_RES_INIT
  175         /* Reload DNS servers from /etc/resolv.conf in case DHCP has updated it.
  176          * We only need to do this occasionally, but it's not expensive
  177          * and simpler to do it every time than it is to figure out when
  178          * to do it.
  179          * This res_init() covers NTS too.
  180          */
  181         res_init();
  182 #endif
  183
  184         if (pp->cfg.flags & FLAG_NTS) {
  185 #ifndef DISABLE_NTS
  186                 nts_probe(pp);
  187 #endif
  188         } else {
  189                 ZERO(hints);
  190                 hints.ai_protocol = IPPROTO_UDP;
  191                 hints.ai_socktype = SOCK_DGRAM;
  192                 hints.ai_family = AF(&pp->srcadr);
  193                 gai_rc = getaddrinfo(pp->hostname, NTP_PORTA, &hints, &answer);
  194         }

  $ /usr/lib/uclibc-ng-test/test/inet/tst-res
  Segmentation fault (core dumped)

  $ ./host/bin/aarch64-buildroot-linux-uclibc-gdb ./build/uclibc-ng-test-0844445e7358eb10e716155b55b0fb23e88d644a/test/inet/tst-res core
  Core was generated by `/usr/lib/uclibc-ng-test/test/inet/tst-res'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  (gdb) where
  #0  __GI___res_init () at libc/inet/resolv.c:3514
  #1  0x0000005591e507e4 in main (argc=<optimized out>, argv=<optimized out>)
      at tst-res.c:20

First reported here:
https://lore.kernel.org/buildroot/20211028230131.5f50d6e7@gmx.net/
https://www.mail-archive.com/devel@uclibc-ng.org/msg01085.html

Change-Id: I646dd9dc45be812e82f00cda7227992dcaf41930
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant