Skip to content

Commit

Permalink
Merge branch 'jb45952' into 'master'
Browse files Browse the repository at this point in the history
Add patches that help with mounting encrypted home on boot. JB#45952

See merge request mer-core/systemd!23
  • Loading branch information
Tomin1 committed May 27, 2019
2 parents 53c807a + a71affc commit 79193e5
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
@@ -0,0 +1,110 @@
From 1f7927f916609fa99f472a6fe2e1e4df7c37d965 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 27 Jun 2017 02:17:39 +0200
Subject: [PATCH] udev: fix some incorrect usages of CLOCK_BOOTTIME (#6198)

CLOCK_BOOTTIME should only be used if we actually want the clock to
count on while we are suspended, and it is hence not useful for normal
code execution time limits, fix that.

Moreover, a couple of uses were even more broken, as
clock_bottime_or_monotonic() was called where actually
now(clock_boottime_or_monotic()) was supposed to be called. Ouch!

Fixes: #5903
---
src/udev/udev-event.c | 10 +++++-----
src/udev/udevd.c | 12 ++++++------
2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 476122278..894bbbad2 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -56,7 +56,7 @@ struct udev_event *udev_event_new(struct udev_device *dev) {
event->udev = udev;
udev_list_init(udev, &event->run_list, false);
udev_list_init(udev, &event->seclabel_list, false);
- event->birth_usec = clock_boottime_or_monotonic();
+ event->birth_usec = now(CLOCK_MONOTONIC);
return event;
}

@@ -496,7 +496,7 @@ static void spawn_read(struct udev_event *event,
if (timeout_usec > 0) {
usec_t age_usec;

- age_usec = clock_boottime_or_monotonic() - event->birth_usec;
+ age_usec = now(CLOCK_MONOTONIC) - event->birth_usec;
if (age_usec >= timeout_usec) {
log_error("timeout '%s'", cmd);
return;
@@ -647,13 +647,13 @@ static int spawn_wait(struct udev_event *event,
if (timeout_usec > 0) {
usec_t usec, age_usec;

- usec = now(clock_boottime_or_monotonic());
+ usec = now(CLOCK_MONOTONIC);
age_usec = usec - event->birth_usec;
if (age_usec < timeout_usec) {
if (timeout_warn_usec > 0 && timeout_warn_usec < timeout_usec && age_usec < timeout_warn_usec) {
spawn.timeout_warn = timeout_warn_usec - age_usec;

- r = sd_event_add_time(e, NULL, clock_boottime_or_monotonic(),
+ r = sd_event_add_time(e, NULL, CLOCK_MONOTONIC,
usec + spawn.timeout_warn, USEC_PER_SEC,
on_spawn_timeout_warning, &spawn);
if (r < 0)
@@ -662,7 +662,7 @@ static int spawn_wait(struct udev_event *event,

spawn.timeout = timeout_usec - age_usec;

- r = sd_event_add_time(e, NULL, clock_boottime_or_monotonic(),
+ r = sd_event_add_time(e, NULL, CLOCK_MONOTONIC,
usec + spawn.timeout, USEC_PER_SEC, on_spawn_timeout, &spawn);
if (r < 0)
return r;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 28ac44fb8..7ff7d4b88 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -275,12 +275,12 @@ static void worker_attach_event(struct worker *worker, struct event *event) {

e = worker->manager->event;

- assert_se(sd_event_now(e, clock_boottime_or_monotonic(), &usec) >= 0);
+ assert_se(sd_event_now(e, CLOCK_MONOTONIC, &usec) >= 0);

- (void) sd_event_add_time(e, &event->timeout_warning, clock_boottime_or_monotonic(),
+ (void) sd_event_add_time(e, &event->timeout_warning, CLOCK_MONOTONIC,
usec + arg_event_timeout_warn_usec, USEC_PER_SEC, on_event_timeout_warning, event);

- (void) sd_event_add_time(e, &event->timeout, clock_boottime_or_monotonic(),
+ (void) sd_event_add_time(e, &event->timeout, CLOCK_MONOTONIC,
usec + arg_event_timeout_usec, USEC_PER_SEC, on_event_timeout, event);
}

@@ -746,9 +746,9 @@ static void manager_exit(Manager *manager) {
event_queue_cleanup(manager, EVENT_QUEUED);
manager_kill_workers(manager);

- assert_se(sd_event_now(manager->event, clock_boottime_or_monotonic(), &usec) >= 0);
+ assert_se(sd_event_now(manager->event, CLOCK_MONOTONIC, &usec) >= 0);

- r = sd_event_add_time(manager->event, NULL, clock_boottime_or_monotonic(),
+ r = sd_event_add_time(manager->event, NULL, CLOCK_MONOTONIC,
usec + 30 * USEC_PER_SEC, USEC_PER_SEC, on_exit_timeout, manager);
if (r < 0)
return;
@@ -782,7 +782,7 @@ static void event_queue_start(Manager *manager) {
manager->exit || manager->stop_exec_queue)
return;

- assert_se(sd_event_now(manager->event, clock_boottime_or_monotonic(), &usec) >= 0);
+ assert_se(sd_event_now(manager->event, CLOCK_MONOTONIC, &usec) >= 0);
/* check for changed config, every 3 seconds at most */
if (manager->last_usec == 0 ||
(usec - manager->last_usec) > 3 * USEC_PER_SEC) {
--
2.21.0

30 changes: 30 additions & 0 deletions rpm/systemd-backport-Remove-extra-BindsTo.patch
@@ -0,0 +1,30 @@
From c88ae15f4f44f531f729dff39f77285c6b446ef1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= <tomi.leppanen@jolla.com>
Date: Mon, 20 May 2019 15:56:36 +0300
Subject: [PATCH] Remove extra BindsTo

Remove extra BindsTo clause. Otherwise it will cause problems when
booting home-encrypted device.

This is a backport of upstream commit
e9ea4526a3a3b41eced29b8d742498cc36750424.

---
src/cryptsetup/cryptsetup-generator.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 6fad8ad80..6c7afeb9f 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -106,7 +106,6 @@ static int create_disk(
"SourcePath=/etc/crypttab\n"
"DefaultDependencies=no\n"
"Conflicts=umount.target\n"
- "BindsTo=dev-mapper-%i.device\n"
"IgnoreOnIsolate=true\n"
"After=cryptsetup-pre.target\n",
f);
--
2.21.0

5 changes: 5 additions & 0 deletions rpm/systemd.spec
Expand Up @@ -43,6 +43,8 @@ Patch29: systemd-backport-enforce-a-limit-on-status-texts-recvd-from-serv
Patch30: systemd-backport-fix-deserialization-of-dev_t.patch
Patch31: systemd-backport-rework-serialization.patch
Patch32: systemd-239-dhcp6-client-CVE-2018-15688-fix.patch
Patch33: systemd-235-Remove-extra-BindsTo.patch
Patch34: systemd-234-udev-fix-some-incorrect-usages-of-CLOCK_BOOTTIME-619.patch

Patch99: systemd-225_fix_build_with_glibc228.patch

Expand Down Expand Up @@ -215,6 +217,9 @@ This package includes tests for systemd.
%patch31 -p1
# DHCP6 client CVE-2018-15688 fix
%patch32 -p1
# home encryption related patches
%patch33 -p1
%patch34 -p1
#systemd-225_fix_build_with_glibc228.patch
%patch99 -p1

Expand Down

0 comments on commit 79193e5

Please sign in to comment.