1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-27 01:57:35 +03:00

69462 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
e6c5386dee core: turn on higher optimization level in seccomp
This mirrors what d75615f398a0fbf986cf03924462863ca6ee2f9f did for nspawn.

It isn't really a fatal failure if we can't set that, so ignore it in libseccomp
cannot set the attribute.

 line  OP   JT   JF   K
=================================
 0000: 0x20 0x00 0x00 0x00000004   ld  $data[4]
 0001: 0x15 0x00 0xb7 0x40000003   jeq 1073741827 true:0002 false:0185
 0002: 0x20 0x00 0x00 0x00000000   ld  $data[0]
 0003: 0x15 0xb5 0x00 0x00000000   jeq 0    true:0185 false:0004
 0004: 0x15 0xb4 0x00 0x00000001   jeq 1    true:0185 false:0005
 0005: 0x15 0xb3 0x00 0x00000002   jeq 2    true:0185 false:0006
 0006: 0x15 0xb2 0x00 0x00000003   jeq 3    true:0185 false:0007
 0007: 0x15 0xb1 0x00 0x00000004   jeq 4    true:0185 false:0008
 0008: 0x15 0xb0 0x00 0x00000005   jeq 5    true:0185 false:0009
 0009: 0x15 0xaf 0x00 0x00000006   jeq 6    true:0185 false:0010
 ...
 0438: 0x15 0x03 0x00 0x000001be   jeq 446  true:0442 false:0439
 0439: 0x15 0x02 0x00 0x000001bf   jeq 447  true:0442 false:0440
 0440: 0x15 0x01 0x00 0x000001c0   jeq 448  true:0442 false:0441
 0441: 0x06 0x00 0x00 0x00050026   ret ERRNO(38)
 0442: 0x06 0x00 0x00 0x7fff0000   ret ALLOW

 line  OP   JT   JF   K
=================================
 0000: 0x20 0x00 0x00 0x00000004   ld  $data[4]
 0001: 0x15 0x00 0x27 0x40000003   jeq 1073741827 true:0002 false:0041
 0002: 0x20 0x00 0x00 0x00000000   ld  $data[0]
 0003: 0x25 0x01 0x00 0x000000b5   jgt 181  true:0005 false:0004
 0004: 0x05 0x00 0x00 0x00000143   jmp 0328
 0005: 0x25 0x00 0xa1 0x00000139   jgt 313  true:0006 false:0167
 0006: 0x25 0x00 0x51 0x00000179   jgt 377  true:0007 false:0088
 0007: 0x25 0x00 0x29 0x000001a0   jgt 416  true:0008 false:0049
 0008: 0x25 0x00 0x13 0x000001b0   jgt 432  true:0009 false:0028
 0009: 0x25 0x00 0x09 0x000001b8   jgt 440  true:0010 false:0019
 ...
 0551: 0x15 0x03 0x00 0x00000002   jeq 2    true:0555 false:0552
 0552: 0x15 0x02 0x01 0x00000001   jeq 1    true:0555 false:0554
 0553: 0x15 0x01 0x00 0x00000000   jeq 0    true:0555 false:0554
 0554: 0x06 0x00 0x00 0x00050026   ret ERRNO(38)
 0555: 0x06 0x00 0x00 0x7fff0000   ret ALLOW

The program is longer but hopefully faster because of the binary search.
2023-12-02 01:21:53 +01:00
Zbigniew Jędrzejewski-Szmek
309a4212cf shared/seccomp-util: use the same error message for the same condition
We were calling seccomp_syscall_resolve_name three times and using a
slightly different error message in each of the cases.
2023-12-02 01:21:53 +01:00
Zbigniew Jędrzejewski-Szmek
2331c02d06 core: when applying syscall filters, use ENOSYS for unknown calls
glibc starting using fchmodat2 to implement fchmod with flags [1], but
current version of libseccomp does not support fchmodat2 [2]. This is
causing problems with programs sandboxed by systemd. libseccomp needs to know
a syscall to be able to set any kind of filter for it, so for syscalls unknown
by libseccomp we would always do the default action, i.e. either return the
errno set by SystemCallErrorNumber or send a fatal signal. For glibc to ignore
the unknown syscall and gracefully fall back to the older implementation,
we need to return ENOSYS. In particular, tar now fails with the default
SystemCallFilter="@system-service" sandbox [3].

This is of course a wider problem: any time the kernel gains new syscalls,
before libseccomp and systemd have caught up, we'd behave incorrectly. Let's
do the same as we already were doing in nspawn since
3573e032f26724949e86626eace058d006b8bf70, and do the "default action" only
for syscalls which are known by us and libseccomp, and return ENOSYS for
anything else. This means that users can start using a sandbox with the new
syscalls only after libseccomp and systemd have been updated, but before that
happens they behaviour that is backwards-compatible.

[1] 65341f7bbe
[2] https://github.com/seccomp/libseccomp/issues/406
[2] https://github.com/systemd/systemd/issues/30250

Fixes https://github.com/systemd/systemd/issues/30250.

In seccomp_restrict_sxid() there's a chunk conditionalized with
'#if defined(__SNR_fchmodat2)'. We need to kep that because seccomp_restrict_sxid()
seccomp_restrict_suid_sgid() uses SCMP_ACT_ALLOW as the default action.
2023-12-02 01:20:28 +01:00
Mike Yuan
a8aed6a9b6 core/cgroup: for non-cached attrs, don't return ENODATA blindly
Follow-up for f17b07f4d72238da95312920dcc2ad076568cba3

Hope I won't break this thing again...
2023-12-02 00:13:46 +00:00
Zbigniew Jędrzejewski-Szmek
26747824fd
Merge pull request #30294 from bluca/news
hwdb and NEWS updates
2023-12-02 01:08:45 +01:00
Neil Wilson
627966ab01 systemd-homed.service.in: add quotactl to SystemCallFilter
Standard directories make a call to the quotactl system call to enforce disk size limits.

Fixes #30287
2023-12-01 22:43:31 +00:00
Luca Boccassi
8163ef5712 hwdb: update 2023-12-01 22:07:08 +00:00
Luca Boccassi
9a848052e4 NEWS: update contributors list 2023-12-01 22:05:08 +00:00
Zbigniew Jędrzejewski-Szmek
ac116f8c27
Merge pull request #30268 from yuwata/network-fix-too-many-waiting-replies
network: fix issue caused by too many waiting replies
2023-12-01 19:54:18 +01:00
Zbigniew Jędrzejewski-Szmek
86a1ee93f3 core: fix comment 2023-12-01 19:40:26 +01:00
Дамјан Георгиевски
ef87c84e81 fix: prefix of dmesg pstore files
A change in the kernel[1] renamed the prefix of the pstore files from
`dmesg-efi-` to `dmesg-efi_pstore-`.

[1]
https://git.kernel.org/linus/893c5f1de620
2023-12-01 17:34:43 +00:00
Neil Wilson
145dc0a0f6 homework-quota.c: correct error message in home_update_quota_btrfs
Fixes #30286
2023-12-01 16:41:29 +00:00
dependabot[bot]
ba47598aef build(deps): bump meson from 1.2.3 to 1.3.0 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 1.2.3 to 1.3.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.2.3...1.3.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 14:49:19 +00:00
dependabot[bot]
d50a357dce build(deps): bump redhat-plumbers-in-action/differential-shellcheck
Bumps [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/docs/CHANGELOG.md)
- [Commits](aa647ec446...91e2582e40)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 14:48:48 +00:00
dependabot[bot]
135c249147 build(deps): bump redhat-plumbers-in-action/devel-freezer
Bumps [redhat-plumbers-in-action/devel-freezer](https://github.com/redhat-plumbers-in-action/devel-freezer) from 1.0.7 to 1.0.8.
- [Release notes](https://github.com/redhat-plumbers-in-action/devel-freezer/releases)
- [Commits](13b6551f19...67aec4a153)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/devel-freezer
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 14:48:14 +00:00
dependabot[bot]
e8bad6615d build(deps): bump actions/github-script from 6.4.1 to 7.0.1
Bumps [actions/github-script](https://github.com/actions/github-script) from 6.4.1 to 7.0.1.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](d7906e4ad0...60a0d83039)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 14:47:23 +00:00
dependabot[bot]
50613206f2 build(deps): bump github/codeql-action from 2.21.9 to 2.22.8
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.9 to 2.22.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ddccb87388...407ffafae6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 14:46:46 +00:00
Franck Bui
2f26c21171 vconsole-setup: use a consistent log level when setfont fails with EX_OSERR
Since we accept that setfont(8) can fail with EX_OSERR and we dont treat it as
an error, dont log this failure at LOG_ERR.

Before:
-------
/usr/bin/setfont failed with exit status 71.           [LOG_ERR]
Setting fonts failed with a "system error", ignoring.  [LOG_NOTICE]

After:
-----
/usr/bin/setfont failed with a "system error" (EX_OSERR), ignoring.   [LOG_NOTICE]
Setting source virtual console failed, ignoring remaining ones        [LOG_NOTICE]

Follow-up for 93c9a9d235e2304500c490b4868534385f925c76
2023-12-01 13:53:20 +00:00
Zbigniew Jędrzejewski-Szmek
24baee3370 ukify: avoid deprecated datetime call
DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for
                    removal in a future version. Use timezone-aware objects to
                    represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

The difference between the two is that .now(datetime.UTC) returns an object with
a timezone attached, "the numbers" are the same.

>>> datetime.datetime.utcnow(), datetime.datetime.now(datetime.UTC)
(datetime.datetime(2023, 12, 1, 9, 37, 53, 891669),
 datetime.datetime(2023, 12, 1, 9, 37, 53, 891688, tzinfo=datetime.timezone.utc))

This value is fed to cryptography's x509.CertificateBuilder object, so as long
as it can accept a datetime object with tzinfo, the result should be identical.
2023-12-01 12:44:08 +00:00
Luca Boccassi
f4a35f2ad9 core: do not drop CAP_SETUID if it is in AmbientCapabilities=
Follow-up for 24832d10b604848cf46624bb439c7fac27f3ce3f
2023-12-01 10:48:14 +00:00
Yu Watanabe
4e6a35e2b2 network: do not send too many netlink messages in a single event
Fixes #26743.
2023-12-01 19:45:12 +09:00
Yu Watanabe
b3a4f4f06d firewall-util: introduce fw_ctx_get_reply_callback_count() 2023-12-01 19:45:02 +09:00
Yu Watanabe
4256379d99 sd-netlink: introduce netlink_get_reply_callback_count() 2023-12-01 19:44:47 +09:00
Daan De Meyer
3f3ec0b8e8
Merge pull request #30211 from yuwata/sd-journal-generic-array-bisect-fix
sd-journal: fix generic_array_bisect()
2023-12-01 11:43:04 +01:00
Zbigniew Jędrzejewski-Szmek
34c2fc8505 ukify: simplify import 2023-12-01 10:30:16 +01:00
Zbigniew Jędrzejewski-Szmek
2060509d12 kernel-install/60-ukify: use exec() instead of runpy
As suggested by Daniele Nicolodi.

Also drop left-over debug line.
2023-12-01 10:30:16 +01:00
Zbigniew Jędrzejewski-Szmek
ef126bbe89 man/ukify: link to competing tools
Right now each of the three invocations yields a part of the picture.
Let's make it easier for users to discover the right tools.
2023-12-01 10:29:39 +01:00
Yu Watanabe
4db7cb37bd sd-netlink: change error code of the case that too many replies waiting
ERANGE should be used when setting or parsing a number.
2023-12-01 14:37:05 +09:00
Takashi Sakamoto
26c9773ab9 hwdb: ieee1394-unit-function: arrangement for Sony DVMC-DA1
A commit 6a42bdb37e39 ("hwdb: ieee1394-unit-function: add Sony
DVMC-DA1") is based on kernel feature unreleased yet (furthermore, not
merged yet). The original intension of new entry is to configure permission
of special file for FireWire character device, so this commit changes the
entry so that it can covers the issued case in existent version of Linux
kernel as out best effort.

When the new version of Linux kernel is released with the new feature,
then following commits would fulfill the hwdb with vendor and model names.
2023-12-01 14:00:56 +09:00
Yu Watanabe
f3714bd5a2 test: add tests for generic_array_bisect() 2023-12-01 10:08:49 +09:00
Yu Watanabe
1f21bc5811 test: make append_number() optionally return offset of the entry object
Preparation for later commits.
2023-12-01 10:08:49 +09:00
Yu Watanabe
76b7a346ed test: split out finalization task 2023-12-01 10:08:46 +09:00
Yu Watanabe
a93be359ae sd-journal: fix corrupted journal handling of generic_array_bisect()
Let's consider the following case:
- the direction is down,
- no cached entry,
- the array has 5 entry objects,
- the function test_object() reutns TEST_LEFT for the 1st object,
- the 2nd, 3rd, and 4th objects are broken, so generic_array_bisect_step()
  returns TEST_RIGHT for the object.

Then, previously, generic_array_bisect_step() updated the values like the following:
  0th: (m = 5, left = 0, right = 4, i = 4) -> (m = 4, left = 0, right = 3, RIGHT)
  1st: (m = 4, left = 0, right = 3, i = 1) -> (m = 4, left = 2, right = 3, LEFT)
  2nd: (m = 4, left = 2, right = 3, i = 2) -> (m = 2, left = 2, right = 1, RIGHT) <- ouch!!
So, assert(left < right) in generic_array_bisect() was triggered.
See issue #30210.

In such situation, there is no matching entry in the array. By returning
TEST_GOTO_PREVIOUS, generic_array_bisect() handles the result so.

Fixes a bug introduced by ab8f553d1e09088fb1f633e014299e7bf6c30c9e.

Fixes #30210.
2023-12-01 09:56:10 +09:00
Yu Watanabe
5dca908a9a sd-journal: ignore failure in testing cached corrupted entry
Let's consider the case that the 1st entry in an array is broken, but
n-th entry is valid. Then, if generic_array_get() is called to read
n-th object, the offset of the broken entry is cached by the function.
If generic_array_bisect() is followed, even if the matching entry is
valid, it always fail with -EBADMSG or friends, as the function test the
cached entry at the beginnning. Let's ignore the failure in testing the
cached entry.
2023-12-01 09:27:38 +09:00
Joerg Behrmann
d4506301f9 man: document how to properly use a target as the Unit= of a timer 2023-11-30 17:14:31 +00:00
Mike Yuan
5a5fdfe3ac
core/exec-invoke: prevent potential double-close of exec_fd
If exec_fd is closed in add_shifted_fd() by close_and_replace(),
but something goes wrong later, we may close exec_fd twice
in exec_params_shallow_clear().
2023-12-01 00:14:37 +08:00
Mike Yuan
f38cbaff63
core/exec-invoke: remove redundant fd_cloexec() call 2023-12-01 00:14:37 +08:00
Mike Yuan
a2467ea894
fdset: set all collected fds to CLOEXEC in fdset_new_fill() 2023-12-01 00:14:37 +08:00
Mike Yuan
d8da25b5d9
core/exec-invoke: rename flags_fds to flag_fds 2023-12-01 00:07:04 +08:00
Mike Yuan
a3e8e15480
core/execute-serialize: FOREACH_ARRAY at one more place 2023-12-01 00:07:04 +08:00
Daan De Meyer
ef90e8f9db Make sure we close bpf outer map fd in systemd-executor
Not doing so leaks it into the child service and causes selinux
denials.
2023-12-01 00:06:24 +08:00
Lennart Poettering
dde54b8a85 journalctl: add short option "-i" for "--file="
I see myself frequently typing in "journalctl --file=…". That's a lot to
type. Let's add a short switch too. Unfortunately, "-f" and "-F" are
already taken, hence let's pick "-i".
2023-11-30 16:21:00 +01:00
Lennart Poettering
12f2576854 man: add '=' suffix to journalctl switches that take parameter
As per coding style recommendations.
2023-11-30 16:21:00 +01:00
Yu Watanabe
b3b33fa3aa contrib: include co-authors to the contributor list of NEWS
Closes #30261.
2023-11-30 09:57:49 +00:00
Mike Yuan
79bad078bb core/executor: avoid double closing serialization fd
Before this commit, between fdopen() (in parse_argv()) and fdset_remove(),
the serialization fd is owned by both arg_serialization FILE stream and fdset.
Therefore, if something wrong happens between the two calls, or if --deserialize=
is specified more than once, we end up closing the serialization fd twice.
Normally this doesn't matter much, but I still think it's better to fix this.

Let's call fdset_new_fill() after parsing serialization fd hence.
We set the fd to CLOEXEC in parse_argv(), so it will be filtered
when the fdset is created.

While at it, also move fdset_new_fill() under the second log_open(), so
that we always log to the log target specified in arguments.
2023-11-30 09:56:59 +00:00
Yu Watanabe
2292d377a2 sd-journal: fix typo in function name 2023-11-30 15:22:24 +09:00
Daan De Meyer
5c314412f0 core: Always call log_open() in systemd-executor
log_setup() will open the console in systemd-executor because it's
not pid 1 and it's not connected to the journal. So if the log target
is later changed to kmsg, we have to reopen the log.

But since log_open() won't open the same log twice, let's just call it
unconditionally since it will be a noop if we try to reopen the same log.

This makes sure that systemd-executor will log to the log target passed
via --log-target= after parsing arguments.
2023-11-29 22:56:50 +00:00
Frantisek Sumsal
ee77e0b2de test: ignore gcov errors with RestrictFileSystems=
The errors are valid, since the file system is indeed not writable, but
we don't care about the missing coverage data in this case.

Follow-up to 4a43c2b3a1.
2023-11-29 22:50:37 +00:00
Daan De Meyer
c52f6cdcb8 network: Add missing comma 2023-11-29 21:24:17 +00:00
Luca Boccassi
edb37ee15c Revert "mkosi ci: enable jammy-proposed"
libsolv has migrated to jammy-updates, so we can disable the
proposed-updates repository again.

This reverts commit 48bfc6791dca3b130befe419fc07f15f515b291c.
2023-11-29 17:30:54 +01:00