From b9055f3969c35b79a0f5315698b539d00573bb4547c9949fe568dcb3977cc64e Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Fri, 31 Jan 2020 10:41:15 +0000 Subject: [PATCH] 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 --- ...lete-fix-double-unlock-of-root-mutex.patch | 47 +++++++++++++++++++ lxd.changes | 6 +++ lxd.spec | 4 ++ 3 files changed, 57 insertions(+) create mode 100644 boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch diff --git a/boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch b/boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch new file mode 100644 index 0000000..082da12 --- /dev/null +++ b/boo1156336-0001-vfs-vfs__delete-fix-double-unlock-of-root-mutex.patch @@ -0,0 +1,47 @@ +From 13548f8bdb309d18801de9febb8f5829b6b9ae55 Mon Sep 17 00:00:00 2001 +From: Aleksa Sarai +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 +--- + 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 + diff --git a/lxd.changes b/lxd.changes index 3d8776a..7e55caa 100644 --- a/lxd.changes +++ b/lxd.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Jan 31 10:16:27 UTC 2020 - Aleksa Sarai + +- 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 diff --git a/lxd.spec b/lxd.spec index 39bb185..a1c4899 100644 --- a/lxd.spec +++ b/lxd.spec @@ -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