Skip to content

Commit abf0a63

Browse files
[AUTO-CHERRYPICK] [2.0] tar: Fix CVE-2022-48303 and CVE-2023-39804 - branch main (#11163)
Co-authored-by: KavyaSree2610 <92566732+KavyaSree2610@users.noreply.github.com>
1 parent cb6ef01 commit abf0a63

7 files changed

Lines changed: 100 additions & 8 deletions

File tree

SPECS/tar/CVE-2022-48303.patch

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From aaba852a19b5ed717a48e62baa277966cdbdcb05 Mon Sep 17 00:00:00 2001
2+
From: kavyasree <kkaitepalli@microsoft.com>
3+
Date: Tue, 19 Nov 2024 10:23:25 +0530
4+
Subject: [PATCH] Fix CVE-2022-48303
5+
6+
---
7+
src/list.c | 6 ++++++
8+
1 file changed, 6 insertions(+)
9+
10+
diff --git a/src/list.c b/src/list.c
11+
index d7ef441..20ae4ee 100644
12+
--- a/src/list.c
13+
+++ b/src/list.c
14+
@@ -888,6 +888,12 @@ from_header (char const *where0, size_t digs, char const *type,
15+
<< (CHAR_BIT * sizeof (uintmax_t)
16+
- LG_256 - (LG_256 - 2)));
17+
value = (*where++ & ((1 << (LG_256 - 2)) - 1)) - signbit;
18+
+ if (where == lim)
19+
+ {
20+
+ if (type && !silent)
21+
+ ERROR ((0, 0, _("Archive base-256 value is invalid")));
22+
+ return -1;
23+
+ }
24+
for (;;)
25+
{
26+
value = (value << LG_256) + (unsigned char) *where++;
27+
--
28+
2.34.1
29+

SPECS/tar/CVE-2023-39804.patch

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From eb012d7c582f2fd1921d7ddd94ae5b5b09a625d7 Mon Sep 17 00:00:00 2001
2+
From: kavyasree <kkaitepalli@microsoft.com>
3+
Date: Tue, 19 Nov 2024 13:00:38 +0530
4+
Subject: [PATCH] Fix CVE-2023-39804
5+
6+
---
7+
src/xheader.c | 17 +++++++++--------
8+
1 file changed, 9 insertions(+), 8 deletions(-)
9+
10+
diff --git a/src/xheader.c b/src/xheader.c
11+
index 229137e..078a12d 100644
12+
--- a/src/xheader.c
13+
+++ b/src/xheader.c
14+
@@ -638,11 +638,11 @@ static struct xhdr_tab const *
15+
locate_handler (char const *keyword)
16+
{
17+
struct xhdr_tab const *p;
18+
-
19+
for (p = xhdr_tab; p->keyword; p++)
20+
if (p->prefix)
21+
{
22+
- if (strncmp (p->keyword, keyword, strlen(p->keyword)) == 0)
23+
+ size_t kwlen = strlen (p->keyword);
24+
+ if (keyword[kwlen] == '.' && strncmp (p->keyword, keyword, kwlen) == 0)
25+
return p;
26+
}
27+
else
28+
@@ -1717,19 +1717,20 @@ xattr_decoder (struct tar_stat_info *st,
29+
char const *keyword, char const *arg, size_t size)
30+
{
31+
char *xstr, *xkey;
32+
-
33+
+
34+
/* copy keyword */
35+
- size_t klen_raw = strlen (keyword);
36+
- xkey = alloca (klen_raw + 1);
37+
- memcpy (xkey, keyword, klen_raw + 1) /* including null-terminating */;
38+
+ xkey = xstrdup (keyword);
39+
40+
/* copy value */
41+
- xstr = alloca (size + 1);
42+
+ xstr = xmalloc (size + 1);
43+
memcpy (xstr, arg, size + 1); /* separator included, for GNU tar '\n' */;
44+
45+
xattr_decode_keyword (xkey);
46+
47+
- xheader_xattr_add (st, xkey + strlen("SCHILY.xattr."), xstr, size);
48+
+ xheader_xattr_add (st, xkey + strlen ("SCHILY.xattr."), xstr, size);
49+
+
50+
+ free (xkey);
51+
+ free (xstr);
52+
}
53+
54+
static void
55+
--
56+
2.34.1
57+

SPECS/tar/tar.spec

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
Summary: Archiving program
22
Name: tar
33
Version: 1.34
4-
Release: 2%{?dist}
4+
Release: 3%{?dist}
55
License: GPLv3+
66
URL: https://www.gnu.org/software/tar
77
Group: Applications/System
88
Vendor: Microsoft Corporation
99
Distribution: Mariner
1010
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
11+
Patch0: CVE-2022-48303.patch
12+
Patch1: CVE-2023-39804.patch
1113

1214
%description
1315
Contains GNU archiving program
1416

1517
%prep
16-
%setup -q
18+
%autosetup -p1
1719
%build
1820
FORCE_UNSAFE_CONFIGURE=1 ./configure \
1921
--prefix=%{_prefix} \
@@ -43,6 +45,10 @@ make %{?_smp_mflags} check
4345
%{_mandir}/*/*
4446

4547
%changelog
48+
* Tue Nov 19 2024 Kavya Sree Kaitepalli <kkaitepalli@microsoft.com> - 1.34-3
49+
- Fix CVE-2022-48303 by patching
50+
- Fix CVE-2023-39804
51+
4652
* Wed Sep 20 2023 Jon Slobodzian <joslobo@microsoft.com> - 1.34-2
4753
- Recompile with stack-protection fixed gcc version (CVE-2023-4039)
4854

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ libcap-ng-devel-0.8.2-2.cm2.aarch64.rpm
6969
util-linux-2.37.4-9.cm2.aarch64.rpm
7070
util-linux-devel-2.37.4-9.cm2.aarch64.rpm
7171
util-linux-libs-2.37.4-9.cm2.aarch64.rpm
72-
tar-1.34-2.cm2.aarch64.rpm
72+
tar-1.34-3.cm2.aarch64.rpm
7373
xz-5.2.5-1.cm2.aarch64.rpm
7474
xz-devel-5.2.5-1.cm2.aarch64.rpm
7575
xz-lang-5.2.5-1.cm2.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ libcap-ng-devel-0.8.2-2.cm2.x86_64.rpm
6969
util-linux-2.37.4-9.cm2.x86_64.rpm
7070
util-linux-devel-2.37.4-9.cm2.x86_64.rpm
7171
util-linux-libs-2.37.4-9.cm2.x86_64.rpm
72-
tar-1.34-2.cm2.x86_64.rpm
72+
tar-1.34-3.cm2.x86_64.rpm
7373
xz-5.2.5-1.cm2.x86_64.rpm
7474
xz-devel-5.2.5-1.cm2.x86_64.rpm
7575
xz-lang-5.2.5-1.cm2.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ systemd-bootstrap-250.3-12.cm2.aarch64.rpm
558558
systemd-bootstrap-debuginfo-250.3-12.cm2.aarch64.rpm
559559
systemd-bootstrap-devel-250.3-12.cm2.aarch64.rpm
560560
systemd-bootstrap-rpm-macros-250.3-12.cm2.noarch.rpm
561-
tar-1.34-2.cm2.aarch64.rpm
562-
tar-debuginfo-1.34-2.cm2.aarch64.rpm
561+
tar-1.34-3.cm2.aarch64.rpm
562+
tar-debuginfo-1.34-3.cm2.aarch64.rpm
563563
tdnf-3.5.2-4.cm2.aarch64.rpm
564564
tdnf-autoupdate-3.5.2-4.cm2.aarch64.rpm
565565
tdnf-cli-libs-3.5.2-4.cm2.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ systemd-bootstrap-250.3-12.cm2.x86_64.rpm
564564
systemd-bootstrap-debuginfo-250.3-12.cm2.x86_64.rpm
565565
systemd-bootstrap-devel-250.3-12.cm2.x86_64.rpm
566566
systemd-bootstrap-rpm-macros-250.3-12.cm2.noarch.rpm
567-
tar-1.34-2.cm2.x86_64.rpm
568-
tar-debuginfo-1.34-2.cm2.x86_64.rpm
567+
tar-1.34-3.cm2.x86_64.rpm
568+
tar-debuginfo-1.34-3.cm2.x86_64.rpm
569569
tdnf-3.5.2-4.cm2.x86_64.rpm
570570
tdnf-autoupdate-3.5.2-4.cm2.x86_64.rpm
571571
tdnf-cli-libs-3.5.2-4.cm2.x86_64.rpm

0 commit comments

Comments
 (0)