Commit Graph

25801 Commits

Author SHA1 Message Date
Thomas Haller
8113bc22d4 tests/sanitizer: suppress leak in openssl
Suppress a leak report from openssl:

 Direct leak of 192 byte(s) in 1 object(s) allocated from:
     #0 0x7f6fe9c6b677 in __interceptor_malloc (/lib64/libasan.so.6+0xb0677)
     #1 0x7f6fe4d4046d in CRYPTO_zalloc crypto/mem.c:230
     #2 0x7f6fe4d0a91f in ENGINE_new crypto/engine/eng_lib.c:34
     #3 0x7f6fe4d0c40d in ENGINE_rdrand crypto/engine/eng_rdrand.c:70
     #4 0x7f6fe4d0c40d in engine_load_rdrand_int crypto/engine/eng_rdrand.c:85
     #5 0x7f6fe4d370ec in ossl_init_engine_rdrand crypto/init.c:353
     #6 0x7f6fe4d370ec in ossl_init_engine_rdrand_ossl_ crypto/init.c:347
     #7 0x7f6fe995aace in __pthread_once_slow (/lib64/libpthread.so.0+0x11ace)
     #8 0x7f6fe4da68fc in CRYPTO_THREAD_run_once crypto/threads_pthread.c:118
     #9 0x7f6fe4d378ec in OPENSSL_init_crypto crypto/init.c:723
     #10 0x7f6fe4d378ec in OPENSSL_init_crypto crypto/init.c:620
     #11 0x7f6fe5292280  (/usr/lib64/pkcs11/libsofthsm2.so+0x78280)
     #12 0x7f6fe5292364  (/usr/lib64/pkcs11/libsofthsm2.so+0x78364)
     #13 0x7f6fe526f151 in SoftHSM::C_Initialize(void*) /usr/src/debug/softhsm-2.5.0-4.fc32.3.x86_64/src/lib/SoftHSM.cpp:485
     #14 0x7f6fe523cc97 in C_Initialize (/usr/lib64/pkcs11/libsofthsm2.so+0x22c97)
     #15 0x7f6fe4ecb233 in initialize_module_inlock_reentrant ../p11-kit/modules.c:738
     #16 0x7f6fe4ecb382 in managed_C_Initialize ../p11-kit/modules.c:1584
     #17 0x7f6fe4ecdbdf in p11_kit_modules_initialize ../p11-kit/modules.c:2157
     #18 0x7f6fe4ecdbdf in p11_kit_modules_initialize ../p11-kit/modules.c:2145
     #19 0x7f6fe4ed1a96 in proxy_create ../p11-kit/proxy.c:330
     #20 0x7f6fe4ed1a96 in proxy_C_Initialize ../p11-kit/proxy.c:398
     #21 0x7f6fe9a343b1 in secmod_ModuleInit /usr/src/debug/nss-3.51.0-1.fc32.x86_64/nss/lib/pk11wrap/pk11load.c:244
     #22 0x7f6fe9a34adb in secmod_LoadPKCS11Module /usr/src/debug/nss-3.51.0-1.fc32.x86_64/nss/lib/pk11wrap/pk11load.c:501
     #23 0x7f6fe9a419ec in SECMOD_LoadModule /usr/src/debug/nss-3.51.0-1.fc32.x86_64/nss/lib/pk11wrap/pk11pars.c:1840
     #24 0x7f6fe9a41b27 in SECMOD_LoadModule /usr/src/debug/nss-3.51.0-1.fc32.x86_64/nss/lib/pk11wrap/pk11pars.c:1876
     #25 0x7f6fe9a0dd00 in nss_Init /usr/src/debug/nss-3.51.0-1.fc32.x86_64/nss/lib/nss/nssinit.c:712
     #26 0x7f6fe9a0e3ab in NSS_NoDB_Init /usr/src/debug/nss-3.51.0-1.fc32.x86_64/nss/lib/nss/nssinit.c:950
     #27 0x55c942e2f1b2 in _nm_crypto_init libnm-core/nm-crypto-nss.c:61
     #28 0x55c942d6f2da in nm_crypto_load_and_verify_certificate libnm-core/nm-crypto.c:721
     #29 0x55c942c99681 in _cert_impl_set libnm-core/nm-setting-8021x.c:497
     #30 0x55c942c9d83b in nm_setting_802_1x_set_ca_cert libnm-core/nm-setting-8021x.c:1033
     #31 0x55c942c63513 in _test_8021x_cert_from_files libnm-core/tests/test-keyfile.c:382
     #32 0x55c942c6425a in test_8021x_cert libnm-core/tests/test-keyfile.c:436
     #33 0x7f6fe965429d in test_case_run ../glib/gtestutils.c:2633
     #34 0x7f6fe965429d in g_test_run_suite_internal ../glib/gtestutils.c:2721
2020-05-14 12:03:24 +02:00
Thomas Haller
42d45299f9 tests/sanitizer: make ASAN/LSAN/UBSAN options configurable in "tools/run-nm-test.sh"
Also add a suppressions file for LSAN.
2020-05-14 12:03:24 +02:00
Thomas Haller
0a030da6c2 gitlab-ci: add more CentOS images for tests 2020-05-14 12:03:24 +02:00
Thomas Haller
b846f9aba3 gitlab-ci: optionally install libasan,libubsan via REQUIRED_PACKAGES script 2020-05-14 12:03:24 +02:00
Thomas Haller
1473f00d74 gitlab-ci: accept failure in REQUIRED_PACKAGES script for non-existing qt-devel
On CentOS 8, many devel packages are not available. Even after

  # dnf config-manager --set-enabled PowerTools

certain devel packages are missing. Some of these (libndp-devel,
mobile-broadband-provider-info-devel, teamd-devel) we build in copr
([1]), but libpsl-devel and qt-devel are still missing.

Only install them optionally and allow failure for them not being
present.

[1] https://copr.fedorainfracloud.org/coprs/nmstate/nm-build-deps/repo/epel-8/nmstate-nm-build-deps-epel-8.repo
2020-05-14 12:03:24 +02:00
Thomas Haller
14bf28f109 tests: fix uint32 integer constants for TC_H_MAKE()
UBSan marks these:

  libnm-core/tests/test-setting.c:2146:2: runtime error: left shift of 65521 by 16 places cannot be represented in type 'int'
      #0 0x561739bed935 in test_tc_config_qdisc libnm-core/tests/test-setting.c:2146
2020-05-14 12:03:24 +02:00
Thomas Haller
446a145db5 cli: use nm_strdup_int() in "clients/cli/devices.c" 2020-05-14 12:03:24 +02:00
Thomas Haller
a1e12c01df cli: fix leak in show_device_lldp_list() for nmc_parse_lldp_capabilities() 2020-05-14 12:03:23 +02:00
Thomas Haller
589d51ca9d cli: fix leak in show_device_lldp_list() 2020-05-14 11:53:48 +02:00
Thomas Haller
18b903943d cli: fix memcpy() with %NULL pointers in nmc_get_devices_sorted()
UBSan correctly flags this:

  clients/cli/devices.c:966:2: runtime error: null pointer passed as argument 2, which is declared to never be null
2020-05-14 11:06:09 +02:00
Thomas Haller
54a64edefc libnm: don't compare invalid mac addresses as equal in nm_utils_hwaddr_matches()
By passing as length of the MAC addresses -1 for both arguments, one
could get through to compare empty strings, NULL, and addresses longer
than the maximum. Such addresses are not valid, and they should never
compare equal (not even to themselves).

This is a change in behavior of public API, but it never made sense to
claim two addresses are equal, when they are not even valid addresses.

Also, avoid undefined behavior with "NULL, -1, NULL, -1" arguments,
where we would call memcmp() with zero length and NULL arguments.
UBSan flags that too.
2020-05-14 11:06:09 +02:00
Thomas Haller
3c581cbb78 build: fix redefinition of VALGRIND define in "nm-sd-adapt-shared.h"
When configuring with sanitizers enabled, ./configure.ac sets
-DVALGRIND=1 in the CFLAGS.

This causes a compilation error later:

  $ /bin/sh ./libtool  --tag=CC   --mode=compile gcc ... -DVALGRIND=1 ... src/dhcp/nm-dhcp-nettools.c
  ...
  In file included from src/dhcp/nm-dhcp-nettools.c:16:
  ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:73: error: "VALGRIND" redefined [-Werror]
   #define VALGRIND 0
2020-05-13 17:21:01 +02:00
Thomas Haller
801c895aa6 cli: cleanup internal functions in "clients/cli/connections.c"
There should be no change in behavior. Use cleanup attribute.
2020-05-13 10:31:11 +02:00
Thomas Haller
67283b4932 cli: use cleanup attribute in save_history_cmds() 2020-05-13 10:29:39 +02:00
Thomas Haller
f6b1b2401d cli: merge branch 'th/nmcli-passwd-file-parsing'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/488
2020-05-13 10:28:10 +02:00
Thomas Haller
797ee7d5ea cli/tests: add unit test for nmc_utils_parse_passwd_file() 2020-05-13 10:28:05 +02:00
Thomas Haller
38a79ca5cd cli: split parsing from nmc_utils_read_passwd_file()
Makes it easier testable.
2020-05-13 10:28:04 +02:00
Thomas Haller
360f0fae11 cli: move nmc_utils_read_passwd_file() to "common/nm-client-utils.c" 2020-05-13 10:28:04 +02:00
Thomas Haller
1086a47cda cli: refactor error handling in parse_passwords() 2020-05-13 10:28:04 +02:00
Thomas Haller
2285dd38ea cli: support backslash escaping in passwd-file
Rework parsing of nmcli's passwd-file.

1) support backslash escaping of secrets.

  - only the secret can be backslash escaped, the property and setting
    name cannot.

  This is a change in behavior for passwd-files with secrets that contain
  a backslash.

2) strip the white space around the secret. This is a change in behavior
  for secrets that had leading or trailing spaces. Note that you can
  backslash escape spaces in secrets.

3) strip white space around the setting.property key. This is also a
  change in behavior, but such keys would never have been valid
  previously (or the caller would have performed the same kind of
  stripping).

4) accept '=' as alternative delimiter beside ':'. The ':' feels really
  odd and unexpected. Also accept '='. This is a change in behavior if
  keys would contain '=', which they really shouldn't.

5) reject non-UTF-8 secrets and keys. For keys, that is not an issue,
  because such keys were never valid. For secrets, it probably didn't
  work anyway to specify non-UTF-8 secrets, because most (if not all)
  secrets are transmitted via D-Bus as strings where arbitrary binary
  is not allowed.

6) ignore empty lines and lines starting with '#'.

7) ensure we don't leak any secrets in memory.

1) to 4) are changes in behavior. 3) and 4) seem less severe, as they
only concern unusual setting.property keys, which really shouldn't be
used (although, VPN secrets can have almost arbitrary names *sigh*).
1) and 2) is more dangerous, as it changes behavior for secrets that
contain backslashes or leading/trailing white space.
2020-05-13 10:28:04 +02:00
Thomas Haller
bb19f6e29c shared: add NM_UTILS_NAMED_VALUE_INIT() macro 2020-05-13 10:28:04 +02:00
Thomas Haller
0f22f77b1c shared: support stripping whitespace from nm_utils_buf_utf8safe_unescape()
When parsing user input if is often convenient to allow stripping whitespace.
Especially with escaped strings, the user could still escape the whitespace,
if the space should be taken literally.

Add support for that to nm_utils_buf_utf8safe_unescape().

Note that this is not the same as calling g_strstrip() before/after
unescape. That is, because nm_utils_buf_utf8safe_unescape() correctly
preserves escaped whitespace. If you call g_strstrip() before/after
the unescape, you don't know whether the whitespace is escaped.
2020-05-13 10:28:04 +02:00
Thomas Haller
5fe447d4a6 shared: assert that nm_utils_buf_utf8safe_unescape() doesn't reallocate memory
We want to use the function to unescape (compress) secrets. As such, we want
to be sure that no secrets are leaked in memory due to growing the buffer with
realloc. In fact, reallocation should never happen. Assert for that.

As reallocation cannot happen, we could directly fill a buffer with
API like nm_utils_strbuf_*(). But NMStrBuf has low overhead even in this
case.
2020-05-13 10:28:04 +02:00
Antonio Cardace
79f254850c ethtool: merge branch 'ac/ethtool_opts'
Add support for ethtool coalesce options

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/496
2020-05-13 10:15:49 +02:00
Antonio Cardace
e2be41cbbe nm-device: apply ethtool coalesce settings when activating a connection
nm-device now applies ethtool coalesce settings during stage 2 "device
config" of the connection activation.

Coalesce settings will be then restored (according to what the state
was before the connection got activated on the device) when the
connection is deactivated during the device cleanup.

One thing to be noted is that unset coalesce settings (in the profile)
will not be touched at all by NetworkManager so that if the NIC driver
sets some default values these will be preserved unless specifically
overridden by the connection profile.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-13 10:15:23 +02:00
Antonio Cardace
d8f551cf4a platform: add support for coalesce settings using ioctl()
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-13 10:15:23 +02:00
Antonio Cardace
56c48b162b clients: add support for ethtool coalesce settings
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-13 10:15:23 +02:00
Antonio Cardace
4fce8b3efb ifcfg-rh: add support for ethtool coalesce settings
Also update unit tests.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-13 10:15:23 +02:00
Antonio Cardace
b0240db068 ethtool: add coalesce settings
This is the initial support for coalesce settings and only allows
getting/setting, nothing is yet implemented in nm-device.

Also add unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-13 10:15:23 +02:00
Antonio Cardace
858fb211ad keyfile: add support for uint32 variant types when using gendata
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-13 10:15:23 +02:00
Antonio Cardace
cf25497569 wwan: merge branch 'svenschwermer/NetworkManager-master'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/499
2020-05-13 10:08:27 +02:00
Sven Schwermer
99efe69f68 wwan: Set MTU based on what ModemManager exposes
Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com>
2020-05-13 10:07:33 +02:00
Beniamino Galvani
211c6fa795 cli: unref main loop after destroying NMClient instance
Callbacks might reference the main loop when destroying the NMClient
instance. Unref the main loop later.

  # G_DEBUG=fatal-warnings valgrind --num-callers=100 nmcli device wifi connect home
  ^C
  Error: nmcli terminated by signal Interrupt (2)
  Error: Connection activation failed: (0) No reason given.
  ==11050== Invalid read of size 4
  ==11050==    at 0x4C90D3D: g_main_loop_quit (in /usr/lib64/libglib-2.0.so.0.6200.6)
  ==11050==    by 0x431435: quit (devices.c:934)
  ==11050==    by 0x43272C: connected_state_cb (devices.c:1919)
  ==11050==    by 0x4BF6741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x4C0A603: ??? (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x4C133AD: g_signal_emit_valist (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x4C139D2: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x4BFB1C3: ??? (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x4BFAAEC: ??? (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x4BFD86A: g_object_thaw_notify (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x48BA040: _nm_client_notify_event_emit (nm-client.c:937)
  ==11050==    by 0x48CA01F: _dbus_handle_changes_commit (nm-client.c:2850)
  ==11050==    by 0x48CC221: _dbus_handle_changes (nm-client.c:2864)
  ==11050==    by 0x48CC833: _init_release_all (nm-client.c:6969)
  ==11050==    by 0x48D2818: dispose (nm-client.c:7826)
  ==11050==    by 0x4BFBC27: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.6200.6)
  ==11050==    by 0x43FF93: nmc_cleanup (nmcli.c:941)
  ==11050==    by 0x4410AD: main (nmcli.c:1005)
  ==11050==  Address 0x54738fc is 12 bytes inside a block of size 16 free'd
  ==11050==    at 0x4839A0C: free (vg_replace_malloc.c:540)
  ==11050==    by 0x4C9649C: g_free (in /usr/lib64/libglib-2.0.so.0.6200.6)
  ==11050==    by 0x4410A3: main (nmcli.c:1004)
  ==11050==  Block was alloc'd at
  ==11050==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
  ==11050==    by 0x4C96400: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6200.6)
  ==11050==    by 0x4C90A45: g_main_loop_new (in /usr/lib64/libglib-2.0.so.0.6200.6)
  ==11050==    by 0x441020: main (nmcli.c:987)

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/501
2020-05-12 23:00:01 +02:00
Thomas Haller
1c216ca3be wifi: drop extra conditions in nm_wifi_utils_parse_ies() and use NM_SET_OUT()
NM_SET_OUT() macro already has an "if" condition to only do
anything if the output pointer is not NULL.

As such, we don't need to check first. In practice, this only reorders
the checks, which the compiler may anyway do.

Note that above the checks are still relevant, because we want to
avoid the more expensive parsing, if we don't care about the result.
2020-05-12 14:41:09 +02:00
Thomas Haller
b7a2e73bd2 core: add FIXME(release-blocker) comments for match.kernel-command-line behavior
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/431#note_490830
2020-05-12 09:39:51 +02:00
Thomas Haller
755c3af915 libnm: add comment and assertions for handling gendata based setting in init_from_dbus() 2020-05-11 18:50:37 +02:00
Thomas Haller
0d7d2425c4 ethtool: accept %NULL as argument for nm_ethtool_data_get_by_optname()/nm_ethtool_id_get_by_name()
Often it is useful to not accept %NULL as input argument, to catch bugs.
For simple functions like nm_ethtool_id_get_by_name(), such limitations
are more annoying than helpful. Gracefully accept %NULL and treat is
like an invalid ethtool option.
2020-05-11 16:18:22 +02:00
Thomas Haller
2027ff50af ethtool: use NM_MORE_ASSERT_ONCE() in _ASSERT_data() to assert immutable data only once
_ASSERT_data() checks static, immutable data. Even with more asserts enabled,
there is no need to do that every time. Use NM_MORE_ASSERT_ONCE().

Note that NM_MORE_ASSERT_ONCE() will return constant FALSE, when build
without a sufficiently high assertion level. That means, the compiler
will just optimize the rest away.
2020-05-11 14:47:43 +02:00
Thomas Haller
c6e51f61dd release: bump version to 1.25.1-dev after 1.25.0 release 2020-05-08 15:00:46 +02:00
Thomas Haller
3f6f7b06c6 contrib/rpm: log MD5/SHA sums of release tarball during build_clean.sh
When doing a release, we should care about the checksum of the tarball.
Log all of them... also, because fedpkg uses sha512, ftpadmin@gnome uses
sha256, etc.
2020-05-08 14:54:37 +02:00
Thomas Haller
b533bef8cd ovs: enable trace logging not only with NM_MORE_LOGGING
The logging is useful. Always compile it in.
2020-05-08 14:24:14 +02:00
Thomas Haller
ea141ba8f8 release: bump version to 1.24.0 2020-05-08 13:04:27 +02:00
Thomas Haller
d7b63a8a8a NEWS: update 2020-05-08 13:03:27 +02:00
Thomas Haller
747f7d3818 all: use "int/char" instead of "gint/gchar" typedefs
This is also recommended by our checkpatch.pl script.

(cherry picked from commit 2929392855)
2020-05-08 12:57:11 +02:00
Thomas Haller
2929392855 all: use "int/char" instead of "gint/gchar" typedefs
This is also recommended by our checkpatch.pl script.
2020-05-08 12:56:29 +02:00
Thomas Haller
4101894466 libnm: use nm_str_is_empty() in "nm-setting-match.c" 2020-05-08 11:11:43 +02:00
Thomas Haller
dbf14dc38c shared: add nm_str_is_empty() helper
We have nm_str_not_empty() which is the inverse of that. The purpose
of nm_str_not_empty() is to normalize a string to either return
%NULL or a non-empty string, like

   const char *
   get_name (Object *obj)
   {
        return nm_str_not_empty (obj->name);
   }

Sometimes, we however want to check whether a string is not empty.
So, we previously had two choices:

1) use a temporary variable:

     const char *tmp;

     tmp = get_string ();
     if (tmp && tmp[0])
        ...

The problem with this variant is that it's more verbose (by requiring a
temporary variable). Another downside is that there are multiple ways
how to check for an empty string (!tmp[0], tmp[0] == '\0', !strlen (tmp),
strlen (tmp) == 0), and sure enough they are all in use.

2) use !nm_str_not_empty(). But this double negation looks really odd
and confusing.

Add nm_str_is_empty() instead.
2020-05-08 11:10:51 +02:00
Benjamin Porter
1b551ad1c3 man: extents -> extends in man page
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/497
(cherry picked from commit f6e41c19ff)
2020-05-08 08:07:10 +02:00
Benjamin Porter
f6e41c19ff man: extents -> extends in man page
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/497
2020-05-08 08:06:33 +02:00
Thomas Haller
4929879964 bridge: merge branch 'th/bridge-default-value-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/492
2020-05-08 08:05:05 +02:00