Compare commits
11 Commits
d7a470c12a
...
7f0d62d9d1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f0d62d9d1 | ||
|
|
c253396220 | ||
|
|
d17aaba7b3 | ||
|
|
ea100d677d | ||
|
|
1c9fdd46e5 | ||
|
|
7b2e2b3434 | ||
|
|
a0976048f3 | ||
|
|
9e16c16537 | ||
|
|
c657843ace | ||
|
|
e4ff2d91b3 | ||
|
|
037109f63c |
@ -0,0 +1,79 @@
|
||||
From ad0958b816f28e53d9bda4486e969ec3ca63538a Mon Sep 17 00:00:00 2001
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Wed, 19 Jun 2024 19:54:16 +0200
|
||||
Subject: [PATCH] lib/csrand.c: Fix the lower part of the domain of
|
||||
csrand_uniform()
|
||||
|
||||
I accidentally broke this code during an un-optimization. We need to
|
||||
start from a random value of the width of the limit, that is, 32 bits.
|
||||
|
||||
Thanks to Jason for pointing to his similar code in the kernel, which
|
||||
made me see my mistake.
|
||||
|
||||
Fixes: 2a61122b5e8f ("Unoptimize the higher part of the domain of csrand_uniform()")
|
||||
Closes: <https://github.com/shadow-maint/shadow/issues/1015>
|
||||
Reported-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
|
||||
Link: <https://git.zx2c4.com/linux-rng/tree/drivers/char/random.c#n535>
|
||||
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/638>
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/634>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/624>
|
||||
Tested-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
|
||||
Reviewed-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
Cherry-picked-from: 4119a2dce564 ("lib/csrand.c: Fix the lower part of the domain of csrand_uniform()")
|
||||
Cc: "Serge E. Hallyn" <serge@hallyn.com>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1025>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
|
||||
Conflict: N/A
|
||||
Reference: https://github.com/shadow-maint/shadow/commit/ad0958b816f28e53d9bda4486e969ec3ca63538a
|
||||
|
||||
---
|
||||
lib/csrand.c | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/csrand.c b/lib/csrand.c
|
||||
index e85eaa8a..16bcccf0 100644
|
||||
--- a/lib/csrand.c
|
||||
+++ b/lib/csrand.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "shadowlog.h"
|
||||
|
||||
|
||||
+static uint32_t csrand32(void);
|
||||
static uint32_t csrand_uniform32(uint32_t n);
|
||||
static unsigned long csrand_uniform_slow(unsigned long n);
|
||||
|
||||
@@ -96,6 +97,13 @@ csrand_interval(unsigned long min, unsigned long max)
|
||||
}
|
||||
|
||||
|
||||
+static uint32_t
|
||||
+csrand32(void)
|
||||
+{
|
||||
+ return csrand();
|
||||
+}
|
||||
+
|
||||
+
|
||||
/*
|
||||
* Fast Random Integer Generation in an Interval
|
||||
* ACM Transactions on Modeling and Computer Simulation 29 (1), 2019
|
||||
@@ -108,12 +116,12 @@ csrand_uniform32(uint32_t n)
|
||||
uint64_t r, mult;
|
||||
|
||||
if (n == 0)
|
||||
- return csrand();
|
||||
+ return csrand32();
|
||||
|
||||
bound = -n % n; // analogous to `2^32 % n`, since `x % y == (x-y) % y`
|
||||
|
||||
do {
|
||||
- r = csrand();
|
||||
+ r = csrand32();
|
||||
mult = r * n;
|
||||
rem = mult; // analogous to `mult % 2^32`
|
||||
} while (rem < bound); // p = (2^32 % n) / 2^32; W.C.: n=2^31+1, p=0.5
|
||||
--
|
||||
2.46.0
|
||||
|
||||
38
backport-lib-encrypt.c-Do-not-exit-in-error-case.patch
Normal file
38
backport-lib-encrypt.c-Do-not-exit-in-error-case.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From 6cbce81df97a16363c46cbd1e8202c3b4f0a2205 Mon Sep 17 00:00:00 2001
|
||||
From: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||
Date: Sun, 19 Jan 2025 21:23:54 +0100
|
||||
Subject: [PATCH] lib/encrypt.c: Do not exit in error case
|
||||
|
||||
If crypt fails, pw_encrypt calls exit. This has the consequence that the
|
||||
plaintext password is not cleared.
|
||||
|
||||
A valid password can fail if the underlying library does not support it.
|
||||
One such example is SHA512, for which the password must not be longer
|
||||
than 256 characters on musl. A password longer than this with glibc
|
||||
works, so it is actually possible that a user, running passwd, tries to
|
||||
enter the old password but the musl-based passwd binary simply exits.
|
||||
Let passwd clear the password before exiting.
|
||||
|
||||
Reviewed-by: Alejandro Colomar <alx@kernel.org>
|
||||
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||
---
|
||||
lib/encrypt.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/encrypt.c b/lib/encrypt.c
|
||||
index c84a2552..9c1cb406 100644
|
||||
--- a/lib/encrypt.c
|
||||
+++ b/lib/encrypt.c
|
||||
@@ -65,7 +65,8 @@
|
||||
(void) fprintf (shadow_logfd,
|
||||
_("crypt method not supported by libcrypt? (%s)\n"),
|
||||
method);
|
||||
- exit (EXIT_FAILURE);
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
if (strlen (cp) != 13) {
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
From 80efeebaf296dc4814e15d67977726b3ee93c048 Mon Sep 17 00:00:00 2001
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Fri, 31 May 2024 18:30:16 +0200
|
||||
Subject: [PATCH] lib/idmapping.c: Use long constants in prctl(2), and remove
|
||||
0s
|
||||
|
||||
The prctl(2) system-call wrapper is implemented as a variadic function.
|
||||
This makes it important to pass arguments to it of the right type (and
|
||||
more importantly of the right width), to avoid undefined behavior.
|
||||
|
||||
While at it, check errors with ==-1, not <0, which is more explicit.
|
||||
|
||||
Also, PR_SET_KEEPCAPS(2const) doesn't need all arguments, so it can be
|
||||
called with just two of them; remove unnecessary 0s.
|
||||
|
||||
See-also: prctl(2), PR_SET_KEEPCAPS(2const)
|
||||
Link: <https://lore.kernel.org/linux-man/ddbdyaiptesjalgfmztxideej67e3yaob7ucsmbf6qvriwxiif@dohhxrqgwhrf/T/#med306b5b003f9cc7cc2de69fcdd7ee2d056d0954>
|
||||
Cc: Xi Ruoyao <xry111@xry111.site>
|
||||
Cc: Lukas Slebodnik <lslebodn@fedoraproject.org>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
lib/idmapping.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/idmapping.c b/lib/idmapping.c
|
||||
index fe3ccdfe3..5cbb6fefc 100644
|
||||
--- a/lib/idmapping.c
|
||||
+++ b/lib/idmapping.c
|
||||
@@ -159,7 +159,7 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
|
||||
|
||||
/* Align setuid- and fscaps-based new{g,u}idmap behavior. */
|
||||
if (geteuid() == 0 && geteuid() != ruid) {
|
||||
- if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
|
||||
+ if (prctl(PR_SET_KEEPCAPS, 1L) == -1) {
|
||||
fprintf(log_get_logfd(), _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), log_get_progname());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
30
backport-man-lastlog-remove-wrong-use-of-keyword-term.patch
Normal file
30
backport-man-lastlog-remove-wrong-use-of-keyword-term.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 9f57beb31ade241aeda412a8ada4912bab83bd40 Mon Sep 17 00:00:00 2001
|
||||
From: Serge Hallyn <serge@hallyn.com>
|
||||
Date: Wed, 5 Jun 2024 08:02:27 -0500
|
||||
Subject: [PATCH] man/lastlog: remove wrong use of keyword term
|
||||
|
||||
Per https://tdg.docbook.org/tdg/4.5/term, term is a word being
|
||||
defined in a varlistentry. The 'high uid' description is not a
|
||||
varlistentry, so <term> and </term> show up in the processed
|
||||
manpage. See debian Bug#1072297.
|
||||
|
||||
Signed-off-by: Serge Hallyn <serge@hallyn.com>
|
||||
---
|
||||
man/lastlog.8.xml | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/man/lastlog.8.xml b/man/lastlog.8.xml
|
||||
index 7a4ba967f..6700791c1 100644
|
||||
--- a/man/lastlog.8.xml
|
||||
+++ b/man/lastlog.8.xml
|
||||
@@ -211,8 +211,8 @@
|
||||
to hang as it processes entries with UIDs 171-799).
|
||||
</para>
|
||||
<para>
|
||||
- Having high UIDs can create problems when handling the <term><filename>
|
||||
- /var/log/lastlog</filename></term> with external tools. Although the
|
||||
+ Having high UIDs can create problems when handling the <filename>
|
||||
+ /var/log/lastlog</filename> with external tools. Although the
|
||||
actual file is sparse and does not use too much space, certain
|
||||
applications are not designed to identify sparse files by default and may
|
||||
require a specific option to handle them.
|
||||
35
backport-src-gpasswd-Clear-password-in-more-cases.patch
Normal file
35
backport-src-gpasswd-Clear-password-in-more-cases.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 6b4bbbeecd676c9423f82658bb3a8f6990218e8d Mon Sep 17 00:00:00 2001
|
||||
From: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||
Date: Sun, 19 Jan 2025 21:27:50 +0100
|
||||
Subject: [PATCH] src/gpasswd: Clear password in more cases
|
||||
|
||||
If encryption of password fails, clear the memory before exiting.
|
||||
|
||||
Reviewed-by: Alejandro Colomar <alx@kernel.org>
|
||||
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||
---
|
||||
src/gpasswd.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/gpasswd.c b/src/gpasswd.c
|
||||
index 560b0ea7..e9e111a9 100644
|
||||
--- a/src/gpasswd.c
|
||||
+++ b/src/gpasswd.c
|
||||
@@ -864,13 +864,13 @@ static void change_passwd (struct group *gr)
|
||||
|
||||
salt = crypt_make_salt (NULL, NULL);
|
||||
cp = pw_encrypt (pass, salt);
|
||||
+ memzero (pass, sizeof pass);
|
||||
if (NULL == cp) {
|
||||
fprintf (stderr,
|
||||
_("%s: failed to crypt password with salt '%s': %s\n"),
|
||||
Prog, salt, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
- memzero (pass, sizeof pass);
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadowgrp) {
|
||||
gr->gr_passwd = SHADOW_PASSWD_STRING;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
32
backport-src-useradd.c-get_groups-Fix-memory-leak.patch
Normal file
32
backport-src-useradd.c-get_groups-Fix-memory-leak.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From feead2f639506d49cef9dde385eb56cd3413ecf0 Mon Sep 17 00:00:00 2001
|
||||
From: sgakerru <sulmpx60@yandex.ru>
|
||||
Date: Sat, 19 Oct 2024 13:26:44 +0400
|
||||
Subject: [PATCH] src/useradd.c: get_groups(): Fix memory leak
|
||||
|
||||
---
|
||||
src/useradd.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/src/useradd.c b/src/useradd.c
|
||||
index 64e7a412..bd3b0624 100644
|
||||
--- a/src/useradd.c
|
||||
+++ b/src/useradd.c
|
||||
@@ -760,6 +760,15 @@ static int get_groups (char *list)
|
||||
int errors = 0;
|
||||
int ngroups = 0;
|
||||
|
||||
+ /*
|
||||
+ * Free previous group list before creating a new one.
|
||||
+ */
|
||||
+ int i = 0;
|
||||
+ while (NULL != user_groups[i]) {
|
||||
+ free(user_groups[i]);
|
||||
+ user_groups[i++] = NULL;
|
||||
+ }
|
||||
+
|
||||
if ('\0' == *list) {
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
41
limit-username-length-to-32.patch
Normal file
41
limit-username-length-to-32.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From cb569337f22de160d61df0bdb7c06f17517835ab Mon Sep 17 00:00:00 2001
|
||||
From: zhangshaoning <zhangshaoning@uniontech.com>
|
||||
Date: Thu, 16 Jan 2025 16:30:09 +0800
|
||||
Subject: [PATCH] limit username length to 32
|
||||
|
||||
---
|
||||
lib/chkname.c | 4 ++--
|
||||
lib/chkname.h | 4 ++++
|
||||
2 files changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/chkname.c b/lib/chkname.c
|
||||
index 2b83361..ae6180f 100644
|
||||
--- a/lib/chkname.c
|
||||
+++ b/lib/chkname.c
|
||||
@@ -75,9 +75,9 @@ static bool is_valid_name (const char *name)
|
||||
bool is_valid_user_name (const char *name)
|
||||
{
|
||||
/*
|
||||
- * User names length are limited by the kernel
|
||||
+ * User names length are limited by USER_NAME_MAX_LENGTH
|
||||
*/
|
||||
- if (strlen (name) > sysconf(_SC_LOGIN_NAME_MAX)) {
|
||||
+ if (strlen (name) > USER_NAME_MAX_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
diff --git a/lib/chkname.h b/lib/chkname.h
|
||||
index 0771347..4af8f32 100644
|
||||
--- a/lib/chkname.h
|
||||
+++ b/lib/chkname.h
|
||||
@@ -25,3 +25,7 @@ extern bool is_valid_user_name (const char *name);
|
||||
extern bool is_valid_group_name (const char *name);
|
||||
|
||||
#endif
|
||||
+
|
||||
+#ifndef USER_NAME_MAX_LENGTH
|
||||
+#define USER_NAME_MAX_LENGTH 32
|
||||
+#endif
|
||||
--
|
||||
2.18.2
|
||||
|
||||
@ -496,8 +496,8 @@ index 1a1a5d5..a2b6e9e 100644
|
||||
#endif /* USE_YESCRYPT */
|
||||
- if (bad_s != 0) {
|
||||
+#if defined(USE_SM3_CRYPT)
|
||||
+ if (( (0 == strcmp (crypt_method, "SM3"))
|
||||
+ && (0 == getlong(optarg, &sm3_rounds)))) {
|
||||
+ if (IS_CRYPT_METHOD("SM3")
|
||||
+ && (0 == getlong(optarg, &sm3_rounds))) {
|
||||
+ bad_s = 1;
|
||||
+ }
|
||||
+#endif /* USE_SM3_CRYPT */
|
||||
|
||||
25
shadow.spec
25
shadow.spec
@ -1,6 +1,6 @@
|
||||
Name: shadow
|
||||
Version: 4.14.3
|
||||
Release: 2
|
||||
Release: 7
|
||||
Epoch: 2
|
||||
License: BSD and GPLv2+
|
||||
Summary: Tools for managing accounts and shadow password files
|
||||
@ -20,6 +20,13 @@ Patch0: usermod-unlock.patch
|
||||
Patch1: shadow-add-sm3-crypt-support.patch
|
||||
Patch2: shadow-Remove-encrypted-passwd-for-useradd-gr.patch
|
||||
Patch3: shadow-libsubid-Dealocate-memory-on-exit.patch
|
||||
Patch4: backport-lib-idmapping.c--Use-long-constants-in-prctl-2.patch
|
||||
Patch5: backport-man-lastlog-remove-wrong-use-of-keyword-term.patch
|
||||
Patch6: backport-lib-csrand.c-Fix-the-lower-part-of-the-domain-of-csr.patch
|
||||
Patch7: limit-username-length-to-32.patch
|
||||
Patch8: backport-src-useradd.c-get_groups-Fix-memory-leak.patch
|
||||
Patch9: backport-src-gpasswd-Clear-password-in-more-cases.patch
|
||||
Patch10: backport-lib-encrypt.c-Do-not-exit-in-error-case.patch
|
||||
|
||||
BuildRequires: gcc, libselinux-devel, audit-libs-devel, libsemanage-devel
|
||||
BuildRequires: libacl-devel, libattr-devel
|
||||
@ -189,6 +196,22 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/libsubid.{la,a}
|
||||
%{_mandir}/*/*
|
||||
|
||||
%changelog
|
||||
* Tue Mar 11 2025 yixiangzhike <yixiangzhike007@163.com> - 2:4.14.3-7
|
||||
- backport patches from upstream
|
||||
|
||||
* Sat Feb 8 2025 hugel <gengqihu2@h-partners.com> - 2:4.14.3-6
|
||||
- limit username length to 32
|
||||
|
||||
* Mon Dec 16 2024 beta <beta@yfqm.date> - 2:4.14.3-5
|
||||
- backport patches from upstream
|
||||
|
||||
* Wed Dec 11 2024 beta <beta@yfqm.date> - 2:4.14.3-4
|
||||
- chpasswd fix coredump with s parameter
|
||||
|
||||
* Wed Oct 9 2024 zhangxingrong <zhangxingrong@uniontech.com> - 2:4.14.3-3
|
||||
- lib/idmapping.c: Use long constants in prctl(2)
|
||||
- man/lastlog: remove wrong use of keyword term
|
||||
|
||||
* Fri Sep 6 2024 zhangzikang <zhangzikang@kylinos.cn> - 2:4.14.3-2
|
||||
- libsubid: Dealocate memory on exit
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user