in show_gtp_cmd, we have two different checks (argc > 0) vs (argc)
which means in theory argc could be negative and the second clause
would be executed without the first having set up related data such as
'ai'.
Fixes: CID#307521: Explicit null dereferenced (FORWARD_NULL)
Change-Id: I4149b0b191a34168ba6649338d3cdf6c6af6cfe7
We cannot garantee that LOGP will not end up calling a syscall which can
be a cancellation point. Since the syscall will be probably called while
having the logging mutex locked, an eventuall cancellation of the thread
would leave the logging mutex locked forever, hence making all other
threads deadlock as soon as they try to write anything to the log.
Change-Id: I72a0b536c8f39857960f132a5b84cdf5b8519732
The main thread calls pthread_cancel before freeing the tun object.
However, pthread_cancel doesn't kill the thread synchronously (man
pthread_cancel). Hence, the tun thread may still be running for a while
after the tun object is/has been(ing) freed.
Let's avoid this by making sure the thread is stopped before
freeing the object.
To accomplish it, we must wait for the thread to be cancelled. A cleanup
routie is added which will signal the "tun_released" message to the main
thread through an osmo_itq, which will then free the object (since
talloc context is managed by the main thread).
Related: SYS#5523
Change-Id: Idf005359afb41d3413b09281a9ff937d5eafcc7c
The same pid will be handled below tyhrough waitpid. This can be seen
when running PGW_Tests:
"""
20220411134309656 DUECUPS main.c:343 SIGCHLD receive from pid 24; status=0
20220411134309656 DUECUPS main.c:95 r=172.18.18.202:9999<->l=172.18.18.20:4268: JSON Tx '{"program_term_ind": {"exit_code": 0, "pid": 24}}'
20220411134309656 DUECUPS main.c:343 SIGCHLD receive from pid 24; status=0
"""
Change-Id: I348b91097fe9bf78b2c7e33d4f3eaf316618068e
It may happen that multiple threads trying to log at the same time,
and the msgb containing a logging message gets corrupted in
libosmocore's _file_wq_write_cb():
msgb(0x7f5ca2a38150): msgb too small to pull 240 (len 120)
Aborted (core dumped)
'''
rc = write(ofd->fd, msgb_data(msg), msgb_length(msg));
if (rc < 0)
return rc;
if (rc != msgb_length(msg)) { // 240 != 120
/* pull the number of bytes we have already written */
msgb_pull(msg, rc); // <-- we abort() here
/* ask write_queue to re-insert the msgb at the head of the queue */
return -EAGAIN;
}
'''
The return value of write() cannot be greater than the given length.
Most likely, the msgb gets corrupted during the write() system call.
Enabling multithread logging in libosmocore solves the problem.
Change-Id: Ib14d0e36e8cd72465bfe55d19b68dbe3423f7f05
Related: SYS#5602
Fixes: OS#5424
Do not turn some compiler warnings into errors by default. This part was
copied from openbsc.git 34f012 ("Turn some compiler warnings into
errors"), where it was added before --enable-werror was available.
We build with --enable-werror during development and in CI. If the code
is built with a different compiler that throws additional warnings, it
should not stop the build.
Related: OS#5289
Change-Id: Idb04e85d1e241f8b53cf338d9e79da198028565d
configure: 8901: error: Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.
Change-Id: I7a7c4680678cc68b0b81f71af7687386a09afdb5
In file included from /usr/include/libnl3/netlink/socket.h:16:0,
from netdev.c:19:
/usr/include/libnl3/netlink/handlers.h:51:15: warning: ‘struct nlmsgerr’
declared inside parameter list will not be visible outside of this
definition or declaration
struct nlmsgerr *nlerr, void *arg);
Change-Id: Ia2d1b0d5ccf427895feb80298d9b5c3aef1c6c9d
This allows the controlling instance (ttcn3 test case) to start
a process (shell command) within the namespace of a given tunnel
/ tun device.
The controlling instance is informed of the success/failure
of starting the process, as well as the exit code at time of
termination.
Change-Id: I94db625de9f5968e53bf67ce2f941673d9a15fbc
Depends: libosmocore.git If1431f930f72a8d6c1d102426874a11b7a2debd9
Depends: libosmocore.git If8d89dd1f6989e1cd9b9367fad954d65f91ada30