Commit Graph
48797 Commits
Author SHA1 Message Date
Luca Boccassi 4db4792a93 Merge pull request #17228 from bluca/bind_path_runtime
core: add systemctl and DBUS method to bind mount new paths without service restart
2021-01-18 21:22:57 +00:00
Zbigniew Jędrzejewski-Szmek 4ea8b443de resolved: fix use-after-free with queries hitting the cache
When dns_transaction_complete() manages to resolve a query, it invalidates the
query candidate object. It shall not be accessed afterwards.

We have the following chain of calls:
dns_query_candidate_go → dns_transaction_go → dns_transaction_prepare → dns_cache_lookup (success: 1)
                                                                      → dns_transaction_complete
After returning back to dns_query_candidate_go(), we'd attempt to continue
iteration over the list of transactions attached to the query candidate,
accessing already freed (and overwritten) memory:

(gdb) bt
0  0x00007f637297cf47 in hashmap_iterate_entry (i=0x7ffe7e15cc90, h=0x706f746b73656465) at ../src/basic/hashmap.c:703
1  _hashmap_iterate (h=0x706f746b73656465, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88,
    key=key@entry=0x0) at ../src/basic/hashmap.c:712
2  0x00007f637297d01b in set_iterate (s=<optimized out>, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88)
    at ../src/basic/hashmap.c:733
hence we crash

3  0x0000557bc99eb80f in dns_query_candidate_go (c=c@entry=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:139
...but c is not valid here in the second iteration of the loop

4  0x0000557bc99eb720 in dns_query_candidate_notify (c=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:271
c was valid here at entry...

5  0x0000557bc99efe28 in dns_transaction_complete (t=0x557bcac072f0, state=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:350
t is a valid transaction (11481 in the backtrace below)

6  0x0000557bc99f1efb in dns_transaction_process_reply (t=0x557bcac072f0, p=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:1171
7  0x0000557bc99f2d41 in on_dns_packet (s=<optimized out>, fd=<optimized out>, revents=<optimized out>,
    userdata=0x557bcac072f0) at ../src/resolve/resolved-dns-transaction.c:1223
8  0x00007f6372a25217 in source_dispatch (s=s@entry=0x557bcb162c50) at ../src/libsystemd/sd-event/sd-event.c:3181
9  0x00007f6372a254fd in sd_event_dispatch (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3620
10 0x00007f6372a267c8 in sd_event_run (e=e@entry=0x557bcb15b050, timeout=timeout@entry=18446744073709551615)
    at ../src/libsystemd/sd-event/sd-event.c:3678
11 0x00007f6372a269ef in sd_event_loop (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3700
12 0x0000557bc99ddc14 in run (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:92
13 0x0000557bc99d260a in main (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:99

xxx.name.net systemd-resolved[31705]: Got message type=method_call sender=:1.3644 destination=org.freedesktop.resolve1 path=/org/freedesktop/resolve1 interface=org.freedesktop.resolve1.Manager member=ResolveHostname cookie=2 reply_cookie=0 signature=isit error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: idn2_lookup_u8: xxx → xxx
xxx.name.net systemd-resolved[31705]: Looking up RR for xxx IN A.
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=1102 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetNameOwner cookie=1103 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1103 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Cache miss for xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> scope dns on enp42s0/*.
xxx.name.net systemd-resolved[31705]: Using feature level UDP for transaction 11481.
xxx.name.net systemd-resolved[31705]: Using DNS server 192.168.1.1 for transaction 11481.
xxx.name.net systemd-resolved[31705]: Sending query packet with id 11481 of size 35.
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1102 signature= error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Match type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.3644' successfully installed.
xxx.name.net systemd-resolved[31705]: Processing incoming packet on transaction 11481 (rcode=NXDOMAIN).
xxx.name.net systemd-resolved[31705]: Not caching negative entry without a SOA record: xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> on scope dns on enp42s0/* now complete with <rcode-failure> from network (unsigned).
xxx.name.net systemd-resolved[31705]: Positive cache hit for xxx.lan IN A
xxx.name.net systemd-resolved[31705]: Transaction 64364 for <xxx.lan IN A> on scope dns on enp42s0/* now complete with <success> from cache (unsigned).
xxx.name.net systemd-resolved[31705]: Sent message type=method_return sender=n/a destination=:1.3644 path=n/a interface=n/a member=n/a cookie=1104 reply_cookie=2 signature=a(iiay)st error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=1105 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Freeing transaction 64364.
xxx.name.net systemd[1]: systemd-resolved.service: Main process exited, code=dumped, status=11/SEGV
xxx.name.net systemd[1]: systemd-resolved.service: Failed with result 'core-dump'.

Fixes #16168, https://bugzilla.redhat.com/show_bug.cgi?id=1895937.
2021-01-18 21:45:03 +01:00
Lennart Poettering 33295214fa update TODO 2021-01-18 21:05:32 +01:00
Luca Boccassi fa7a3cd00e test: run strace with -f and copy log out 2021-01-18 17:24:05 +00:00
Luca Boccassi a9d34376e6 test: skip missing optional libraries in image install
Not all optional libraries might be available on developers machines,
so log and skip.
Also some pkg-config files are broken (eg: tss2 on Debian Stable) so
skip if the required variables are missing, and improve logs.
2021-01-18 17:24:05 +00:00
Luca Boccassi 5e8deb94c6 core: add DBUS method to bind mount new nodes without service restart
Allow to setup new bind mounts for a service at runtime (via either
DBUS or a new 'systemctl bind' verb) with a new helper that forks into
the unit's mount namespace.
Add a new integration test to cover this.

Useful for zero-downtime addition to services that are running inside
mount namespaces, especially when using RootImage/RootDirectory.

If a service runs with a read-only root, a tmpfs is added on /run
to ensure we can create the airlock directory for incoming mounts
under /run/host/incoming.
2021-01-18 17:24:05 +00:00
Luca Boccassi 94293d65cd MountAPIVFS: always mount a tmpfs on /run
We need a writable /run for most operations, but in case a read-only
RootImage (or similar) is used, by default there's no additional
tmpfs mount on /run. Change this behaviour and document it.
2021-01-18 17:24:05 +00:00
Luca Boccassi f7c18d3de8 machine: use file descriptor when chasing bind mount sources
Allows to always operate on pinned inodes, rather than paths, so that
races are less likely
2021-01-18 17:24:05 +00:00
Luca Boccassi 98f654fdea machine: enter target PID namespace when adding a live mount
machinectl fails since 21935150a0 as it's now
mounting onto a file descriptor in a target namespace, without joining the
target's PID namespace.
Note that it's not enough to setns CLONE_NEWPID, but a double-fork is required
as well, as implemented by namespace_fork().

Add a test case to TEST-13-NSPAWN to cover this use case.
2021-01-18 17:24:05 +00:00
Luca Boccassi 2338a175fd shared/mount-util: use namespace_fork utils 2021-01-18 17:23:46 +00:00
Luca Boccassi 724e689715 machine: adjust error message to use 'normalized' instead of ../ 2021-01-18 17:23:12 +00:00
Luca Boccassi 6af52c3a45 machine/basic: factor out helper function to add airlocked mount to namespace 2021-01-18 17:23:11 +00:00
moson-mo 2a613b34cc hwdb: Add Logitech MX 518 Legendary mouse
Add Logitech MX 518 Legendary model to hwdb.
2021-01-18 16:49:30 +01:00
Zbigniew Jędrzejewski-Szmek 9dffdb4e3c Merge pull request #18289 from yuwata/core-load-fragment-cleanups
pid1: several cleanups for conf parsers
2021-01-18 16:48:44 +01:00
Yu Watanabe aac6673f02 network: address-pool: also check conflicts with foreign addresses
Fixes CI issue found in
https://github.com/systemd/systemd-centos-ci/pull/334.
2021-01-17 23:23:08 +00:00
Jonathan McDowell 0da7f9e589 hwdb: Add NEWYES 10" LCD writing tablet (#18274) 2021-01-18 08:39:07 +10:00
Yu Watanabe 2400743e1f core: add logs when credential value is duplicated 2021-01-18 01:32:49 +09:00
Yu Watanabe 8c6493e59e core: make config_parse_documentation() explicitly return 0 on success 2021-01-18 01:27:14 +09:00
Yu Watanabe 16eb0c4ad0 core: add missing log_oom() 2021-01-18 01:25:05 +09:00
Yu Watanabe ca9169f47f core: do not fail when an invalid cpu affinity is specified 2021-01-18 01:22:48 +09:00
Yu Watanabe 22ede2c1dc Merge pull request #18286 from ssahani/net-1
tree-wide: more use of hashmap_ensure_put() and TAKE_PTR()
2021-01-18 01:18:17 +09:00
Lennart Poettering 7ed7d3e6fd systemctl: use right type 'size_t' for counting memory
Follow-up for e363b0e4fc

(Mostly a theoretical fix. On 64bit systems unsigned is 32bit, and we
had more than 2^32 units thing would fall apart here.)
2021-01-18 01:17:27 +09:00
Susant Sahani 5a3e1cb918 network: tc use TAKE_PTR 2021-01-17 23:26:14 +09:00
Susant Sahani a4aba097ad udevadm-monitor: use TAKE_PTR 2021-01-17 14:25:21 +01:00
Susant Sahani 39f930c215 udevadm-monitor: Use hashmap_ensure_put 2021-01-17 14:25:18 +01:00
Susant Sahani a3b42af5b6 udev-rules: Use hashmap_ensure_put 2021-01-17 14:25:15 +01:00
Susant Sahani 15c69d0700 resolved-dnssd: Use TAKE_PTR 2021-01-17 14:25:10 +01:00
Susant Sahani 276abbeebc resolved-dnssd: Use hashmap_ensure_put 2021-01-17 14:25:07 +01:00
Susant Sahani daced7483b resolved-dns-packet: Use TAKE_PTR 2021-01-17 14:25:05 +01:00
Susant Sahani 3004fcd0b8 resolved-dns-packet: Use hashmap_ensure_put 2021-01-17 14:24:59 +01:00
Susant Sahani 71fb97c7c4 resolved-bus: Use hashmap_ensure_put 2021-01-17 14:24:50 +01:00
Susant Sahani 4bc2516856 journal-remote: use hashmap_ensure_put 2021-01-17 14:24:44 +01:00
Susant Sahani f85f5f0dc8 core: load fragment - use hashmap_ensure_put 2021-01-17 14:24:41 +01:00
Susant Sahani 53dba3ef07 core: job - use hashmap_ensure_put 2021-01-17 14:24:36 +01:00
Yu Watanabe 25351bc557 basic: drop unused module
Follow-up for 35b42e5600.
2021-01-17 11:48:05 +00:00
Yu Watanabe 6e75df0866 Merge pull request #18284 from ssahani/net-7
Tree wide tighten variable scope used in loop
2021-01-17 20:08:59 +09:00
Susant Sahani ebffea2a25 network: Use ordered_hashmap_ensure_put (#18233) 2021-01-17 20:07:02 +09:00
Yu Watanabe f9ead1a2f4 Merge pull request #18230 from ssahani/macvlan-bcqueuelen
network: macvlan - add support to configure rx queue for broadcast / multicast
2021-01-17 20:05:22 +09:00
Lennart Poettering 3dc536e0c5 Merge pull request #17576 from gportay/veritysetup-add-support-for-dm-verity-flags
veritysetup: add support for veritytab
2021-01-17 11:18:25 +01:00
Susant Sahani cf55fe4a4c core: dbus - use hashmap_ensure_put 2021-01-17 09:49:14 +01:00
Susant Sahani dca0a4e131 network: macvlan - add support to configure rx queue for broadcast/multicast 2021-01-17 08:39:28 +01:00
Susant Sahani f6a0cfa5a5 journal: journal-file - tighten variable scope used in loop 2021-01-17 08:24:12 +01:00
Susant Sahani d007c58317 machine: machined-dbus - tighten variable scope used in loop 2021-01-17 08:24:12 +01:00
Yu Watanabe 38f3e0a58d tree-wide: fix typo 2021-01-17 16:20:27 +09:00
Yu Watanabe 16ed53658a Merge pull request #18243 from ssahani/ensure-put-use
tree-wide: introduce hashmap_ensure_put() and use it
2021-01-17 15:39:41 +09:00
Yu Watanabe 95dd454edc Merge pull request #18261 from ssahani/net2
network: modernize routing policy rule and add 0 validation where needed
2021-01-17 15:39:01 +09:00
Susant Sahani cda7fc8db3 network: tighten variable scope used in loop (#18277) 2021-01-17 15:38:33 +09:00
Adam Nielsen e64652f70c man: clarify what network scopes are 2021-01-17 12:47:08 +09:00
Susant Sahani a307a7dd38 network: nexthop - use hashmap_ensure_put 2021-01-16 23:10:32 +01:00
Susant Sahani dcd46cc42d network: use hashmap_ensure_put 2021-01-16 23:10:18 +01:00