From patchwork Fri Dec 24 18:04:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Famulari X-Patchwork-Id: 35635 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9BC4027BBEA; Fri, 24 Dec 2021 18:05:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D3F0B27BBE9 for ; Fri, 24 Dec 2021 18:05:37 +0000 (GMT) Received: from localhost ([::1]:51934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0owi-0007kW-T8 for patchwork@mira.cbaines.net; Fri, 24 Dec 2021 13:05:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0owA-0007kC-G6 for guix-patches@gnu.org; Fri, 24 Dec 2021 13:05:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:54699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n0owA-0001O0-7K for guix-patches@gnu.org; Fri, 24 Dec 2021 13:05:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n0owA-0004wX-0y for guix-patches@gnu.org; Fri, 24 Dec 2021 13:05:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#47979] [PATCH v5] gnu: binutils: Fix CVE-2021-45078. References: In-Reply-To: Resent-From: Leo Famulari Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 24 Dec 2021 18:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47979 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 47979@debbugs.gnu.org Received: via spool by 47979-submit@debbugs.gnu.org id=B47979.164036907218923 (code B ref 47979); Fri, 24 Dec 2021 18:05:01 +0000 Received: (at 47979) by debbugs.gnu.org; 24 Dec 2021 18:04:32 +0000 Received: from localhost ([127.0.0.1]:38004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0ovf-0004v6-Ji for submit@debbugs.gnu.org; Fri, 24 Dec 2021 13:04:32 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:54097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0ovb-0004uq-OG for 47979@debbugs.gnu.org; Fri, 24 Dec 2021 13:04:30 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A3587320148A; Fri, 24 Dec 2021 13:04:21 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 24 Dec 2021 13:04:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=RP/bYKTdaTZFcLpEDa7uhxv iiGzaaJrMSUmV7nT28a8=; b=zU00uGm+natB2cZcV4brDKW8ijP3oiTIj5Piy3E 1wWoRooEZithD1f3Grh8edRF8tNE00yaCPnL1/FYpSaJSb32NGj1clzFKdtjAAWU csWwnVmU5Ad177CfNg60torY6iiyZyemmqLGR09v0JprK8VevmrIWF12RNKew0au xvtk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=RP/bYKTdaTZFcLpED a7uhxviiGzaaJrMSUmV7nT28a8=; b=kDAvKLa5MjWpX7NudNlfIomjST6rwd5FK 5J8aM2ARdUgvncEA5r3Eq3NWhVM7rhYPGS6gXLd7p7lH9v26idSGo47yeZORlHDy g/kYEMwi+LCyprJ6DtJmi72xpALBaY9xEqzedq39rSYvcUvL4JuP4h/45L9jMjG8 EAqcow57BNAkTp4b7vmhDchzqyfVogjMUGS3rczIzWXdZtPb9Q3dItsHCqHt1dg1 oOfHU4kouRk+WG03jaOBmAvfKrd2+mI/L92EB0icTwEUTTpJ9A31r7bNLU6tQHCs 6LkLF4nuj2Mhg8xoDMh24D3v2Vpt8lyeQtgS9AVAL8u+PjdnijJsA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddutddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertd ertddtnecuhfhrohhmpefnvghoucfhrghmuhhlrghrihcuoehlvghosehfrghmuhhlrghr ihdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeekgeehfeefffeiuefhgeelieevveelie duveffteelgefhgeehhfekhedvtdegjeenucffohhmrghinhepmhhithhrvgdrohhrghdp shhouhhrtggvfigrrhgvrdhorhhgpdhtvgigihhnfhhordhnrghmvgenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlvghosehfrghmuhhlrghr ihdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for <47979@debbugs.gnu.org>; Fri, 24 Dec 2021 13:04:20 -0500 (EST) From: Leo Famulari Date: Fri, 24 Dec 2021 13:04:15 -0500 Message-Id: <802baa40ed72d1020c15226ec295187bbb1565be.1640369055.git.leo@famulari.name> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/patches/binutils-CVE-2021-45078.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/base.scm (binutils)[source]: Use it. --- gnu/local.mk | 1 + gnu/packages/base.scm | 3 +- .../patches/binutils-CVE-2021-45078.patch | 257 ++++++++++++++++++ 3 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/binutils-CVE-2021-45078.patch diff --git a/gnu/local.mk b/gnu/local.mk index aa0117a3f5..546b940eb6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -906,6 +906,7 @@ dist_patch_DATA = \ %D%/packages/patches/binutils-loongson-workaround.patch \ %D%/packages/patches/binutils-mingw-w64-timestamp.patch \ %D%/packages/patches/binutils-mingw-w64-deterministic.patch \ + %D%/packages/patches/binutils-CVE-2021-45078.patch \ %D%/packages/patches/blender-2.79-gcc8.patch \ %D%/packages/patches/blender-2.79-gcc9.patch \ %D%/packages/patches/blender-2.79-newer-ffmpeg.patch \ diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index 12e4de52d4..be6fbf608d 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -521,7 +521,8 @@ (define-public binutils (sha256 (base32 "1m3b2rdfv1dmdpd0bzg1hy7i8a2qng53szc6livyi3nh6101mz37")) (patches (search-patches "binutils-loongson-workaround.patch" - "binutils-2.37-file-descriptor-leak.patch")))) + "binutils-2.37-file-descriptor-leak.patch" + "binutils-CVE-2021-45078.patch")))) (build-system gnu-build-system) (arguments `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency diff --git a/gnu/packages/patches/binutils-CVE-2021-45078.patch b/gnu/packages/patches/binutils-CVE-2021-45078.patch new file mode 100644 index 0000000000..fca692bdb5 --- /dev/null +++ b/gnu/packages/patches/binutils-CVE-2021-45078.patch @@ -0,0 +1,257 @@ +Fix CVE-2021-45078 (incomplete fix for CVE-2018-12699): + +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45078 +https://sourceware.org/bugzilla/show_bug.cgi?id=28694 + +Patch copied from upstream source repository: + +https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=161e87d12167b1e36193385485c1f6ce92f74f02 + +From 161e87d12167b1e36193385485c1f6ce92f74f02 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Wed, 15 Dec 2021 11:48:42 +1030 +Subject: [PATCH] PR28694, Out-of-bounds write in stab_xcoff_builtin_type + + PR 28694 + * stabs.c (stab_xcoff_builtin_type): Make typenum unsigned. + Negate typenum earlier, simplifying bounds checking. Correct + off-by-one indexing. Adjust switch cases. +--- + binutils/stabs.c | 87 ++++++++++++++++++++++++------------------------ + 1 file changed, 43 insertions(+), 44 deletions(-) + +diff --git a/binutils/stabs.c b/binutils/stabs.c +index 274bfb0e7fa..83ee3ea5fa4 100644 +--- a/binutils/stabs.c ++++ b/binutils/stabs.c +@@ -202,7 +202,7 @@ static debug_type stab_find_type (void *, struct stab_handle *, const int *); + static bool stab_record_type + (void *, struct stab_handle *, const int *, debug_type); + static debug_type stab_xcoff_builtin_type +- (void *, struct stab_handle *, int); ++ (void *, struct stab_handle *, unsigned int); + static debug_type stab_find_tagged_type + (void *, struct stab_handle *, const char *, int, enum debug_type_kind); + static debug_type *stab_demangle_argtypes +@@ -3496,166 +3496,167 @@ stab_record_type (void *dhandle ATTRIBUTE_UNUSED, struct stab_handle *info, + + static debug_type + stab_xcoff_builtin_type (void *dhandle, struct stab_handle *info, +- int typenum) ++ unsigned int typenum) + { + debug_type rettype; + const char *name; + +- if (typenum >= 0 || typenum < -XCOFF_TYPE_COUNT) ++ typenum = -typenum - 1; ++ if (typenum >= XCOFF_TYPE_COUNT) + { +- fprintf (stderr, _("Unrecognized XCOFF type %d\n"), typenum); ++ fprintf (stderr, _("Unrecognized XCOFF type %d\n"), -typenum - 1); + return DEBUG_TYPE_NULL; + } +- if (info->xcoff_types[-typenum] != NULL) +- return info->xcoff_types[-typenum]; ++ if (info->xcoff_types[typenum] != NULL) ++ return info->xcoff_types[typenum]; + +- switch (-typenum) ++ switch (typenum) + { +- case 1: ++ case 0: + /* The size of this and all the other types are fixed, defined + by the debugging format. */ + name = "int"; + rettype = debug_make_int_type (dhandle, 4, false); + break; +- case 2: ++ case 1: + name = "char"; + rettype = debug_make_int_type (dhandle, 1, false); + break; +- case 3: ++ case 2: + name = "short"; + rettype = debug_make_int_type (dhandle, 2, false); + break; +- case 4: ++ case 3: + name = "long"; + rettype = debug_make_int_type (dhandle, 4, false); + break; +- case 5: ++ case 4: + name = "unsigned char"; + rettype = debug_make_int_type (dhandle, 1, true); + break; +- case 6: ++ case 5: + name = "signed char"; + rettype = debug_make_int_type (dhandle, 1, false); + break; +- case 7: ++ case 6: + name = "unsigned short"; + rettype = debug_make_int_type (dhandle, 2, true); + break; +- case 8: ++ case 7: + name = "unsigned int"; + rettype = debug_make_int_type (dhandle, 4, true); + break; +- case 9: ++ case 8: + name = "unsigned"; + rettype = debug_make_int_type (dhandle, 4, true); + break; +- case 10: ++ case 9: + name = "unsigned long"; + rettype = debug_make_int_type (dhandle, 4, true); + break; +- case 11: ++ case 10: + name = "void"; + rettype = debug_make_void_type (dhandle); + break; +- case 12: ++ case 11: + /* IEEE single precision (32 bit). */ + name = "float"; + rettype = debug_make_float_type (dhandle, 4); + break; +- case 13: ++ case 12: + /* IEEE double precision (64 bit). */ + name = "double"; + rettype = debug_make_float_type (dhandle, 8); + break; +- case 14: ++ case 13: + /* This is an IEEE double on the RS/6000, and different machines + with different sizes for "long double" should use different + negative type numbers. See stabs.texinfo. */ + name = "long double"; + rettype = debug_make_float_type (dhandle, 8); + break; +- case 15: ++ case 14: + name = "integer"; + rettype = debug_make_int_type (dhandle, 4, false); + break; +- case 16: ++ case 15: + name = "boolean"; + rettype = debug_make_bool_type (dhandle, 4); + break; +- case 17: ++ case 16: + name = "short real"; + rettype = debug_make_float_type (dhandle, 4); + break; +- case 18: ++ case 17: + name = "real"; + rettype = debug_make_float_type (dhandle, 8); + break; +- case 19: ++ case 18: + /* FIXME */ + name = "stringptr"; + rettype = NULL; + break; +- case 20: ++ case 19: + /* FIXME */ + name = "character"; + rettype = debug_make_int_type (dhandle, 1, true); + break; +- case 21: ++ case 20: + name = "logical*1"; + rettype = debug_make_bool_type (dhandle, 1); + break; +- case 22: ++ case 21: + name = "logical*2"; + rettype = debug_make_bool_type (dhandle, 2); + break; +- case 23: ++ case 22: + name = "logical*4"; + rettype = debug_make_bool_type (dhandle, 4); + break; +- case 24: ++ case 23: + name = "logical"; + rettype = debug_make_bool_type (dhandle, 4); + break; +- case 25: ++ case 24: + /* Complex type consisting of two IEEE single precision values. */ + name = "complex"; + rettype = debug_make_complex_type (dhandle, 8); + break; +- case 26: ++ case 25: + /* Complex type consisting of two IEEE double precision values. */ + name = "double complex"; + rettype = debug_make_complex_type (dhandle, 16); + break; +- case 27: ++ case 26: + name = "integer*1"; + rettype = debug_make_int_type (dhandle, 1, false); + break; +- case 28: ++ case 27: + name = "integer*2"; + rettype = debug_make_int_type (dhandle, 2, false); + break; +- case 29: ++ case 28: + name = "integer*4"; + rettype = debug_make_int_type (dhandle, 4, false); + break; +- case 30: ++ case 29: + /* FIXME */ + name = "wchar"; + rettype = debug_make_int_type (dhandle, 2, false); + break; +- case 31: ++ case 30: + name = "long long"; + rettype = debug_make_int_type (dhandle, 8, false); + break; +- case 32: ++ case 31: + name = "unsigned long long"; + rettype = debug_make_int_type (dhandle, 8, true); + break; +- case 33: ++ case 32: + name = "logical*8"; + rettype = debug_make_bool_type (dhandle, 8); + break; +- case 34: ++ case 33: + name = "integer*8"; + rettype = debug_make_int_type (dhandle, 8, false); + break; +@@ -3664,9 +3665,7 @@ stab_xcoff_builtin_type (void *dhandle, struct stab_handle *info, + } + + rettype = debug_name_type (dhandle, name, rettype); +- +- info->xcoff_types[-typenum] = rettype; +- ++ info->xcoff_types[typenum] = rettype; + return rettype; + } + +-- +2.27.0 +