Merge ~sergiodj/ubuntu/+source/memcached:sasl-configuration-wrong-path-bug1878721-eoan into ubuntu/+source/memcached:ubuntu/eoan-devel

Proposed by Sergio Durigan Junior
Status: Merged
Approved by: Bryce Harrington
Approved revision: e56ed463b1bfea92341bce22a4407f2d25c02366
Merged at revision: e56ed463b1bfea92341bce22a4407f2d25c02366
Proposed branch: ~sergiodj/ubuntu/+source/memcached:sasl-configuration-wrong-path-bug1878721-eoan
Merge into: ubuntu/+source/memcached:ubuntu/eoan-devel
Diff against target: 144 lines (+122/-0)
3 files modified
debian/changelog (+18/-0)
debian/patches/fix-bug-where-sasl-will-load-config-the-wrong-path.patch (+103/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Bryce Harrington (community) Approve
Anders Kaseorg (community) Approve
Canonical Server Core Reviewers Pending
Review via email: mp+384765@code.launchpad.net

Description of the change

This is a simple regression that happens on memcached. The SASL configuration is being read from an erroneous file, '/etc/sasl2/memcached.conf/memcached.conf'. Upstream fixed this bug and made memcached load the configuration from the right file, '/etc/sasl2/memcached.conf', but kept the old behaviour (i.e., reading from the wrong location) just in case users have made a workaround.

The reporter was thorough and provided the debdiff along with an SRU template, so one could say I'm filing this MP for him. I kept his authorship intact.

There is a PPA with the proposed change here:

https://launchpad.net/~sergiodj/+archive/ubuntu/memcached-bug1878721

autopkgtest is still happy:

autopkgtest [09:22:43]: test client.pl: -----------------------]
autopkgtest [09:22:44]: test client.pl: - - - - - - - - - - results - - - - - - - - - -
client.pl PASS
autopkgtest [09:22:45]: @@@@@@@@@@@@@@@@@@@@ summary
daemon PASS
client.pl PASS

To post a comment you must log in.
Revision history for this message
Anders Kaseorg (andersk) :
review: Approve
Revision history for this message
Bryce Harrington (bryce) wrote :

* Changelog:
  - [√] old content and logical tag match as expected
  - [√] changelog entry correct version and targeted codename
  - [√] changelog entries correct
  - [√] update-maintainer has been run

* Actual changes:
  - [-] no upstream changes to consider
  - [-] no further upstream version to consider
  - [√] debian changes look safe

* Old Delta:
  - [-] dropped changes are ok to be dropped
  - [-] nothing else to drop
  - [√] changes forwarded upstream/debian (if appropriate)

* New Delta:
  - [-] no new patches added
  - [√] patches match what was proposed upstream
  - [√] patches correctly included in debian/patches/series
  - [√] patches have correct DEP3 metadata

* Build/Test:
  - [√] build is ok
  - [√] verified PPA package installs/uninstalls
  - [√] autopkgtest against the PPA package passes
  - [x] sanity checks test fine

See comments on the focal branch.

Revision history for this message
Bryce Harrington (bryce) :
review: Needs Fixing
Revision history for this message
Bryce Harrington (bryce) wrote :

$ git ubuntu tag --upload
$ git push pkg upload/1.5.10-0ubuntu3.1
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 12 threads
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 3.52 KiB | 1.17 MiB/s, done.
Total 11 (delta 7), reused 0 (delta 0)
To ssh://git.launchpad.net/ubuntu/+source/memcached
 * [new tag] upload/1.5.10-0ubuntu3.1 -> upload/1.5.10-0ubuntu3.1
$ dput ubuntu ../memcached_1.5.10-0ubuntu3.1_source.changes
Checking signature on .changes
gpg: ../memcached_1.5.10-0ubuntu3.1_source.changes: Valid signature from E603B2578FB8F0FB
Checking signature on .dsc
gpg: ../memcached_1.5.10-0ubuntu3.1.dsc: Valid signature from E603B2578FB8F0FB
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading memcached_1.5.10-0ubuntu3.1.dsc: done.
  Uploading memcached_1.5.10-0ubuntu3.1.debian.tar.xz: done.
  Uploading memcached_1.5.10-0ubuntu3.1_source.buildinfo: done.
  Uploading memcached_1.5.10-0ubuntu3.1_source.changes: done.
Successfully uploaded packages.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 6df3b73..b0194fd 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,21 @@
6+memcached (1.5.10-0ubuntu3.1) eoan; urgency=medium
7+
8+ * d/p/fix-bug-where-sasl-will-load-config-the-wrong-path.patch:
9+ Fix the path from which SASL configuration is loaded. (LP: #1878721)
10+ The bug happened because sasl expects memcached to provide a
11+ path (i.e., a directory, not a filename) where the sasl
12+ configuration file(s) is (are). However, memcached was passing
13+ the filename (/etc/sasl2/memcached.conf) to sasl, which was
14+ interpreting it as a directory, and looking for a configuration
15+ file inside it (i.e., /etc/sasl2/memcached.conf/memcached.conf).
16+ Users could workaround this bug by creating a directory named
17+ /etc/sasl2/memcached.conf/, and putting the configuration file
18+ inside it. This patch not only fixes this bug (by passing the
19+ right directory, /etc/sasl2/, to sasl) but also supports the
20+ workaround described above.
21+
22+ -- Anders Kaseorg <andersk@mit.edu> Thu, 14 May 2020 17:13:17 -0700
23+
24 memcached (1.5.10-0ubuntu3) eoan; urgency=medium
25
26 * SECURITY UPDATE: stack-based buffer over-read
27diff --git a/debian/patches/fix-bug-where-sasl-will-load-config-the-wrong-path.patch b/debian/patches/fix-bug-where-sasl-will-load-config-the-wrong-path.patch
28new file mode 100644
29index 0000000..3901042
30--- /dev/null
31+++ b/debian/patches/fix-bug-where-sasl-will-load-config-the-wrong-path.patch
32@@ -0,0 +1,103 @@
33+From: Zheng Gu <zhenggu@cisco.com>
34+Date: Fri, 22 Nov 2019 22:34:16 +0800
35+Subject: fix bug where sasl will load config the wrong path
36+
37+/etc/sasl2/memcached.conf/memcached.conf instead of
38+/etc/sasl2/memcached.conf
39+
40+This bug was caused by two upstream commits:
41+
42+ https://github.com/memcached/memcached/commit/39151c870c5e598f039714bdb790bd46f614856e
43+ https://github.com/memcached/memcached/commit/80dd99d831535ddeec73d55a0adcaeaac8cb7298
44+
45+Now, the reason for the bug is interesting. Before the commits
46+mentioned above, we had a big part of the sasl_defs.c file practically
47+inactive due to the "#ifdef HAVE_SASL_CB_GETCONF" check (which fails
48+when compiling with cyrrus-sasl), including the definition of the
49+"sasl_getconf" function, which is the source of this bug, and which
50+implements the "sasl_getconfpath_t" callback used by sasl to get the
51+configuration path to be used. According to sasl_getconfpath_t(3):
52+
53+ sasl_getconfpath_t is used if the application wishes to use a
54+ different location for the SASL configuration files. If this callback
55+ is not used SASL will either use the location in the environment
56+ variable SASL_CONF_PATH (provided we are not SUID or SGID) or
57+ /etc/sasl2 by default.
58+
59+Which means that, before both commits existed, memcached was always
60+using /etc/sasl2 as the config path.
61+
62+When the commits were incorporated into the repo, memcached started
63+using "sasl_getconf" for both the HAVE_SASL_CB_GETCONF and the
64+HAVE_SASL_CB_GETCONFPATH cases, but the function only works is the sasl
65+being used supports SASL_CB_GETCONF, because it passes the full path
66+(including the filename) back to the sasl library for processing. And
67+this is the reason why the sasl library started getting
68+"/etc/sasl2/memcached.conf/" as the config path.
69+
70+Author: Zheng Gu <zhenggu@cisco.com>
71+Origin: upstream, https://github.com/memcached/memcached/commit/6207330c2705fdb5f02de13b99a0d994f7c4f14a
72+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/memcached/+bug/1878721
73+Last-Update: 2020-05-26
74+Applied-Upstream: 1.6.0
75+Reviewed-by: Sergio Durigan Junior <sergio.durigan@canonical.com>
76+---
77+ sasl_defs.c | 29 +++++++++++++++++++++++++++++
78+ 1 file changed, 29 insertions(+)
79+
80+diff --git a/sasl_defs.c b/sasl_defs.c
81+index c60d1bf..370f947 100644
82+--- a/sasl_defs.c
83++++ b/sasl_defs.c
84+@@ -16,6 +16,23 @@ const char * const locations[] = {
85+ "/etc/sasl2/memcached.conf",
86+ NULL
87+ };
88++
89++/* If the element of locations is file, locations_dir_path stores the
90++ * directory path of these elements */
91++const char *const locations_dir_path[] = {
92++ "/etc/sasl",
93++ "/etc/sasl2",
94++ NULL
95++};
96++
97++/* If the element of locations is directory, locations_file_path stores
98++ * the actual configue file which used by sasl, when GETCONFPATH is
99++ * enabled */
100++const char *const locations_file_path[] = {
101++ "/etc/sasl/memcached.conf/memcached.conf",
102++ "/etc/sasl2/memcached.conf/memcached.conf",
103++ NULL
104++};
105+ #endif
106+
107+ #ifndef HAVE_SASL_CALLBACK_FT
108+@@ -88,12 +105,24 @@ static int sasl_getconf(void *context, const char **path)
109+ *path = getenv("SASL_CONF_PATH");
110+
111+ if (*path == NULL) {
112++#if defined(HAVE_SASL_CB_GETCONF)
113+ for (int i = 0; locations[i] != NULL; ++i) {
114+ if (access(locations[i], F_OK) == 0) {
115+ *path = locations[i];
116+ break;
117+ }
118+ }
119++#elif defined(HAVE_SASL_CB_GETCONFPATH)
120++ for (int i = 0; locations[i] != NULL; ++i) {
121++ if (access(locations_file_path[i], F_OK) == 0) {
122++ *path = locations[i];
123++ break;
124++ } else if (access(locations[i], F_OK) == 0) {
125++ *path = locations_dir_path[i];
126++ break;
127++ }
128++ }
129++#endif
130+ }
131+
132+ if (settings.verbose) {
133+--
134+2.26.2
135+
136diff --git a/debian/patches/series b/debian/patches/series
137index 71207c2..d6e04cf 100644
138--- a/debian/patches/series
139+++ b/debian/patches/series
140@@ -4,3 +4,4 @@
141 07_disable_tests.patch
142 CVE-2019-11596.patch
143 CVE-2019-15026.patch
144+fix-bug-where-sasl-will-load-config-the-wrong-path.patch

Subscribers

People subscribed via source and target branches