Skip to content

Systemd partition fix#490

Closed
Devender-117 wants to merge 703 commits intosystemd:v255-stablefrom
Devender-117:systemd_partition_fix
Closed

Systemd partition fix#490
Devender-117 wants to merge 703 commits intosystemd:v255-stablefrom
Devender-117:systemd_partition_fix

Conversation

@Devender-117
Copy link
Copy Markdown

No description provided.

poettering and others added 30 commits November 4, 2022 13:02
(cherry picked from commit 3840b14)
(cherry picked from commit 8320387)
…not be used.

(cherry picked from commit 8c88895)
(cherry picked from commit 724d521)
When invoked as the coredump handler by the kernel, systemd-coredump's
stdout and stderr streams are closed. This is dangerous as this means
the fd's can get reallocated, leading to hard to debug errors such as
log messages ending up being appended to a compressed coredump file.

To avoid such issues in the future, let's bind stdout/stderr to
/dev/null so the file descriptors can't get used for anything else.

(cherry picked from commit 1f9d2a8)
(cherry picked from commit fba50bc)
Inspired by systemd/systemd#24024 this is
another user mode helper, where this might be an issue. hence let's
rather be safe than sorry, and also connect stdin/stdout/stderr
explicitly with /dev/null.

(cherry picked from commit 50492ce)
(cherry picked from commit 6894877)
Ambient capabilities should not be passed implicitly to user
services. Dropping them does not affect the permitted and effective sets
which are important for the manager itself to operate.

(cherry picked from commit 963b6b9)
(cherry picked from commit c88309d)
…tion (#24030)

(cherry picked from commit 69a7d10)
(cherry picked from commit 7632ff4)
Whitespace inside of the <varname> field was propagated to the displayed form,
causing strange indentation.

(cherry picked from commit 9cfc294)
(cherry picked from commit b7c5530)
since in this specific case (r == 0) `errno` is irrelevant and most likely
set to zero, leading up to a confusing message:

```
[  120.595085] H systemd[1]: session-5.scope: No PIDs left to attach to the scope's control group, refusing: Success
[  120.595144] H systemd[1]: session-5.scope: Failed with result 'resources'.
```

(cherry picked from commit e99b928)
(cherry picked from commit 5c822e3)
Just a minor cleanup to fix unparseable wording

(cherry picked from commit 729d2df)
(cherry picked from commit 110d49d)
Fixes: #22706
(cherry picked from commit cbc2593)
(cherry picked from commit 8e466d9)
(cherry picked from commit 5f2b4f9)
(cherry picked from commit 9f3ed4f)
For the system manager, /run/systemd/private is publicly accessible, because
/run/systemd is 0755, and /run/systemd/private is 0777. For the user manager,
/run/user/<uid> is 0700, and /run/user/<uid>/systemd/private is 0777. This
does not directly cause any security issue because we check the sender in
bus_check_peercred (ucred.uid != 0 && ucred.uid != geteuid()).

But it makes sense to limit access to the socket to avoid wasting time in PID1.
Somebody could send messages there that'd we'd reject anyway. It also makes
things more explicit.

(cherry picked from commit df1cbd1)
(cherry picked from commit dc3333b)
The variable `inst` was set to NULL by TAKE_PTR().

This fixes the following log message:
```
systemd[1]: Unit getty@tty2.service has alias (null).
```

(cherry picked from commit 7c35b78)
(cherry picked from commit 9ac0ad8)
…_attr conflict with glibc 2.36

(cherry picked from commit 3657d3a)
(cherry picked from commit 8fe0c12)
(cherry picked from commit 6e40ed5)
(cherry picked from commit a9dd0f6)
We ignore xattr copy failures on all other cases, and we should do so
here too.

Fixes: #24106
(cherry picked from commit d3efe29)
(cherry picked from commit 200cbc2)
Fixes #24114.

(cherry picked from commit 5202362)
(cherry picked from commit 834632a)
Fixes #24117.

(cherry picked from commit 0a58cd0)
(cherry picked from commit 739d713)
This reverts commit e4de58c.

If mkdir() fails and the path does exist, then the later mount
command fails anyway. Hence, it is not necessary to fail here.

Fixes #24120.

(cherry picked from commit e5e6b7c)
(cherry picked from commit b1e494d)
(cherry picked from commit 574febd)
(cherry picked from commit 9f8b7ee)
When running on images you don't want to modify the /tmp
directory even if it's writable, and often it will just
be read-only. Set PrivateTmp=yes.

Fixes systemd/systemd#23592

(cherry picked from commit f2d26cd)
(cherry picked from commit 6e111d2)
Fixes #23843 and #23873.

(cherry picked from commit d50a58e)
(cherry picked from commit e832a27)
(cherry picked from commit 4b2ceb8)
(cherry picked from commit a1edebf)
Also, this makes mDNS regular queries sent without delay (except for
one caused by the default accuracy of sd-event).

Note, RFC 6762 Section 5.2 is about continuous mDNS query, which is not
implemented yet.

(cherry picked from commit 765647b)
(cherry picked from commit 41810cb)
Fixes the following assertion:
---
Assertion 'r > 0' failed at src/resolve/resolved-mdns.c:180, function mdns_do_tiebreak(). Aborting.
---

(cherry picked from commit f2605af)
(cherry picked from commit 0070302)
(cherry picked from commit 055acd4)
(cherry picked from commit b61a61e)
…rds in the

Known-Answer list whose remaining TTL is less than half of their original TTL

(cherry picked from commit f941c12)
(cherry picked from commit ef6c379)
(cherry picked from commit 01d9fbc)
Kubevirt is currently technically based on KVM (but not xen yet[1]).
The systemd-detect-virt command, used to differentiate the current
virtualization environment, works fine on x86 relying on CPUID, while
fails to get the correct value (none instead of kvm) on aarch64.

Let's fix this by adding a new 'vendor[KubeVirt] = kvm' classification
considering the sys_vendor is always KubeVirt.

[1] https://groups.google.com/g/kubevirt-dev/c/C6cUgzTOsVg

Signed-off-by: Fei Li <lifei.shirley@bytedance.com>
(cherry picked from commit c15d1ac)
(cherry picked from commit e7d635f)
by default, gcrypt defaults to an userspace RNG, this is
the wrong thing (tm) to do on linux.

Switch to the SYSTEM rng instead.

(cherry picked from commit 80f9673)
(cherry picked from commit ca0ed3a)
ml- and others added 27 commits February 16, 2023 15:02
(cherry picked from commit f39d7d0)
(cherry picked from commit bfaf023)
(cherry picked from commit 067b5b7)
Timestampfs from sysfs files can be zero in which case ERANGE will
be returned so let's make sure we catch that.

(cherry picked from commit 0da4cc9)
(cherry picked from commit ef96e60)
(cherry picked from commit 18a2aaf)
Follow-up for 49bb7fe.

Fixes an issue reported at
systemd/systemd#26270 (comment).

(cherry picked from commit 9361a71)
(cherry picked from commit e91a304)
(cherry picked from commit f32581a)
If UDP is blocked on the system (e.g. by iptables or BPF), the kernel will
return EPERM on some or all of the system calls (connect, sendmsg, etc.).
In this case, try to fall back to TCP, which hopefully will not be blocked.

(cherry picked from commit 3dd6336)
(cherry picked from commit a88e35b)
(cherry picked from commit 58cbb7a)
(cherry picked from commit 5f6a369)
Follow-up for 29a24ab.

(cherry picked from commit dbfc096)
(cherry picked from commit a3177cb)
(cherry picked from commit 6e8d76f)
(cherry picked from commit 4647e86)
… is off

(cherry picked from commit 6aa2c55)
(cherry picked from commit 01b90e1)
(cherry picked from commit 7c9b9c8)
(cherry picked from commit 292debc)
The TPM code expects a description unless the PCR index indicates that
no measurements have to take place. The assert was preempting this
check from happening.

Fixes: #26428
(cherry picked from commit f92428e)
(cherry picked from commit cd5de28)
(cherry picked from commit ac3d892)
(cherry picked from commit 2cf90e1)
Previously, we skip the entries before arg_lines
unconditionally, which doesn't behave correctly
when used with --grep. After this commit, when
a pattern is specified, we don't skip the entries
early, but rely on the count of the lines shown
to tell us when to stop. To achieve that we would
have to search backwards instead.

Fixes #25147

(cherry picked from commit db46919)
(cherry picked from commit c4cdbb9)
(cherry picked from commit e988919)
(cherry picked from commit a90a456)
This is useful for debugging issues like #26474.

(cherry picked from commit b9fadf2)
(cherry picked from commit ba1cb41)
(cherry picked from commit 892fe5d)
(cherry picked from commit bfbd75c)
r and R take globs, so let's name the argument appropriately in the tl;dr listing.

Also, use 'clean-up' in the file name where it represents the verb "clean up",
and other minor spelling adjustments.

(cherry picked from commit 164297c)
(cherry picked from commit aac6921)
(cherry picked from commit e72f167)
(cherry picked from commit 88302d7)
(cherry picked from commit 464ec1d)
(cherry picked from commit eae11e3)
(cherry picked from commit 8af5e94)
(cherry picked from commit 73fd236)
An rpminspect test in Fedora/RHEL is flagging our stub files as having an
executable stack. The check is correct:

$ readelf --wide --program-headers build/src/boot/efi/linuxx64.elf.stub | rg -i stack
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x10

It seems to be just an omission in the linker script… None of the objects that
are linked into the stub are marked as requiring an executable stack:

$ readelf --wide --sections build/src/boot/efi/*.c.o \
  /usr/lib/gnuefi/x64/libgnuefi.a \
  /usr/lib/gnuefi/x64/libefi.a \
  /usr/lib/gcc/x86_64-redhat-linux/12/libgcc.a \
  | rg '.note.GNU-stack.*X'
(nothing)

On aarch64 we end up with a nonexecutable stack, but on ia32 and x64 we get one,
so this might be just a matter of defaults in the linker. It doesn't matter
greatly, but let's mark the stack as non-executable to avoid the warning.

Note: '-Wl,-z' is not needed, things work with just '-z'.
(cherry picked from commit 1eca770)
(cherry picked from commit 44c2ff5)
(cherry picked from commit 4f4344e)
(cherry picked from commit c68ae31)
I'm not sure what "suffix" was meant by this comment, but the file has the usual suffix.
The file was added with the current name back in c4708f1.
Maybe an earlier version of the patch did something different.

(cherry picked from commit 9c71885)
(cherry picked from commit d9abd8b)
(cherry picked from commit 2ca2390)
(cherry picked from commit 3339b23)
Only service and scope units have RuntimeMaxUSec bus property.
To suppress the "Until:" field for other unit types, the entry must be
initialized with USEC_INFINITY.

Fixes #26473.

(cherry picked from commit b59052b)
(cherry picked from commit 2bfb07b)
(cherry picked from commit 028cee0)
(cherry picked from commit e385eb5)
If the boot ID cannot be obtained, let's first fallback to the machine
ID, and if still cannot, then let's use 0.
Otherwise, no timer event source cannot be triggered.

Fixes #26549.

(cherry picked from commit 6d2326e)
(cherry picked from commit 58c821a)
(cherry picked from commit 7897619)
(cherry picked from commit ac04d80)
Follow-up for 6d2326e.

(cherry picked from commit 1912f79)
(cherry picked from commit a719c2e)
(cherry picked from commit dd6561f)
(cherry picked from commit 8be4af4)
In config_parse_socket_listen(), we have checked the path is absolute,
however we have not in the dbus method.

(cherry picked from commit 4de2b47)
(cherry picked from commit e093acd)
(cherry picked from commit 22d1f01)
(cherry picked from commit 1a4634b)
(cherry picked from commit aff1317)
(cherry picked from commit dc98d58)
(cherry picked from commit 7d3af1f)
(cherry picked from commit 0917430)
If the default target is masked, `systemctl get-default` prints

  Failed to get default target: Operation not possible due to RF-kill

That's a bit too cryptic, so let's make it clear what's actually
happening.

Fixes #26589.

(cherry picked from commit 7c78a19)
(cherry picked from commit 144ac49)
(cherry picked from commit 30eae23)
(cherry picked from commit 407726d)
We checked ERRNO_IS_NOT_SUPPORTED on a possible positive non-error code,
which isn't right.

Fix that. Also add caching, since we are about to call this more often.

(cherry picked from commit 90ec8eb)
(cherry picked from commit 5ee19fd)
(cherry picked from commit 8e62340)
(cherry picked from commit cb4f512)
Resolves: #26629
(cherry picked from commit 8c7a6c7)
(cherry picked from commit 1a22006)
(cherry picked from commit 48911dc)
(cherry picked from commit 0857956)
This ensures that shell string escape operations will not produce output
with invalid UTF-8 from the input by escaping invalid UTF-8 data as if
they were single byte characters.

(cherry picked from commit 00f5715)
(cherry picked from commit e906fd2)
(cherry picked from commit e0a674f)
(cherry picked from commit dfa043a)
(cherry picked from commit 582843e)
(cherry picked from commit c4e7cf2)
(cherry picked from commit dec5e2e)
(cherry picked from commit 11ecf66)
The kernel loads the DTB from EFI before ExitBootServices():

https://github.com/torvalds/linux/blob/v6.5/drivers/firmware/efi/libstub/fdt.c#L245

DTBs can map and assign arbitrary memory ranges. The kernel refuses
to load one from the dtb= kernel command line parameter when secure
boot is enabled, as it's not safe. Let's do the same for type 1
entries, as they are unverified.

This only affects arm64 and riscv64, firmwares do not support DTB
on x86.

(cherry picked from commit 4b4d612)
(cherry picked from commit c1404ff)
(cherry picked from commit 7844c65)
(cherry picked from commit f381320)
(cherry picked from commit 3c97ff5)
Fixes #25676

(cherry picked from commit 3b4cc14)
(cherry picked from commit 6da5ca9)
(cherry picked from commit 0292727)
(cherry picked from commit 5c149c7)
(cherry picked from commit bb78da7)
(cherry picked from commit f58fc88)
Something went wrong when 6aa2c55 was
cherry-picked for v250-stable, causing it to fail to build when seccomp
is disabled.

Fix this by changing the code to how it looks like in other versions of
the backported commit, slightly adapted to the file's style in v250.

Fixes the following build error:

| ../git/src/core/main.c: In function 'parse_config_file':
| ../git/src/core/main.c:721:101: error: lvalue required as unary '&' operand
|   721 |                 { "Manager", "SystemCallArchitectures",      config_parse_syscall_archs,         0, &DISABLED_CONFIGURATION                },
|       |                                                                                                     ^

Fixes: 8e8c7d5 ("pid1: generate compat warning for SystemCallArchitectures= if seccomp is off")
@packit-as-a-service
Copy link
Copy Markdown

Failed to load packit config file:

Cannot parse package config. ValidationError({'jobs': {0: {'packages': defaultdict(<class 'dict'>, {'systemd': {'value': {'synced_files': ['Unknown field.']}}})}}, 'packages': defaultdict(<class 'dict'>, {'systemd': {'value': {'synced_files': ['Unknown field.']}}})})

For more info, please check out the documentation or contact the Packit team. You can also use our CLI command config validate or our pre-commit hooks for validation of the configuration.

@Devender-117 Devender-117 deleted the systemd_partition_fix branch August 21, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.