Accepting request 769023 from home:cyphar:lxc

- Backport https://github.com/canonical/dqlite/pull/207 to fix boo#1156336.
  + boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch

OBS-URL: https://build.opensuse.org/request/show/769023
OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/lxd?expand=0&rev=39
This commit is contained in:
Aleksa Sarai 2020-01-31 10:41:15 +00:00 committed by Git OBS Bridge
parent be143eb303
commit b9055f3969
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,47 @@
From 13548f8bdb309d18801de9febb8f5829b6b9ae55 Mon Sep 17 00:00:00 2001
From: Aleksa Sarai <cyphar@cyphar.com>
Date: Fri, 31 Jan 2020 20:57:47 +1100
Subject: [PATCH] vfs: vfs__delete: fix double-unlock of &root->mutex
vfs__delete_contents would unlock the passed &root->mutex, but all of
its callers would then also unlock the passed &root->mutex. It turns out
that this works on most architectures without issue, but apparently on
some Intel CPUs with TSX enabled this will trigger a general protection
fault[1,2].
This was the cause of a very frustrating bug where LXD would segfault on
start-up[3].
[1]: https://lwn.net/Articles/534758/
[2]: https://software.intel.com/en-us/forums/intel-isa-extensions/topic/675036
[3]: https://bugzilla.opensuse.org/show_bug.cgi?id=1156336
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
---
src/vfs.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/vfs.c b/src/vfs.c
index 3a4c205a1d4a..443a6ad3b980 100644
--- a/src/vfs.c
+++ b/src/vfs.c
@@ -619,7 +619,6 @@ static int vfs__delete_content(struct root *root, const char *filename)
/* Check that there are no consumers of this file. */
if (content->refcount > 0) {
root->error = EBUSY;
- pthread_mutex_unlock(&root->mutex);
rc = SQLITE_IOERR_DELETE;
goto err;
}
@@ -630,8 +629,6 @@ static int vfs__delete_content(struct root *root, const char *filename)
/* Reset the file content slot. */
*(root->contents + content_index) = NULL;
- pthread_mutex_unlock(&root->mutex);
-
return SQLITE_OK;
err:
--
2.25.0

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jan 31 10:16:27 UTC 2020 - Aleksa Sarai <asarai@suse.com>
- Backport https://github.com/canonical/dqlite/pull/207 to fix boo#1156336.
+ boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch
-------------------------------------------------------------------
Fri Jan 31 00:33:47 UTC 2020 - Aleksa Sarai <asarai@suse.com>

View File

@ -38,6 +38,8 @@ Source100: %{name}.service
# Additional runtime configuration.
Source200: %{name}.sysctl
Source201: %{name}.dnsmasq
# FIX-UPSTREAM: Backport of https://github.com/canonical/dqlite/pull/207. boo#1156336
Patch100: boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch
BuildRequires: fdupes
BuildRequires: golang-packaging
BuildRequires: libacl-devel
@ -88,6 +90,8 @@ Bash command line completion support for %{name}.
%prep
%setup -q
# boo#1156336
%patch100 -d _dist/deps/dqlite -p1
# Create fake "go mod"-like import paths. This is going to be really fun to
# maintain but it's unfortunately necessary because openSUSE doesn't have nice