summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMingli Yu <mingli.yu@windriver.com>2021-08-16 16:03:45 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-08-17 09:53:04 +0100
commit6566a99d4d8d39204f60ad3dd9dda8603f1e713b (patch)
tree0ac64b24e9fcbe022747e847b46eadfde1c9b17d
parent626afc69a4ec59fb1dc56ba3cef7415924b97629 (diff)
downloadpoky-6566a99d4d8d39204f60ad3dd9dda8603f1e713b.tar.gz
shadow: fix default value in SHA_get_salt_rounds()
Backport a patch [1] to fix chpasswd, gpasswd and passwd "hang" for several minutes (10-20min) at 100% cpu usage though they finally terminate successfully. [1] https://github.com/shadow-maint/shadow/issues/393 (From OE-Core rev: ad8c62f988017e1e4da1f5ed7fb6f4a5ce44844e) Signed-off-by: Mingli Yu <mingli.yu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-extended/shadow/files/0001-libmisc-fix-default-value-in-SHA_get_salt_rounds.patch64
-rw-r--r--meta/recipes-extended/shadow/shadow.inc1
2 files changed, 65 insertions, 0 deletions
diff --git a/meta/recipes-extended/shadow/files/0001-libmisc-fix-default-value-in-SHA_get_salt_rounds.patch b/meta/recipes-extended/shadow/files/0001-libmisc-fix-default-value-in-SHA_get_salt_rounds.patch
new file mode 100644
index 0000000000..2c9b1d06cd
--- /dev/null
+++ b/meta/recipes-extended/shadow/files/0001-libmisc-fix-default-value-in-SHA_get_salt_rounds.patch
@@ -0,0 +1,64 @@
1From 234e8fa7b134d1ebabfdad980a3ae5b63c046c62 Mon Sep 17 00:00:00 2001
2From: Mike Gilbert <floppym@gentoo.org>
3Date: Sat, 14 Aug 2021 13:24:34 -0400
4Subject: [PATCH] libmisc: fix default value in SHA_get_salt_rounds()
5
6If SHA_CRYPT_MIN_ROUNDS and SHA_CRYPT_MAX_ROUNDS are both unspecified,
7use SHA_ROUNDS_DEFAULT.
8
9Previously, the code fell through, calling shadow_random(-1, -1). This
10ultimately set rounds = (unsigned long) -1, which ends up being a very
11large number! This then got capped to SHA_ROUNDS_MAX later in the
12function.
13
14The new behavior matches BCRYPT_get_salt_rounds().
15
16Bug: https://bugs.gentoo.org/808195
17Fixes: https://github.com/shadow-maint/shadow/issues/393
18
19Upstream-Status: Backport [https://github.com/shadow-maint/shadow/commit/234e8fa7b134d1ebabfdad980a3ae5b63c046c62]
20
21Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
22---
23 libmisc/salt.c | 21 +++++++++++----------
24 1 file changed, 11 insertions(+), 10 deletions(-)
25
26diff --git a/libmisc/salt.c b/libmisc/salt.c
27index 91d528fd..30eefb9c 100644
28--- a/libmisc/salt.c
29+++ b/libmisc/salt.c
30@@ -223,20 +223,21 @@ static /*@observer@*/const unsigned long SHA_get_salt_rounds (/*@null@*/int *pre
31 if ((-1 == min_rounds) && (-1 == max_rounds)) {
32 rounds = SHA_ROUNDS_DEFAULT;
33 }
34+ else {
35+ if (-1 == min_rounds) {
36+ min_rounds = max_rounds;
37+ }
38
39- if (-1 == min_rounds) {
40- min_rounds = max_rounds;
41- }
42+ if (-1 == max_rounds) {
43+ max_rounds = min_rounds;
44+ }
45
46- if (-1 == max_rounds) {
47- max_rounds = min_rounds;
48- }
49+ if (min_rounds > max_rounds) {
50+ max_rounds = min_rounds;
51+ }
52
53- if (min_rounds > max_rounds) {
54- max_rounds = min_rounds;
55+ rounds = (unsigned long) shadow_random (min_rounds, max_rounds);
56 }
57-
58- rounds = (unsigned long) shadow_random (min_rounds, max_rounds);
59 } else if (0 == *prefered_rounds) {
60 rounds = SHA_ROUNDS_DEFAULT;
61 } else {
62--
632.17.1
64
diff --git a/meta/recipes-extended/shadow/shadow.inc b/meta/recipes-extended/shadow/shadow.inc
index 97ffae978a..c1e24b4f16 100644
--- a/meta/recipes-extended/shadow/shadow.inc
+++ b/meta/recipes-extended/shadow/shadow.inc
@@ -16,6 +16,7 @@ SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/v${PV}/${BP}
16 file://shadow-relaxed-usernames.patch \ 16 file://shadow-relaxed-usernames.patch \
17 file://0001-Fix-out-of-tree-builds-with-respect-to-libsubid-incl.patch \ 17 file://0001-Fix-out-of-tree-builds-with-respect-to-libsubid-incl.patch \
18 file://0001-libsubid-link-to-PAM-libraries.patch \ 18 file://0001-libsubid-link-to-PAM-libraries.patch \
19 file://0001-libmisc-fix-default-value-in-SHA_get_salt_rounds.patch \
19 " 20 "
20 21
21SRC_URI:append:class-target = " \ 22SRC_URI:append:class-target = " \