Commit graph

20627 commits

Author SHA1 Message Date
Thomas Haller
be2da47a9d libnm: fix memleak for NMDeviceTun:hw-address
Fixes: 337304f19d
(cherry picked from commit 41ea9fffbb)
(cherry picked from commit 38890376fb)
2019-02-19 09:42:29 +01:00
Thomas Haller
3fb254fc82 libnm: fix duplicate free in nm_client_checkpoint_rollback()
#0  0x00007fffea7481e5 in _g_log_abort (breakpoint=1) at gmessages.c:554
    #1  0x00007fffea74951d in g_logv (log_domain=0x7fffea78e00e "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcbb0)
        at gmessages.c:1371
    #2  0x00007fffea7496f3 in g_log
        (log_domain=log_domain@entry=0x7fffea78e00e "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7fffea798320 "%s: assertion '%s' failed")
        at gmessages.c:1413
    #3  0x00007fffea749f2d in g_return_if_fail_warning
        (log_domain=log_domain@entry=0x7fffea78e00e "GLib", pretty_function=pretty_function@entry=0x7fffea799d40 <__func__.4759> "g_atomic_ref_count_dec", expression=expression@entry=0x7fffea799ca1 "g_atomic_int_get (arc) > 0") at gmessages.c:2762
    #4  0x00007fffea754c12 in g_atomic_ref_count_dec (arc=arc@entry=0x5555558c5280) at grefcount.c:260
    #5  0x00007fffea7302c6 in g_hash_table_unref (hash_table=0x5555558c5240) at ghash.c:1101
    #6  0x00007fffea4b6dbc in clear_op_res (simple=0x55555587ed90 [GSimpleAsyncResult]) at gsimpleasyncresult.c:248
    #7  0x00007fffea4b6dbc in g_simple_async_result_finalize (object=0x55555587ed90 [GSimpleAsyncResult]) at gsimpleasyncresult.c:268
    #8  0x00007fffea67b949 in g_object_unref (_object=<optimized out>) at gobject.c:3346
    #9  0x00007fffea67b949 in g_object_unref (_object=0x55555587ed90) at gobject.c:3238
    #10 0x00007fffe95dea2d in checkpoint_rollback_cb (object=<optimized out>, result=<optimized out>, user_data=0x55555587ed90) at libnm/nm-manager.c:1584
    #11 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5c80 [GTask]) at gtask.c:1148
    #12 0x00007fffea4cb196 in g_task_return (task=0x5555558b5c80 [GTask], type=<optimized out>) at gtask.c:1206
    #13 0x00007fffea5096bb in reply_cb (connection=<optimized out>, res=<optimized out>, user_data=0x5555558b5c80) at gdbusproxy.c:2596
    #14 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5d50 [GTask]) at gtask.c:1148
    #15 0x00007fffea4cb196 in g_task_return (task=0x5555558b5d50 [GTask], type=<optimized out>) at gtask.c:1206
    #16 0x00007fffea4fdd4a in g_dbus_connection_call_done (source=<optimized out>, result=0x5555558b5e20, user_data=0x5555558b5d50) at gdbusconnection.c:5715
    #17 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5e20 [GTask]) at gtask.c:1148
    #18 0x00007fffea4ca86d in complete_in_idle_cb (task=task@entry=0x5555558b5e20) at gtask.c:1162
    #19 0x00007fffea73e97b in g_idle_dispatch (source=0x7fffdc04eb90, callback=0x7fffea4ca860 <complete_in_idle_cb>, user_data=0x5555558b5e20) at gmain.c:5620
    #20 0x00007fffea74206d in g_main_dispatch (context=0x5555557c8410) at gmain.c:3182
    #21 0x00007fffea74206d in g_main_context_dispatch (context=context@entry=0x5555557c8410) at gmain.c:3847
    #22 0x00007fffea742438 in g_main_context_iterate (context=0x5555557c8410, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3920
    #23 0x00007fffea742762 in g_main_loop_run (loop=0x55555584ed00) at gmain.c:4116

Fixes: c3efedf54b
(cherry picked from commit 25a3825b51)
(cherry picked from commit a505ab423e)
2019-02-19 09:42:28 +01:00
Lubomir Rintel
58f7b55bde platform/linux: fix setting of IFA_ADDRESS without a peer
Since commit 9ecdba316 ('platform: create netlink messages directly
without libnl-route-3') we're unconditionally setting IFA_ADDRESS to
the peer address, even if there's no peer and it's all zeroes.

The kernel actually stopped caring somewhere around commit caeaba790
('ipv6: add support of peer address') in v3.10, but Ubuntu Touch likes
to run Android's v3.4 on some poorly supported hardware.

Fixes: 9ecdba316c

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/77
(cherry picked from commit ef6d461b7f)
(cherry picked from commit e2409b1888)
2019-02-05 07:16:12 +01:00
Beniamino Galvani
ef6ad04821 vpn: add route to vpn gw when parent has a default device route
When the parent device has a device default route (i.e. without
gateway) and we establish a VPN on top of it, 'ip route get' for the
VPN gateway returns a device route, which is the same result we get
for an unreachable VPN gateway. However it is necessary to add the
route to the gateway or otherwise it will possibly become unreachable
once the VPN gets activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/93
(cherry picked from commit 797eab2f6b)
(cherry picked from commit 6808cd48aa)
2019-02-04 11:12:51 +01:00
Beniamino Galvani
3cadc48aef clients: fix string list setter
Fixes: 5d3736ac65

https://bugzilla.redhat.com/show_bug.cgi?id=1671200
(cherry picked from commit a68b1827ec)
(cherry picked from commit bc83a5035b)
2019-01-31 09:38:58 +01:00
Beniamino Galvani
bf4e97921d supplicant: don't set PMF when the supplicant doesn't support it
When the supplicant does not support PMF we wrongly set
'ieee80211w=0', but since the option is not recognized the connection
fails. Don't set it when unsupported.

Fixes: a9ab50efb1
(cherry picked from commit 58c4cd9cc9)
(cherry picked from commit 542e340f01)
2019-01-17 11:07:44 +01:00
Thomas Haller
691d5273f1 contrib/rpm: don't depend NetworkManager-ovs package on openvswitch on RHEL
On RHEL, openvswitch package is not in the base set of packages. Hence,
we cannot depend NetworkManager-ovs package on openvswitch.

This isn't really a problem, because NetworkManager's OVS plugin must
anyway behave graceful when openvswich service is not running or not
available. It only means, that a user who wants to use the OVS plugin
needs to explicitly install the openvswitch package.

https://bugzilla.redhat.com/show_bug.cgi?id=1629178
https://bugzilla.redhat.com/show_bug.cgi?id=1633190
(cherry picked from commit 669bd33022)
(cherry picked from commit f92d2d7766)
2019-01-16 09:59:28 +01:00
Beniamino Galvani
e511f72458 supplicant: fix ready_count assignment
Fix a wrong backport.

Fixes: 1110e0bcae
(cherry picked from commit d0dd120ab4)
2019-01-14 15:19:23 +01:00
Beniamino Galvani
40adc98a6d supplicant: set optional PMF using global supplicant property
wpa_supplicant is going to change the global default for PMF from 0
(disabled) to 1 (optional) [1], so NM code needs to be adjusted to
work with all wpa_supplicant versions. Furthermore, it is better to
set optional PMF using the 'Pmf' property instead of the 'ieee80211w'
configuration option because the former better handles missing support
in driver [2].

Note that each interface in wpa_supplicant has its own copy of global
configuration and so 'global' options must still be set on each
interface. So, let's set Pmf=1 when each interface gets created and
override it with ieee80211w={0,2} if needed during association.

[1] http://lists.infradead.org/pipermail/hostap/2018-November/039009.html
[2] http://lists.infradead.org/pipermail/hostap/2019-January/039215.html

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/104
(cherry picked from commit a9ab50efb1)
(cherry picked from commit 1110e0bcae)
2019-01-14 14:01:04 +01:00
Beniamino Galvani
09d8eca1c2 cli: fix cleanup after activation from editor
progress_activation_editor_cb() is called multiple times every 120
milliseconds and it must free resources only the last time.

Fixes: f0a2686545

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/51
(cherry picked from commit d091cbdc2f)
(cherry picked from commit fd3658e25f)
2019-01-02 08:57:00 +01:00
Beniamino Galvani
5420456cf1 settings: apply agent-owned secrets from the new connection on update
When updating a connection passing agent-owned secret, they are lost
from @reread_connection after the settings-plugin persists the
connection. Therefore we need to cache and reapply them separately to
the connection so that they can be saved to secret agents later.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/82
(cherry picked from commit a3383726dc)
(cherry picked from commit 95d9fd387b)
2018-12-13 11:31:11 +01:00
Thomas Haller
18103b00d8 connectivity: fix determining the global connectivity state
Since we determine the connectivity state of each device individually,
the global connectivity state is an aggregate of all these states.

I am not sure about considering here devices that don't have the (best)
default route for their respective address family. But anyway.

When we aggregate the best connectivity, we chose the numerical largest
value. That is wrong, because PORTAL is numerically smaller than
LIMITED.

That means, if you have two devices, one with connectivity LIMITED and
one with connectivity PORTAL, then LIMITED wrongly wins.

Fixes: 6b7e9f9b22

https://bugzilla.redhat.com/show_bug.cgi?id=1619873
(cherry picked from commit ade753d06f)
(cherry picked from commit d1e98e334d)
2018-12-11 11:10:15 +01:00
Thomas Haller
c155f776fd libnm: add nm_connectivity_state_cmp() helper
(cherry picked from commit 487ee687d5)
(cherry picked from commit 51b7b10d3d)
2018-12-11 11:10:15 +01:00
Beniamino Galvani
0624814af1 device: always take device down when changing MAC for wifi devices
If the device is not taken down wpa_supplicant does not detect that
the MAC changed and the authentication can fail due to wrong key
derivation.

Fixes: e206a34732

https://bugzilla.redhat.com/show_bug.cgi?id=1656157
(cherry picked from commit 29e8f6d5a1)
(cherry picked from commit b2686110ef)
2018-12-10 13:47:55 +01:00
Beniamino Galvani
f0890cc83f man: add missing connection defaults
(cherry picked from commit a482b27593)
(cherry picked from commit 9135603c93)
2018-12-01 15:31:50 +01:00
Beniamino Galvani
a3546bb28d device: fix wrong connection default property
Fixes: 96cabbcbb8
(cherry picked from commit 218d7687a0)
(cherry picked from commit 70cbda40cb)
2018-12-01 15:31:35 +01:00
Thomas Haller
a47c3b2e24 release: bump version to 1.12.7 (development) 2018-12-01 08:18:00 +01:00
Thomas Haller
913feaed77 release: bump version to 1.12.6 2018-12-01 08:16:54 +01:00
Thomas Haller
8640180a3a release: update NEWS 2018-11-30 17:15:48 +01:00
Thomas Haller
cb46754f24 gitignore: ignore directories added in newer versions
These directories don't exist yet, however are added by newer versions.
When switching branches, the artifacts from these directories wrongly
show up in `git status`. Ignore them.
2018-11-30 17:15:48 +01:00
Thomas Haller
f009f1681e cli: minor cleanup of _set_fcn_gobject_enum()
No need to check again the gtype_class. We did it above already.

(cherry picked from commit 085105fc0e)
(cherry picked from commit 3b782ece71)
2018-11-30 16:56:17 +01:00
Thomas Haller
828a3135aa cli: fix setting "serial.parity" enum
The meta data type descriptor must set .get_gtype only for
GObject properties which are of type int or uint. That is, when
the enum type cannot be automatically detected.

However, NM_SETTING_SERIAL_PARITY is a g_param_spec_enum()
of type NM_TYPE_SETTING_SERIAL_PARITY, so setting the get_gtype()
hook is wrong and leads to a crash

   $ /bin/nmcli connection add type gsm autoconnect no con-name t ifname '*' apn xyz serial.parity 5

   (process:11086): libnmc-CRITICAL **: 15:04:35.180: file clients/common/nm-meta-setting-desc.c: line 1283 (_set_fcn_gobject_enum): should not be reached
   Segmentation fault (core dumped)

That is because the enum property setter does:

    »···if (   has_gtype
    »···    && NM_IN_SET (gtype_prop,
    »···                  G_TYPE_INT,
    »···                  G_TYPE_UINT)
    »···    && G_TYPE_IS_CLASSED (gtype)
    »···    && (gtype_class = g_type_class_ref (gtype))
    »···    && (   (is_flags = G_IS_FLAGS_CLASS (gtype_class))
    »···        || G_IS_ENUM_CLASS (gtype_class))) {
    »···»···/* valid */

meaning, it only allows "has_gtype" if the native "gtype_prop" is
G_TYPE_INT or G_TYPE_UINT.

Fixes: 9a68123827
(cherry picked from commit 127ac25ef8)
(cherry picked from commit 7c78398d3e)
2018-11-30 16:56:13 +01:00
Thomas Haller
cf482ae8ee cli: fix handling uint64 connection property "serial.send-delay"
libnm currently has only one GObject property of type uint64:
"serial.send-delay". However, it's broken because uint64 handling
is not implemented.

    $ nmcli connection add type gsm autoconnect no con-name t ifname '*' apn 'xyz' serial.baud 5
    Connection 't' (4c929f17-9fda-41d6-8f90-897f6d46b078) successfully added.

    $ nmcli connection show t
    ...
    ipv6.dhcp-duid:                         --
    ipv6.dhcp-send-hostname:                yes
    ipv6.dhcp-hostname:                     --
    ipv6.token:                             --

    (process:14016): libnmc-CRITICAL **: 14:08:32.591: file clients/common/nm-meta-setting-desc.c: line 811 (_get_fcn_gobject_int): should not be reached
    serial.baud:                            5
    serial.bits:                            8
    serial.parity:                          none
    serial.stopbits:                        1
    serial.send-delay:                      --
    gsm.number:                             *99#
    ...

    $ nmcli connection add type gsm autoconnect no con-name t ifname '*' apn 'xyz' serial.baud 5 serial.send-delay 100

    (process:14852): libnmc-CRITICAL **: 14:12:24.259: file clients/common/nm-meta-setting-desc.c: line 1131 (_set_fcn_gobject_int): should not be reached
    Segmentation fault (core dumped)

Fixes: b6d9bdcee8
(cherry picked from commit a600b3a3b2)
(cherry picked from commit 1b987a5366)
2018-11-30 16:54:32 +01:00
Thomas Haller
8cb0a13a5b shared: add _nm_utils_ascii_str_to_uint64() helper
(cherry picked from commit c0d292d255)
(cherry picked from commit 79ddb280de)
2018-11-30 16:54:29 +01:00
Lubomir Rintel
1a2db338d1 clients/meta: allow formatting 16-bit values formatted as 0x%04x
This is the preferred way to format WPAN short addresses and PAN IDs.

(cherry picked from commit 8901193816)
2018-11-30 16:54:14 +01:00
Beniamino Galvani
19c650d5d6 clients: fix memory leak when parsing routes
The new hash table should destroy elements stolen from the hash table
returned by nm_utils_parse_variant_attributes().

Fixes: d094914120
(cherry picked from commit 31bda1b837)
(cherry picked from commit 6a9d2740ac)
2018-11-30 16:48:59 +01:00
Thomas Haller
04888726d1 libnm: document nm_utils_parse_variant_attributes() returning floating references
See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1594887
(cherry picked from commit e645aeb12c)
(cherry picked from commit 74a3d184b0)
2018-11-30 16:48:59 +01:00
Beniamino Galvani
8fc0a8a60d cli: avoid crash on device disconnect
When nm_device_disconnect_async() returns, the device could be still
in DEACTIVATING state, and so we also register to device-state signal
notifications to know when the device state goes to DISCONNECTED.

Sometimes it happens that the device state goes to DISCONNECTED before
nm_device_disconnect_async() returns. In this case the signal handler
exits the main loop and then the callback for disconnect_async() is
executed anyway because it was already dispatched, leading to an
invalid memory access.

To avoid this we should cancel nm_device_disconnect_async() when we
are quitting the main loop.

Reproducer:
  nmcli connection add type team ifname t1 con-name t1
  nmcli connection up t1
  nmcli device disconnect t1 & nmcli device delete t1

Crash example:
 ==14955==ERROR: AddressSanitizer: SEGV on unknown address 0xffffffff0000000b (pc 0x7f128c8ba3dd bp 0x0000004be080 sp 0x7ffcda7dc6e0 T0)
 ==14955==The signal is caused by a READ memory access.
    0 0x7f128c8ba3dc in g_string_truncate (/lib64/libglib-2.0.so.0+0x713dc)
    1 0x7f128c8bb4bb in g_string_printf (/lib64/libglib-2.0.so.0+0x724bb)
    2 0x45bdfa in disconnect_device_cb clients/cli/devices.c:2321
    3 0x7f128ca3d1a9 in g_simple_async_result_complete /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gsimpleasyncresult.c:802
    4 0x7f128cf85d0e in device_disconnect_cb libnm/nm-device.c:2354
    5 0x7f128ca4ff73 in g_task_return_now /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gtask.c:1148
    6 0x7f128ca508d5 in g_task_return /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gtask.c:1206
    7 0x7f128ca8ecfc in reply_cb /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gdbusproxy.c:2586
    8 0x7f128ca4ff73 in g_task_return_now /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gtask.c:1148
    9 0x7f128ca508d5 in g_task_return /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gtask.c:1206
    10 0x7f128ca83440 in g_dbus_connection_call_done /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gdbusconnection.c:5713
    11 0x7f128ca4ff73 in g_task_return_now /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gtask.c:1148
    12 0x7f128ca4ffac in complete_in_idle_cb /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gio/gtask.c:1162
    13 0x7f128c893b7a in g_idle_dispatch gmain.c:5620
    14 0x7f128c89726c in g_main_dispatch gmain.c:3182
    15 0x7f128c897637 in g_main_context_iterate gmain.c:3920
    16 0x7f128c897961 in g_main_loop_run (/lib64/libglib-2.0.so.0+0x4e961)
    17 0x473afb in main clients/cli/nmcli.c:1067
    18 0x7f128c6a1412 in __libc_start_main (/lib64/libc.so.6+0x24412)
    19 0x416c39 in _start (/usr/bin/nmcli+0x416c39)

https://github.com/NetworkManager/NetworkManager/pull/254
https://bugzilla.redhat.com/show_bug.cgi?id=1546061
(cherry picked from commit cf1126f60b)
(cherry picked from commit b64abe8572)
2018-11-30 14:31:03 +01:00
Thomas Haller
4909ea71af platform/tests: increase wait timeout in test_cleanup_internal()
Seems this assertion still can fail. Dunno, maybe the timeout was just too
short. Increase it.

(cherry picked from commit b7bdde6e0b)
2018-11-30 09:54:13 +01:00
Thomas Haller
8708da118b dnsmasq/shared: fix setting DNS nameserver and search for shared dnsmasq
Fixes: c8fa7b6f57

(cherry picked from commit 803514df27)
(cherry picked from commit 047747f9e3)
2018-11-29 14:36:41 +01:00
Thomas Haller
c144752fb2 device: merge branch 'th/device-set-mac-addr-no-down'
https://bugzilla.redhat.com/show_bug.cgi?id=1639274

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/54

(cherry picked from commit a8f0da9f91)
(cherry picked from commit dfd376963e)
2018-11-29 14:14:52 +01:00
Thomas Haller
b81648fc6c device: avoid taking down link to change MAC address
A lot of drivers actually support changing the MAC address of a link
without taking it down.

Taking down a link is very bad, because kernel will remove routes
and IPv6 addresses.

For example, if the user used a dispatcher script to add routes,
these will be lost. Note that we may change the MAC address of a
device any time. For example, a VLAN device watches the parent's
MAC address and configures it (with a logging message "parent hardware
address changed to ...").

Try first whether we can change the MAC address without taking the
link down. Only if that fails, retry with taking it down first.

https://bugzilla.redhat.com/show_bug.cgi?id=1639274
(cherry picked from commit e206a34732)
(cherry picked from commit ca4e28ea2b)
2018-11-29 14:13:30 +01:00
Thomas Haller
cfa95ed9b0 platform: add nm_platform_link_get_ifi_flags() helper
Add helper nm_platform_link_get_ifi_flags() to access the
ifi-flags.

This replaces the internal API _link_get_flags() and makes it public.
However, the return value also allows to distinguish between errors
and valid flags.

Also, consider non-visible links. These are links that are in netlink,
but not visible in udev. The ifi-flags are inherrently netlink specific,
so it seems wrong to pretend that the link doesn't exist.

(cherry picked from commit b445b1f8fe)
(cherry picked from commit f8a13422f1)
2018-11-29 14:13:29 +01:00
Sebastien Fabre
bff948b96d dbus: register object manager object before requesting dbus name
Working on NetworkManager 1.12.4 and sometimes (rarely), when creating
a NM client object before NetworkManager service start, this object will
never be running.
In that case, we can see the following log:
"[GLIB-GLib-GIO WARN] Error calling GetManagedObjects() when name
owner :1.5 for name org.freedesktop.NetworkManager came back:
GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod:
No such interface 'org.freedesktop.DBus.ObjectManager' on object
at path /org/freedesktop".

Object Manager object shall be registered before requesting dbus name
to be sure that 'org.freedesktop.Dbus.ObjectManager' interface is present
when name owner change is received by libnm.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/51

(cherry picked from commit dc0cdbb57e)
(cherry picked from commit b2eb897bc0)
2018-11-29 08:01:29 +01:00
Thomas Haller
7820d71ef0 platform/tests: fix assertion for unit test for address lifetime
Sometimes the test fail:

    $ make -j 10 src/platform/tests/test-address-linux
    $ while true; do
          NMTST_DEBUG=d ./tools/run-nm-test.sh src/platform/tests/test-address-linux 2>&1 > log.txt || break;
      done

fails with:

    ERROR: src/platform/tests/test-address-linux - Bail out! test:ERROR:src/platform/tests/test-common.c:790:nmtstp_ip_address_assert_lifetime: assertion failed (adr <= lft): (1001 <= 1000)

That is, because of a wrong check. Fix it.

(cherry picked from commit e180464bcc)
(cherry picked from commit 66cbca1f21)
2018-11-28 16:17:53 +01:00
Patrick Talbert
3444c1145d clients: Fix typo in _dump_team_link_watcher output
This makes the output of a 'con show' for a team device look suspect.

Signed-off-by: Patrick Talbert <ptalbert@redhat.com>

Fixes: 4657390d45

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/53
(cherry picked from commit 25a0739658)
(cherry picked from commit e28bfa41a0)
2018-11-23 17:42:04 +01:00
Beniamino Galvani
b5468828f4 libnm-core: fix documentation for connection.mdns
After an update of the connection.mdns property, a reactivation is
needed to apply the new value.

Also, the ifcfg-rh variable name was wrong.

Fixes: 2e2ff6f27a
(cherry picked from commit 8e6ad2853c)
2018-11-22 11:44:25 +01:00
Beniamino Galvani
6d4ad477b8 lldp: fix parsing of vlan-name attribute
We used to read 3 bytes after the TLV, fix this.

Also, check that string length is at most 32 bytes as specified in
figure E.3 of IEEE 802.1AB-2009.

Fixes: 18133ea142

https://bugzilla.redhat.com/show_bug.cgi?id=1652210
(cherry picked from commit e909778710)
(cherry picked from commit 05c27c3c50)
2018-11-22 09:47:06 +01:00
Lubomir Rintel
5349e59f3f libnm/remote-connection: fix "flags" property getter
Fixes: acc8244ca2

https://github.com/NetworkManager/NetworkManager/pull/250
(cherry picked from commit 42e4d09844)
2018-11-21 11:50:55 +01:00
Benjamin Berg
d535f95b6b systemd: fix crash by unrefing event sources before re-adding them
In certain cases the timeouts may not have been unref'ed before they
need to be re-added. Add the appropriate unref calls to ensure we don't
register the timeout multiple times.

This fixes possible cases where timeouts are triggered multiple times
and even on destroyed DHCPv6 clients.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/73

(cherry picked from commit e179202e47)
(cherry picked from commit bbef6cf44a)
2018-11-15 14:52:53 +01:00
Corentin Noël
000c805921 libnm: fix GObject Introspection annotations for functions returning a GPtrArray
The GPtrArray owns the element so it is a (transfer full).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/46
(cherry picked from commit 201c153e25)
(cherry picked from commit 7d5cce2e10)
2018-11-12 13:04:34 +01:00
Thomas Haller
d95bdd00bb systemd: merge branch 'CVE-2018-15688' into nm-1-12 2018-10-29 16:39:53 +01:00
Lennart Poettering
cc1e5a7f57 dhcp6: make sure we have enough space for the DHCP6 option header
Fixes a vulnerability originally discovered by Felix Wilhelm from
Google.

CVE-2018-15688
LP: #1795921
https://bugzilla.redhat.com/show_bug.cgi?id=1639067

(cherry picked from commit 4dac5eaba4e419b29c97da38a8b1f82336c2c892)
(cherry picked from commit 01ca2053bb)
(cherry picked from commit fc230dca13)
2018-10-29 16:31:36 +01:00
Li Song
f211b140a5 sd-dhcp: remove unreachable route after rebinding return NAK
(cherry picked from commit cc3981b1272b9ce37e7d734a7b2f42e84acac535)
(cherry picked from commit 915c2f675a)
(cherry picked from commit cb77290a69)
2018-10-29 16:31:36 +01:00
Yu Watanabe
c836279fca sd-dhcp6: make dhcp6_option_parse_domainname() not store empty domain
This improves performance of fuzzer.
C.f. oss-fuzz#11019.

(cherry picked from commit 3c72b6ed4252e7ff5f7704bfe44557ec197b47fa)
(cherry picked from commit 50403cccee)
(cherry picked from commit f11f5abb1a)
2018-10-29 16:31:36 +01:00
Yu Watanabe
6ea13fc825 sd-dhcp6: fix argument and error handling of dhcp6_option_parse_status()
(cherry picked from commit 91c43f3978fa7c8341550b9ca279e460ba7e74e6)
(cherry picked from commit 373cbfc8c6)
(cherry picked from commit 0e93fd895d)
2018-10-29 16:31:36 +01:00
Yu Watanabe
15a3c6c692 dhcp6: fix buffer size checking
(cherry picked from commit cb1bdeaf56852275e6b0dd1fba932bb174767f70)
(cherry picked from commit 91fb1673d5)
2018-10-29 16:31:36 +01:00
Yu Watanabe
3fd9d11619 sd-dhcp-lease: fix memleaks
(cherry picked from commit e2975f854831d08a25b4f5eb329b6d04102e115f)
(cherry picked from commit 157094abd8)
2018-10-29 16:31:36 +01:00
Evgeny Vereshchagin
5b140a77bc dhcp6: fix an off-by-one error in dhcp6_option_parse_domainname
==14==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200055fa9c at pc 0x0000005458f1 bp 0x7ffc78940d90 sp 0x7ffc78940d88
READ of size 1 at 0x60200055fa9c thread T0
    #0 0x5458f0 in dhcp6_option_parse_domainname /work/build/../../src/systemd/src/libsystemd-network/dhcp6-option.c:555:29
    #1 0x54706e in dhcp6_lease_set_domains /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-lease.c:242:13
    #2 0x53fce0 in client_parse_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:984:29
    #3 0x53f3bc in client_receive_advertise /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1083:13
    #4 0x53d57f in client_receive_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1182:21
    #5 0x7f0f7159deee in source_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3042:21
    #6 0x7f0f7159d431 in sd_event_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3455:21
    #7 0x7f0f7159ea8d in sd_event_run /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3512:21
    #8 0x531f2b in fuzz_client /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:44:9
    #9 0x531bc1 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:53:9
    #10 0x57bec8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:570:15
    #11 0x579d67 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:479:3
    #12 0x57dc92 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:707:19
    #13 0x580ca6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:838:5
    #14 0x55e968 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
    #15 0x551a1c in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #16 0x7f0f701a082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #17 0x41e928 in _start (/out/fuzz-dhcp6-client+0x41e928)

https://github.com/systemd/systemd/pull/10200
b387d3c132
(cherry picked from commit 7cb7cffc49)
(cherry picked from commit cd3aacefdd)
2018-10-29 16:31:36 +01:00
Yu Watanabe
8b8b248679 dhcp6: check option length before reading values
Fixes oss-fuzz#10746
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10746.

https://github.com/systemd/systemd/pull/10213
84452783b8
(cherry picked from commit 484e92e17f)
(cherry picked from commit 0cec1cb93e)
2018-10-29 16:31:36 +01:00