diff options
| author | Xiangyu Chen <xiangyu.chen@windriver.com> | 2023-04-19 14:17:39 +0800 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-04-26 04:03:21 -1000 |
| commit | e8eab4241593cc93da7dd24ad7a188bbf1866413 (patch) | |
| tree | 9e8c57e084f90527302ca25df479e082d343b1a4 | |
| parent | 82be2c179a235e66f30eab58232e9384c087157e (diff) | |
| download | poky-e8eab4241593cc93da7dd24ad7a188bbf1866413.tar.gz | |
shadow: backport patch to fix CVE-2023-29383
The fix of CVE-2023-29383.patch contains a bug that it rejects all
characters that are not control ones, so backup another patch named
"0001-Overhaul-valid_field.patch" from upstream to fix it.
(From OE-Core rev: ab48ab23de6f6bb1f05689c97724140d4bef8faa)
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch | 65 | ||||
| -rw-r--r-- | meta/recipes-extended/shadow/files/CVE-2023-29383.patch | 53 | ||||
| -rw-r--r-- | meta/recipes-extended/shadow/shadow.inc | 2 |
3 files changed, 120 insertions, 0 deletions
diff --git a/meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch b/meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch new file mode 100644 index 0000000000..ac08be515b --- /dev/null +++ b/meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | From 2eaea70111f65b16d55998386e4ceb4273c19eb4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com> | ||
| 3 | Date: Fri, 31 Mar 2023 14:46:50 +0200 | ||
| 4 | Subject: [PATCH] Overhaul valid_field() | ||
| 5 | |||
| 6 | e5905c4b ("Added control character check") introduced checking for | ||
| 7 | control characters but had the logic inverted, so it rejects all | ||
| 8 | characters that are not control ones. | ||
| 9 | |||
| 10 | Cast the character to `unsigned char` before passing to the character | ||
| 11 | checking functions to avoid UB. | ||
| 12 | |||
| 13 | Use strpbrk(3) for the illegal character test and return early. | ||
| 14 | |||
| 15 | Upstream-Status: Backport [https://github.com/shadow-maint/shadow/commit/2eaea70111f65b16d55998386e4ceb4273c19eb4] | ||
| 16 | |||
| 17 | Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> | ||
| 18 | --- | ||
| 19 | lib/fields.c | 24 ++++++++++-------------- | ||
| 20 | 1 file changed, 10 insertions(+), 14 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/lib/fields.c b/lib/fields.c | ||
| 23 | index fb51b582..53929248 100644 | ||
| 24 | --- a/lib/fields.c | ||
| 25 | +++ b/lib/fields.c | ||
| 26 | @@ -37,26 +37,22 @@ int valid_field (const char *field, const char *illegal) | ||
| 27 | |||
| 28 | /* For each character of field, search if it appears in the list | ||
| 29 | * of illegal characters. */ | ||
| 30 | + if (illegal && NULL != strpbrk (field, illegal)) { | ||
| 31 | + return -1; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /* Search if there are non-printable or control characters */ | ||
| 35 | for (cp = field; '\0' != *cp; cp++) { | ||
| 36 | - if (strchr (illegal, *cp) != NULL) { | ||
| 37 | + unsigned char c = *cp; | ||
| 38 | + if (!isprint (c)) { | ||
| 39 | + err = 1; | ||
| 40 | + } | ||
| 41 | + if (iscntrl (c)) { | ||
| 42 | err = -1; | ||
| 43 | break; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | - if (0 == err) { | ||
| 48 | - /* Search if there are non-printable or control characters */ | ||
| 49 | - for (cp = field; '\0' != *cp; cp++) { | ||
| 50 | - if (!isprint (*cp)) { | ||
| 51 | - err = 1; | ||
| 52 | - } | ||
| 53 | - if (!iscntrl (*cp)) { | ||
| 54 | - err = -1; | ||
| 55 | - break; | ||
| 56 | - } | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | return err; | ||
| 61 | } | ||
| 62 | |||
| 63 | -- | ||
| 64 | 2.34.1 | ||
| 65 | |||
diff --git a/meta/recipes-extended/shadow/files/CVE-2023-29383.patch b/meta/recipes-extended/shadow/files/CVE-2023-29383.patch new file mode 100644 index 0000000000..f53341d3fc --- /dev/null +++ b/meta/recipes-extended/shadow/files/CVE-2023-29383.patch | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | From e5905c4b84d4fb90aefcd96ee618411ebfac663d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: tomspiderlabs <128755403+tomspiderlabs@users.noreply.github.com> | ||
| 3 | Date: Thu, 23 Mar 2023 23:39:38 +0000 | ||
| 4 | Subject: [PATCH] Added control character check | ||
| 5 | |||
| 6 | Added control character check, returning -1 (to "err") if control characters are present. | ||
| 7 | |||
| 8 | CVE: CVE-2023-29383 | ||
| 9 | Upstream-Status: Backport | ||
| 10 | |||
| 11 | Reference to upstream: | ||
| 12 | https://github.com/shadow-maint/shadow/commit/e5905c4b84d4fb90aefcd96ee618411ebfac663d | ||
| 13 | |||
| 14 | Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> | ||
| 15 | --- | ||
| 16 | lib/fields.c | 11 +++++++---- | ||
| 17 | 1 file changed, 7 insertions(+), 4 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/lib/fields.c b/lib/fields.c | ||
| 20 | index 640be931..fb51b582 100644 | ||
| 21 | --- a/lib/fields.c | ||
| 22 | +++ b/lib/fields.c | ||
| 23 | @@ -21,9 +21,9 @@ | ||
| 24 | * | ||
| 25 | * The supplied field is scanned for non-printable and other illegal | ||
| 26 | * characters. | ||
| 27 | - * + -1 is returned if an illegal character is present. | ||
| 28 | - * + 1 is returned if no illegal characters are present, but the field | ||
| 29 | - * contains a non-printable character. | ||
| 30 | + * + -1 is returned if an illegal or control character is present. | ||
| 31 | + * + 1 is returned if no illegal or control characters are present, | ||
| 32 | + * but the field contains a non-printable character. | ||
| 33 | * + 0 is returned otherwise. | ||
| 34 | */ | ||
| 35 | int valid_field (const char *field, const char *illegal) | ||
| 36 | @@ -45,10 +45,13 @@ int valid_field (const char *field, const char *illegal) | ||
| 37 | } | ||
| 38 | |||
| 39 | if (0 == err) { | ||
| 40 | - /* Search if there are some non-printable characters */ | ||
| 41 | + /* Search if there are non-printable or control characters */ | ||
| 42 | for (cp = field; '\0' != *cp; cp++) { | ||
| 43 | if (!isprint (*cp)) { | ||
| 44 | err = 1; | ||
| 45 | + } | ||
| 46 | + if (!iscntrl (*cp)) { | ||
| 47 | + err = -1; | ||
| 48 | break; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | -- | ||
| 52 | 2.34.1 | ||
| 53 | |||
diff --git a/meta/recipes-extended/shadow/shadow.inc b/meta/recipes-extended/shadow/shadow.inc index 5106b95571..3c1dd2f98e 100644 --- a/meta/recipes-extended/shadow/shadow.inc +++ b/meta/recipes-extended/shadow/shadow.inc | |||
| @@ -16,6 +16,8 @@ SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/v${PV}/${BP} | |||
| 16 | ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \ | 16 | ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \ |
| 17 | file://shadow-relaxed-usernames.patch \ | 17 | file://shadow-relaxed-usernames.patch \ |
| 18 | file://useradd \ | 18 | file://useradd \ |
| 19 | file://CVE-2023-29383.patch \ | ||
| 20 | file://0001-Overhaul-valid_field.patch \ | ||
| 19 | " | 21 | " |
| 20 | 22 | ||
| 21 | SRC_URI:append:class-target = " \ | 23 | SRC_URI:append:class-target = " \ |
