From patchwork Thu Jan 2 07:53:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: aszh07 X-Patchwork-Id: 54875 X-Patchwork-Delegate: steve@sakoman.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A215E77188 for ; Thu, 2 Jan 2025 07:53:56 +0000 (UTC) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mx.groups.io with SMTP id smtpd.web11.4076.1735804435208721999 for ; Wed, 01 Jan 2025 23:53:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dq5GlN2l; spf=pass (domain: gmail.com, ip: 209.85.216.42, mailfrom: mail2szahir@gmail.com) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2ee9a780de4so11247815a91.3 for ; Wed, 01 Jan 2025 23:53:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735804434; x=1736409234; darn=lists.openembedded.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GoqbhKjRMDYemaamog5wLKe4dWUi6juvUmiR5UEo0w0=; b=dq5GlN2lgQQMi0+rq44TYxYf5IvYrKnadTyePruWFW4aEJxTIU+nlgXyrrKZ7XKCj7 bAei7CXzySZUaIJ2g3HsCYNO0RNHXAjv5ngFKKdSM1s8ZVMXtfVBwg28WOU01Gl9rEdF Lk9CN6f6BM7McQfgnfJrGzMpWXoLAcqfR1Vj/A8+D41k2XTxiKihKpwCTlqPYa3CsS5K 5r+RdxixJmNQmYBzdt9YkUC29no/uinVLb/PIwy/ejevGj7Om8PUEYnGMFgHTaT9sSwI /X43OdIHqkMiT3r9ijNtZMPX3+vhU/KY4MRzFAI4O+8d0FVaeV6Y6KThyrNkmkKW2KMD ibNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735804434; x=1736409234; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GoqbhKjRMDYemaamog5wLKe4dWUi6juvUmiR5UEo0w0=; b=Jwxge0ZRK94m3F8htlnQ790+p8fsLjcbB1+Z7vPZD3MTZTim3KUwYawmmnh9hycDmi 3m0pVrvhK++eiVivj6EAlxLVXQGoC2DAQD/0yMbuznF2eGC3+wrAEfuZ0eij4PKIDHlh dRyOPhZ7KeRFbeUDAxeF5Pnn7EjXaH92di7MGdwmXL+q269LrbxAs4ulWROnIdB9YnBO wihEJ/6Pht1mMjy5ShEsbbQVDijqawBwHb6YQKMyDbiY/19+VbCofCQEWCJDIxP6z79X n0dtTvoZ+/UKz15k+7etmLRlPAziXth0j9vVjGKWZ9M7D9nz7ajtvmvvens+do+8pfB+ k2bg== X-Gm-Message-State: AOJu0YzDhY2+cGJ5hRFCI+2xLffv/20V5en/7KN71TFJ3Iv/Oxxw8EmN 6UFpjqdAkS/7dl+XNYUTPTGSG9Uee97KoNwWBun78MHgDRp1gX1zIo8Bcg== X-Gm-Gg: ASbGncumSQqH9xCDJQe3oQQYuKBuYBvkBeHvWjOxTYDVbnkLdyyhXeIs225hYKAFRCi KhsgkvNcNy9yogmOeVXHdvqEWdzfvl5Z+UzgdjfoTOY7sFVQ+vOLf4uDVcJWDbheumQaw5K9Li4 k8wXAJQw77DJ2NjUxfzr4sK/zxjqSsz5vGHyaGfphODtSauZMEhsAI7D9vg2GBT6d4TqAt7qkMb kAT0whUlGNaAhHrf3NCvMe1EHqP4bavcr8SLzQJW5h17TvMuiYtgA0A8zIDkpq86N3xFpvojVs= X-Google-Smtp-Source: AGHT+IF3+dIPcT3e+Oy1uX5CtOqsJyEKFeRl1elYGGihCBscUZNgRPzwyuzVdDNAe0v7JlP4iwuRsg== X-Received: by 2002:a17:90b:2c84:b0:2ee:bbe0:98c6 with SMTP id 98e67ed59e1d1-2f452dfcb28mr73342768a91.8.1735804434305; Wed, 01 Jan 2025 23:53:54 -0800 (PST) Received: from localhost.localdomain ([2405:201:e02e:c09b:a838:214c:8b21:28ef]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ed62d9f1sm27492742a91.20.2025.01.01.23.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jan 2025 23:53:53 -0800 (PST) From: aszh07 To: openembedded-core@lists.openembedded.org, nikhilr5@kpit.com Cc: Nitin Wankhade Subject: [OE-core][scarthgap][PATCH] libarchive: Fix CVE-2024-20696 Date: Thu, 2 Jan 2025 13:23:41 +0530 Message-Id: <20250102075341.29355-1-mail2szahir@gmail.com> X-Mailer: git-send-email 2.17.1 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 02 Jan 2025 07:53:56 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/209255 Add Patch file to fix CVE-2024-20696 CVE: CVE-2024-20696 Signed-off-by: Nitin Wankhade Signed-off-by: Nikhil R --- .../libarchive/CVE-2024-20696.patch | 115 ++++++++++++++++++ .../libarchive/libarchive_3.7.4.bb | 3 +- 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/libarchive/libarchive/CVE-2024-20696.patch diff --git a/meta/recipes-extended/libarchive/libarchive/CVE-2024-20696.patch b/meta/recipes-extended/libarchive/libarchive/CVE-2024-20696.patch new file mode 100644 index 0000000000..e55d58d37b --- /dev/null +++ b/meta/recipes-extended/libarchive/libarchive/CVE-2024-20696.patch @@ -0,0 +1,115 @@ +From eac15e252010c1189a5c0f461364dbe2cd2a68b1 Mon Sep 17 00:00:00 2001 +From: "Dustin L. Howett" +Date: Thu, 9 May 2024 18:59:17 -0500 +Subject: [PATCH] rar4 reader: protect copy_from_lzss_window_to_unp() (#2172) + +copy_from_lzss_window_to_unp unnecessarily took an `int` parameter where +both of its callers were holding a `size_t`. + +A lzss opcode chain could be constructed that resulted in a negative +copy length, which when passed into memcpy would result in a very, very +large positive number. + +Switching copy_from_lzss_window_to_unp to take a `size_t` allows it to +properly bounds-check length. + +In addition, this patch also ensures that `length` is not itself larger +than the destination buffer. + +CVE: CVE-2024-20696 +Upstream-Status: Backport [https://github.com/libarchive/libarchive/commit/eac15e252010c1189a5c0f461364dbe2cd2a68b1] + +Signed-off-by: Nitin Wankhade +--- + +--- a/libarchive/archive_read_support_format_rar.c 2024-04-26 14:52:59.000000000 +0530 ++++ b/libarchive/archive_read_support_format_rar.c 2024-12-12 07:35:33.287412704 +0530 +@@ -432,7 +432,7 @@ static int make_table_recurse(struct arc + struct huffman_table_entry *, int, int); + static int expand(struct archive_read *, int64_t *); + static int copy_from_lzss_window_to_unp(struct archive_read *, const void **, +- int64_t, int); ++ int64_t, size_t); + static const void *rar_read_ahead(struct archive_read *, size_t, ssize_t *); + static int parse_filter(struct archive_read *, const uint8_t *, uint16_t, + uint8_t); +@@ -2060,7 +2060,7 @@ read_data_compressed(struct archive_read + bs = rar->unp_buffer_size - rar->unp_offset; + else + bs = (size_t)rar->bytes_uncopied; +- ret = copy_from_lzss_window_to_unp(a, buff, rar->offset, (int)bs); ++ ret = copy_from_lzss_window_to_unp(a, buff, rar->offset, bs); + if (ret != ARCHIVE_OK) + return (ret); + rar->offset += bs; +@@ -2213,7 +2213,7 @@ read_data_compressed(struct archive_read + bs = rar->unp_buffer_size - rar->unp_offset; + else + bs = (size_t)rar->bytes_uncopied; +- ret = copy_from_lzss_window_to_unp(a, buff, rar->offset, (int)bs); ++ ret = copy_from_lzss_window_to_unp(a, buff, rar->offset, bs); + if (ret != ARCHIVE_OK) + return (ret); + rar->offset += bs; +@@ -3094,11 +3094,16 @@ copy_from_lzss_window(struct archive_rea + + static int + copy_from_lzss_window_to_unp(struct archive_read *a, const void **buffer, +- int64_t startpos, int length) ++ int64_t startpos, size_t length) + { + int windowoffs, firstpart; + struct rar *rar = (struct rar *)(a->format->data); + ++ if (length > rar->unp_buffer_size) ++ { ++ goto fatal; ++ } ++ + if (!rar->unp_buffer) + { + if ((rar->unp_buffer = malloc(rar->unp_buffer_size)) == NULL) +@@ -3110,17 +3115,17 @@ copy_from_lzss_window_to_unp(struct arch + } + + windowoffs = lzss_offset_for_position(&rar->lzss, startpos); +- if(windowoffs + length <= lzss_size(&rar->lzss)) { ++ if(windowoffs + length <= (size_t)lzss_size(&rar->lzss)) { + memcpy(&rar->unp_buffer[rar->unp_offset], &rar->lzss.window[windowoffs], + length); +- } else if (length <= lzss_size(&rar->lzss)) { ++ } else if (length <= (size_t)lzss_size(&rar->lzss)) { + firstpart = lzss_size(&rar->lzss) - windowoffs; + if (firstpart < 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Bad RAR file data"); + return (ARCHIVE_FATAL); + } +- if (firstpart < length) { ++ if ((size_t)firstpart < length) { + memcpy(&rar->unp_buffer[rar->unp_offset], + &rar->lzss.window[windowoffs], firstpart); + memcpy(&rar->unp_buffer[rar->unp_offset + firstpart], +@@ -3130,9 +3135,7 @@ copy_from_lzss_window_to_unp(struct arch + &rar->lzss.window[windowoffs], length); + } + } else { +- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, +- "Bad RAR file data"); +- return (ARCHIVE_FATAL); ++ goto fatal; + } + rar->unp_offset += length; + if (rar->unp_offset >= rar->unp_buffer_size) +@@ -3140,6 +3143,11 @@ copy_from_lzss_window_to_unp(struct arch + else + *buffer = NULL; + return (ARCHIVE_OK); ++ ++fatal: ++ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, ++ "Bad RAR file data"); ++ return (ARCHIVE_FATAL); + } + + static const void * diff --git a/meta/recipes-extended/libarchive/libarchive_3.7.4.bb b/meta/recipes-extended/libarchive/libarchive_3.7.4.bb index 6e406611f9..80b2e49eac 100644 --- a/meta/recipes-extended/libarchive/libarchive_3.7.4.bb +++ b/meta/recipes-extended/libarchive/libarchive_3.7.4.bb @@ -33,7 +33,8 @@ SRC_URI = "http://libarchive.org/downloads/libarchive-${PV}.tar.gz" SRC_URI += "file://configurehack.patch \ file://CVE-2024-48957.patch \ file://CVE-2024-48958.patch \ - " + file://CVE-2024-20696.patch \ + " UPSTREAM_CHECK_URI = "http://libarchive.org/" SRC_URI[sha256sum] = "7875d49596286055b52439ed42f044bd8ad426aa4cc5aabd96bfe7abb971d5e8"