Commit graph

20583 commits

Author SHA1 Message Date
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
Thomas Haller
f37ed84ca4 systemd/dhcp: fix assertion starting DHCP client without MAC address
An assertion in dhcp_network_bind_raw_socket() is triggered when
starting an sd_dhcp_client without setting setting a MAC address
first.

  - sd_dhcp_client_start()
    - client_start()
      - client_start_delayed()
        - dhcp_network_bind_raw_socket()

In that case, the arp-type and MAC address is still unset. Note that
dhcp_network_bind_raw_socket() already checks for a valid arp-type
and MAC address below, so we should just gracefully return -EINVAL.

Maybe sd_dhcp_client_start() should fail earlier when starting without
MAC address. But the failure here will be correctly propagated and
the start aborted.

See-also: https://github.com/systemd/systemd/pull/10054
(cherry picked from commit 34af574d58)
(cherry picked from commit 0a797bdc2a)
2018-10-29 16:31:33 +01:00
Thomas Haller
3d23e9d68f libnm: fix crash in activate_info_complete() when cancelling
We must disconnect ActivateInfo before invoking callbacks.

Otherwise, it can happen that the callee cancels the cancellable,
which in turn enters activate_info_complete() again, and leads
to a crash.

https://bugzilla.redhat.com/show_bug.cgi?id=1642625
(cherry picked from commit ec37e18c64)
(cherry picked from commit 2c6fafad7a)
2018-10-25 15:31:46 +02:00
Frederic Danis
b9357b3aa3 core: fix route metric set to -1 on DHCP renewal
The first DHCP renew after setting back Ethernet metric to default (-1)
applies a metric of 4294967295 (uint16 -1) instead of the default metric.

The route becomes:
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref Use Iface
  0.0.0.0         0.0.0.0         0.0.0.0         U     700    0     0 ppp0
  0.0.0.0         192.168.19.193  0.0.0.0         UG    -1     0     0 eth0
  10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0     0 ppp0
  10.64.64.64     0.0.0.0         255.255.255.255 UH    700    0     0 ppp0
  10.250.0.0      0.0.0.0         255.255.0.0     U     50     0     0 tun0
  192.168.19.0    0.0.0.0         255.255.255.0   U     100    0     0 eth0
  192.168.19.193  0.0.0.0         255.255.255.255 UH    100    0     0 eth0
  217.114.201.194 192.168.19.193  255.255.255.255 UGH   100    0     0 eth0

Route update traces:
  Sep 20 09:53:11.869027 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): REQUEST (renewing)
  Sep 20 09:53:11.873766 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): ACK
  Sep 20 09:53:11.873792 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): lease expires in 1min 58s
  Sep 20 09:53:11.873800 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): T2 expires in 1min 35s
  Sep 20 09:53:11.873808 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): T1 expires in 50s
  Sep 20 09:53:11.873845 tap-0FB1 NetworkManager[762]: <debug> dhcp4 (eth0): client event 4
  Sep 20 09:53:11.873853 tap-0FB1 NetworkManager[762]: <debug> dhcp4 (eth0): lease available
  Sep 20 09:53:11.873881 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   address 192.168.19.100
  Sep 20 09:53:11.873890 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   plen 24
  Sep 20 09:53:11.873899 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   expires in 120 seconds
  Sep 20 09:53:11.873916 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   nameserver '192.168.19.193'
  Sep 20 09:53:11.873925 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   hostname 'TAPOFB1'
  Sep 20 09:53:11.873932 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   gateway 192.168.19.193
  Sep 20 09:53:11.874064 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0): state changed bound -> bound
  Sep 20 09:53:11.874082 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): new DHCPv4 client state 1
  Sep 20 09:53:11.874535 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): ip4-config: update (commit=1, new-config=0x558dc6110be0)
  Sep 20 09:53:11.874569 tap-0FB1 NetworkManager[762]: <debug> platform: address: adding or updating IPv4 address: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-0[120,120] dev 2 flags noprefixroute src unkn
  Sep 20 09:53:11.874626 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_NEWADDR, flags 0, seq 141: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-237[120,120] dev 2 flags noprl
  Sep 20 09:53:11.874653 tap-0FB1 NetworkManager[762]: <debug> platform: signal: address 4 changed: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-237[120,120] dev 2 flags noprefixroute src kernel
  Sep 20 09:53:11.874671 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): queued IP4 config change
  Sep 20 09:53:11.874699 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-add-ip4-address[2: 192.168.19.100/24]: success
  Sep 20 09:53:11.874723 tap-0FB1 NetworkManager[762]: <debug> platform: route: append     IPv4 route: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src dhcp
  Sep 20 09:53:11.874778 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_NEWROUTE, flags excl,create, seq 142: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcl
  Sep 20 09:53:11.874809 tap-0FB1 NetworkManager[762]: <debug> platform: signal: route   4   added: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874846 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-add-ip4-route[0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcp scope global]: success
  Sep 20 09:53:11.874867 tap-0FB1 NetworkManager[762]: <debug> platform: ip4-route: delete 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874904 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_DELROUTE, flags 0, seq 143: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874930 tap-0FB1 NetworkManager[762]: <debug> platform: signal: route   4 removed: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874961 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-delete-ip4-route[0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global]: success
  Sep 20 09:53:11.874983 tap-0FB1 NetworkManager[762]: <trace> platform: ip4-dev-route: register 192.168.19.0/24 via 0.0.0.0 dev 2 metric 0 mss 0 rt-src rt-kernel scope link pref-src 192.168.19.100 (update)

https://mail.gnome.org/archives/networkmanager-list/2018-September/msg00020.html

Fixes: b9e6433a02
(cherry picked from commit 7d155757b1)
(cherry picked from commit 474cf75054)
2018-10-23 10:18:24 +02:00
Lubomir Rintel
77234c352d ndisc: mark a keep-alive variable unused
Fixed build with clang:

  src/ndisc/nm-lndp-ndisc.c:494:27: error: unused variable 'ndisc_keep_alive' [-Werror,-Wunused-variable]
        gs_unref_object NMNDisc *ndisc_keep_alive = g_object_ref (ndisc);
                                 ^
Fixes: 9aa628cedb

(cherry picked from commit 7c7e4cf134)
(cherry picked from commit 506f781488)
2018-10-22 18:25:09 +02:00
Beniamino Galvani
65a9cf0203 cli: fix crash when removing devices
When a software device is removed by nmcli in parallel with a
disconnection, e.g.:

     nmcli connection add type team ifname t1 con-name t1
     sleep 1
     nmcli connection down t1 & nmcli device delete t1

nmcli sometimes crashes in the following way:

 ...
 Connection 't1' (e4701688-d1a9-4942-85f0-a2081e120023) successfully added.
 Connection 't1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/36)
 Device 't1' successfully removed.
 AddressSanitizer:DEADLYSIGNAL
 =================================================================
 ==15217==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000000b (pc 0x7fa6d92d1c9d bp 0x0000004ba260 sp 0x7ffffe6a6f40 T0)
 ==15217==The signal is caused by a READ memory access.
 ==15217==Hint: address points to the zero page.
     0 0x7fa6d92d1c9c in g_string_truncate (/lib64/libglib-2.0.so.0+0x6ec9c)
     1 0x7fa6d92d2d7b in g_string_printf (/lib64/libglib-2.0.so.0+0x6fd7b)
     2 0x45a6d7 in delete_device_cb clients/cli/devices.c:2465
     3 0x7fa6d9849289 in g_simple_async_result_complete /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gsimpleasyncresult.c:802
     4 0x7fa6dbaa9836 in device_delete_cb libnm/nm-device.c:2458
     5 0x7fa6d985bcf3 in g_task_return_now /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gtask.c:1148
     6 0x7fa6d985c7a5 in g_task_return /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gtask.c:1206
     7 0x7fa6d989ca6c in reply_cb /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gdbusproxy.c:2586
     8 0x7fa6d985bcf3 in g_task_return_now /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gtask.c:1148
     9 0x7fa6d985c7a5 in g_task_return /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gtask.c:1206
     10 0x7fa6d98913c0 in g_dbus_connection_call_done /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gdbusconnection.c:5722
     11 0x7fa6d985bcf3 in g_task_return_now /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gtask.c:1148
     12 0x7fa6d985bd2c in complete_in_idle_cb /usr/src/debug/glib2-2.56.1-1.fc28.x86_64/gio/gtask.c:1162
     13 0x7fa6d92ac0ea in g_idle_dispatch gmain.c:5535
     14 0x7fa6d92af7cc in g_main_dispatch gmain.c:3177
     15 0x7fa6d92afb97 in g_main_context_iterate gmain.c:3903
     16 0x7fa6d92afec1 in g_main_loop_run (/lib64/libglib-2.0.so.0+0x4cec1)
     17 0x472892 in main clients/cli/nmcli.c:1067
     18 0x7fa6d8cc31ba in __libc_start_main (/lib64/libc.so.6+0x231ba)
     19 0x4162b9 in _start (/usr/bin/nmcli+0x4162b9)

The reason is that after calling nm_device_delete_async() we also
listen for the manager device-removed signal. When the signal is
received, device_removed_cb() destroy the @info structure and calls
g_main_loop_quit (loop). However, if the delete_device_cb() callback
has already been dispatched it is executed anyway and it tries to
access a stale @info.

It makes little sense to listen for the device-removed signal since
the return value of nm_device_delete_async() already tells us whether
the device was removed successfully or not.

The only advantage would be that when the device goes away for other
reasons we can still return success, but that is racy and should not
be relied upon.

https://bugzilla.redhat.com/show_bug.cgi?id=1639208
(cherry picked from commit 6130a4561e)
(cherry picked from commit 8123c42e61)
2018-10-22 09:32:34 +02:00
Beniamino Galvani
b0d2244db1 libnm: add mdns backported symbols from 1.10.14
Add to branch 1.12 mdns symbols that were backported to 1.10.14 to
allow seamless upgrading from 1.10 to 1.12.
2018-10-19 19:30:40 +02:00
Thomas Haller
c7d8f17094 ndisc: merge branch 'th/ndisc-addr-lifetime'
https://github.com/NetworkManager/NetworkManager/pull/228

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/57
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1796622

(cherry picked from commit 3baa016f89)
(cherry picked from commit 8c24119859)
2018-10-13 17:48:43 +02:00
Thomas Haller
148c9d9b0c ndisc: don't update dad_counter for addresses in router config
I am not sure, we ever call complete_address() for router-configurations.
Maybe not, so the dad-counter is never incremented and does not matter either.

If we however do, then we certainly want to preserve the DAD counter
when the address is already tracked.

(cherry picked from commit 8c6629b356)
(cherry picked from commit 036d1f56ea)
2018-10-13 17:48:31 +02:00
Thomas Haller
451bf6e275 ndisc: fix updating address lifetime on Router Announcement according to RFC4862
This is a denial-of-service protection, where a malicious router
advertisement can expire the addresses.

See-also: 6554550f35
See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3

https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1796622
(cherry picked from commit 27be3e0338)
(cherry picked from commit 8e2ccd3921)
2018-10-13 17:48:31 +02:00
Thomas Haller
42e61a8cc8 ndisc: handle integer overflows better for lifetime handling
we use get_expiry() to compare two lifetimes. Note, that previously,
it would correctly truncate the calculated expiry at G_MAXINT32-1.

However, that means, that two different lifetimes that both lie
more than 68 years in the future would compare equal.

Fix that, but extending the range to int64, so that no overflow
can happen.

(cherry picked from commit b086535cb7)
(cherry picked from commit fe60843232)
2018-10-13 17:48:31 +02:00
Thomas Haller
669e004299 ndisc: minor refactoring loop in nm_ndisc_add_address()
No change in behavior. Just don't do so much work inside
the deeper nesting of the loop.

(cherry picked from commit 9d0a138ef0)
(cherry picked from commit 3cecb4d018)
2018-10-13 17:48:31 +02:00
Thomas Haller
b2f084a8ae ndisc: only generate address interface identifer after checking existing prefix
RFC4862 5.5.3, points d) and e) make it clear, that the list of
addresses should be compared based on the prefix.

  d)  If the prefix advertised is not equal to the prefix of an
    address configured by stateless autoconfiguration already in the
    list of addresses associated with the interface (where "equal"
    means the two prefix lengths are the same and the first prefix-
    length bits of the prefixes are identical), and if the Valid
    Lifetime is not 0, form an address (and add it to the list) by
    combining the advertised prefix with an interface identifier of
    the link as follows:

That means, we should not initialize the interface identifier first
(via complete_address()) and then search for the full address.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
(cherry picked from commit 23c417854a)
(cherry picked from commit ac5669633c)
2018-10-13 17:48:31 +02:00
Thomas Haller
547dcacbfb ndisc: ensure we skip unspecified IPv6 address in ndisc_set_router_config()
Later, nm_ndisc_add_address() asserts that the address is not an
unspecified address. Skip it, just to be sure.

(cherry picked from commit 700b04d0de)
(cherry picked from commit e0e698e463)
2018-10-13 17:48:31 +02:00
Thomas Haller
dbfa7950cf ndisc: ignore addresses with preferred lifetime larger than lifetime
Previously, we would coerce the value so that preferred is the same
as lifetime. However, RFC4862 5.5.3.c) says:

  c)  If the preferred lifetime is greater than the valid lifetime,
    silently ignore the Prefix Information option.  A node MAY wish to
    log a system management error in this case.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
(cherry picked from commit 43c3c259c8)
(cherry picked from commit eff9e161cb)
2018-10-13 17:48:31 +02:00
Thomas Haller
685573e049 ndisc: merge branch 'th/ndisc-fixes'
https://github.com/NetworkManager/NetworkManager/pull/219

(cherry picked from commit 6e41d79067)
(cherry picked from commit 8ee0ca8cce)
2018-10-13 17:47:01 +02:00
Thomas Haller
9f6a654999 ndisc: always emit changed signal if an ndisc parameter changes
Note how the nm_ndisc_add_*() return a boolean to indicate whether
anything changes. That is taken to decide whether to emit a changed
signal.

Previously, we would not consider all fields which are exposed
as public API.

Note that nm-ip6-config.c would care about the lifetime of NMNDiscAddress.
For that, nm_ndisc_add_address() would correctly consider a change of
the lifetime as relevant. So, this was for the most part not broken.
However, for example nm_ndisc_add_route() would ignore changes to the
gateway.

Always signal changes if anything changes at all. It's more correct
and robust.

(cherry picked from commit 98ec56c670)
(cherry picked from commit 2e12660dd4)
2018-10-13 17:46:42 +02:00
Thomas Haller
cdc5848be7 ndisc/trivial: move code
(cherry picked from commit 4f78d82fcd)
(cherry picked from commit bd41719f95)
2018-10-13 17:46:42 +02:00
Thomas Haller
5c56404dfc ndisc: abort handling IO in event_ready() if we are unable to switch namespace
It should never happen that we are unable to switch the namespace.
However, in case it does, we cannot just return G_SOURCE_CONTINUE,
because we will just endlessly trying to process IO without actually
reading from the socket.

This shouldn't happen, but the instance is hosed and something is
very wrong. No longer handle the socket to avoid an endless loop.

(cherry picked from commit d444fcde34)
(cherry picked from commit 6631debaa3)
2018-10-13 17:46:42 +02:00
Thomas Haller
2ba6d74bca ndisc: keep NMNDisc instance alive while processing IO in event_ready()
event_ready() calls ndp_callall_eventfd_handler(), which invokes
our own callback, which may invoke change notification.

At that point, it's not guaranteed that the signal handler won't
destroy the ndisc instance, which means, the "struct ndp" gets destroyed
while invoking callbacks. That's bad, because libndp is not robust
against that.

Ensure the object stays alive long enough.

(cherry picked from commit 9aa628cedb)
(cherry picked from commit efb9e2bc6b)
2018-10-13 17:46:42 +02:00
Thomas Haller
6858e794f3 ndisc: first reschedule timeout before invoking change event in check_timestamps()
It's just ugly to invoke external code in the middel of an operation.
You never know, whether the handler won' unref the ndisc instance.

(cherry picked from commit 1f856b7cb3)
(cherry picked from commit a3c73e783b)
2018-10-13 17:46:42 +02:00
Lubomir Rintel
391e298dfb devices/olpc: don't assert we're waiting for companion on device_added_cb()
We're hooking the signal on construction, but we only queue a pending
action on reaching UNAVAILABLE state. The signal could fire in between:

  <info>  [1539282167.9666] manager: (msh0): new 802.11 OLPC Mesh device (/org/freedesktop/NetworkManager/Devices/4)
  <info>  [1539282168.1440] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/5)
  <info>  [1539282168.1831] device (msh0): found companion WiFi device wlan0
  <warn>  [1539282168.2110] device (msh0): remove_pending_action (1): 'waiting-for-companion' not pending
  file src/devices/nm-device.c: line 13966 (<dropped>): should not be reached

https://github.com/NetworkManager/NetworkManager/pull/229
(cherry picked from commit 08225c5e96)
(cherry picked from commit 7e793bf3b4)
2018-10-12 12:58:08 +02:00
Thomas Haller
7c09527d5e wwan: don't assume DNS info is always available for IPv6
See also "5df024f57a wwan: don't assume DNS info is always available"
which does the same for IPv4.

(cherry picked from commit cec7ade86c)
(cherry picked from commit 00f14736e6)
2018-10-12 00:18:55 +02:00
Thomas Haller
dcec33798e platform/netlink: fix overrun in attribute iteration in nla_ok()
See-also: 123dc07bcc
See-also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1045b03e07d85f3545118510a587035536030c1c
(cherry picked from commit c295d45a3b)
(cherry picked from commit ec1c512e40)
2018-10-10 12:17:13 +02:00
Lubomir Rintel
89b7f638ed devices/olpc: correct the signal handler arguments
Commit 631ca806 ("devices/wifi: flip meaning of scanning allowed
signal") added a "periodic" argument, but the OLPC companion handler was
not adjusted. Fix it now.

https://github.com/NetworkManager/NetworkManager/pull/222

Fixes: 631ca80692
(cherry picked from commit aa0e395530)
2018-10-09 20:24:23 +02:00
Thomas Haller
5583fffddb ppp: cleanup logging in impl_ppp_manager_set_ifindex()
It's enough that all code paths in impl_ppp_manager_set_ifindex() log exactly
one message. Also, give all messages the same prefix, so that it's clear where
they come from.

(cherry picked from commit 2a45c32e8c)
(cherry picked from commit d3ba511cce)
2018-10-04 20:50:22 +02:00
Thomas Haller
b366f89bea ppp: downgrade warning about repeated SetIfindex calls from ppp plugin
In src/ppp/nm-pppd-plugin.c, it seems that pppd can invoke
phasechange(PHASE_RUNNING:) multiple times. Hence, the plugin
calls SetIfindex multiple times too. In nm-ppp-manager.c, we
want to make sure that the ifindex does not change after it
was set once. However, calling SetIfindex with the same ifindex
is not something worth warning. Just log a debug message and nothing.

Maybe the plugin should remember that it already set the ifindex,
and avoid multiple D-Bus calls. But it's unclear that that is desired.
For now, just downgrade the warning.

(cherry picked from commit 4a4439835d)
(cherry picked from commit d3e0a0f9b3)
2018-10-04 20:49:52 +02:00
Thomas Haller
7a8b692226 ppp: avoid strncpy() in ppp plugin nm_phasechange()
strncpy() is deemed insecure, and it raises at least an eyebrow.
While it's save in this case, just avoid it.

(cherry picked from commit 4d11eba8c5)
(cherry picked from commit 2f6af40cd5)
2018-10-04 20:44:26 +02:00
AsciiWolf
14732eef90 po: update Czech (cz) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/19
2018-09-30 22:09:59 +02:00
Beniamino Galvani
6f6a810189 wifi: support hidden ssid in AP mode
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/48
(cherry picked from commit 5d97e76c7d)
(cherry picked from commit f235d57a3a)
2018-09-27 14:16:37 +02:00
Thomas Haller
ea4150d08f libnm: don't skip NMObject:path from documentation and introspection
The D-Bus path is a useful property, also exposed via
nm_object_get_path() function. Don't mark it to be
skipped from documentation and introspection.

This was changed in "1f5b48a59e libnm: use the o.fd.DBus.ObjectManager
API for object management" and was an API breakage of libnm.
This also caused a bug in gnome-shell [1].

[1] https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/240/diffs
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1628263

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

Fixes: 1f5b48a59e
(cherry picked from commit bbc88cd07f)
(cherry picked from commit b873a93b93)
2018-09-21 10:43:44 +02:00
Thomas Haller
d506400ef3 release: bump version to 1.12.5 (development) 2018-09-18 13:36:37 +02:00
Thomas Haller
2e4ca55635 release: bump version to 1.12.4 2018-09-18 13:36:37 +02:00
Thomas Haller
00e02bf0fb release: update NEWS 2018-09-18 13:36:37 +02:00
Thomas Haller
3dbd264418 connectivity: fix crash when removing easy-handle from curl callback
libcurl does not allow removing easy-handles from within a curl
callback.

That was already partly avoided for one handle alone. That is, when
a handle completed inside a libcurl callback, it would only invoke the
callback, but not yet delete it. However, that is not enough, because
from within a callback another handle can be cancelled, leading to
the removal of (the other) handle and a crash:

  ==24572==    at 0x40319AB: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==24572==    by 0x52DDAE5: Curl_close (url.c:392)
  ==24572==    by 0x52EC02C: curl_easy_cleanup (easy.c:825)
  ==24572==    by 0x5FDCD2: cb_data_free (nm-connectivity.c:215)
  ==24572==    by 0x5FF6DE: nm_connectivity_check_cancel (nm-connectivity.c:585)
  ==24572==    by 0x55F7F9: concheck_handle_complete (nm-device.c:2601)
  ==24572==    by 0x574C12: concheck_cb (nm-device.c:2725)
  ==24572==    by 0x5FD887: cb_data_invoke_callback (nm-connectivity.c:167)
  ==24572==    by 0x5FD959: easy_header_cb (nm-connectivity.c:435)
  ==24572==    by 0x52D73CB: chop_write (sendf.c:612)
  ==24572==    by 0x52D73CB: Curl_client_write (sendf.c:668)
  ==24572==    by 0x52D54ED: Curl_http_readwrite_headers (http.c:3904)
  ==24572==    by 0x52E9EA7: readwrite_data (transfer.c:548)
  ==24572==    by 0x52E9EA7: Curl_readwrite (transfer.c:1161)
  ==24572==    by 0x52F4193: multi_runsingle (multi.c:1915)
  ==24572==    by 0x52F5531: multi_socket (multi.c:2607)
  ==24572==    by 0x52F5804: curl_multi_socket_action (multi.c:2771)

Fix that, by never invoking any callbacks when we are inside a libcurl
callback. Instead, the handle is marked for completion and queued. Later,
we complete all queue handles separately.

While at it, drop the @error argument from NMConnectivityCheckCallback.
It was only used to signal cancellation. Let's instead signal that via
status NM_CONNECTIVITY_CANCELLED.

https://bugzilla.gnome.org/show_bug.cgi?id=797136
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1792745
https://bugzilla.opensuse.org/show_bug.cgi?id=1107197
https://github.com/NetworkManager/NetworkManager/pull/207

Fixes: d8a31794c8
(cherry picked from commit fa40fc6d76)
(cherry picked from commit 7f05debf99)
2018-09-17 18:23:29 +02:00
Thomas Haller
6c1cbe4d61 vpn: disconnect signal handlers from proxy in NMVpnConnection::dispose()
We cannot be sure who holds a reference to the proxy, and
who is gonna call us back after the VPN connection instance
is destroyed.

(cherry picked from commit 6ebb9091d2)
(cherry picked from commit f71f9b54a8)
2018-09-14 15:25:06 +02:00
Thomas Haller
0e633c232d vpn: fix assertion during "SecretsRequired" in unexpected state
Got this assertion:

    NetworkManager[12939]: <debug> [1536917977.4868] active-connection[0x563d8fd34540]: set state deactivated (was deactivating)
    ...
    NetworkManager[12939]: nm-openvpn[1106] <info>  openvpn[1132]: send SIGTERM
    NetworkManager[12939]: nm-openvpn[1106] <info>  wait for 1 openvpn processes to terminate...
    NetworkManager[12939]: nm-openvpn[1106] <warn>  openvpn[1132] exited with error code 1
    NetworkManager[12939]: <info>  [1536917977.5035] vpn-connection[0x563d8fd34540,2fdeaea3-975f-4325-8305-83ebca5eaa26,"my-openvpn-Red-Hat",0]: VPN plugin: requested secrets; state disconnected (9)
    NetworkManager[12939]: plugin_interactive_secrets_required: assertion 'priv->vpn_state == STATE_CONNECT || priv->vpn_state == STATE_NEED_AUTH' failed

Meaning. We should either ensure that secrets_required_cb() signal callback
is disconnected from proxy's signal, or we gracefully handle callbacks at
unexpected moments. Do the latter.

(cherry picked from commit 92344dd084)
(cherry picked from commit 011dd919fa)
2018-09-14 15:25:05 +02:00
Thomas Haller
10888abe96 cli: fix reading "vpn.secrets.*" from passwd-file
Due to a bug, we required VPN secrets to be prefixed with
"vpn.secret." instead of "vpn.secrets.". This was a change
in behavior with 1.12.0 release.

Fix it, to restore the old behavior. For backward compatibility
to the broken behavior, adjust parse_passwords() to treat accept
that as well.

https://bugzilla.redhat.com/show_bug.cgi?id=1628833
https://github.com/NetworkManager/NetworkManager/pull/201

Fixes: 0601b5d725
(cherry picked from commit 5815ae8c60)
(cherry picked from commit 6bfab6796f)
2018-09-14 15:18:29 +02:00
Beniamino Galvani
6542edef4c contrib/rpm: fix mode of ghost ifup/ifdown files
Set the execution bit on /usr/sbin/{ifup,ifdown} ghost files to match
the mode of same files installed by initscripts.

Otherwise, they will appear as changed according to rpm verify:

 .M.......  g /usr/sbin/ifdown
 .M.......  g /usr/sbin/ifup

when the alternatives mechanism is not in place.

 # ll /usr/sbin/if{up,down}
 -rwxr-xr-x. 1 root root 1651 Aug 24 06:23 /usr/sbin/ifdown
 -rwxr-xr-x. 1 root root 5010 Aug 24 06:23 /usr/sbin/ifup

https://bugzilla.redhat.com/show_bug.cgi?id=1626517
(cherry picked from commit d8a972c575)
(cherry picked from commit 63639f338f)
2018-09-14 15:14:02 +02:00
AsciiWolf
14dfdab34c po: update Czech (cz) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/14
2018-09-13 17:27:06 +02:00
Thomas Haller
6c4c12c796 wifi: fix leaking fake AP in NMDeviceWifi's act_stage1_prepare()
Fixes: 96f40dcdcd
(cherry picked from commit ef61d7909f)
(cherry picked from commit d08530ac4b)
2018-09-13 16:29:28 +02:00
Beniamino Galvani
3abddc3328 dns: dnsmasq: avoid crash when no reverse domains exist
ip_data->domains.reverse can be NULL when the device is being removed
and has no IP configuration for a short moment.

Fixes: 6409e7719c

https://bugzilla.gnome.org/show_bug.cgi?id=797022
(cherry picked from commit f0c075f050)
(cherry picked from commit 8309a7a696)
2018-09-13 15:09:08 +02:00
Thomas Haller
4a185a7483 build/meson: merge branch 'heftig/pr/12'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/12

(cherry picked from commit 08d19df209)
2018-09-12 12:57:54 +02:00
Jan Alexander Steffens (heftig)
be679e0652 meson: Fix vapi build
Apparently vapigen can't find the NetworkManager-1.0.gir belonging to
libnm-util.vapi.

(cherry picked from commit 44f14e969b)
2018-09-12 12:57:36 +02:00
Jan Alexander Steffens (heftig)
1ac1e25847 meson: Fix libnm-util build
This was broken by e01f7f2c6d.
Port the commit's changes from libnm to libnm-util.

(cherry picked from commit 4bfd0bab0d)
2018-09-12 12:57:36 +02:00