From nobody Mon Nov 25 06:28:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1722326672; cv=none; d=zohomail.com; s=zohoarc; b=J1rOigDJcu9ABFEbT5nteSSzQn64uwD3j3cmfX6Q32ftmYy+obnrGf7SgszDu6RBHsLPUFVpnX3BI1n/xDOv37v4zqyvUU7xAofIStEsurvuLIw5vdtd3tpYMSvIsqk/kfNYOYHJ0WH+tbG2zuay2l90WG6+STlZluYW4dtlbrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722326672; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2h7HiiJXVeJ+i1ScVuKzptcWqQHcv9MhlmldDZ9sR80=; b=XhCmngdfkN5wsHFSC6bU4CK3iAHxwBRZbnmooDtOSF26w/y4ePj2yHjTkNo9uGXrZBZEfcFD67MP7JDmP9GgHpGiyG3MfZSf7UrJnucT6Yrxs8F3w+gk+CvtA4vVlQk2mpX4qeETnPF0E3ya9uyo6IAkgQ5mA3nf/JvrCYU03bE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1722326672377909.617904070987; Tue, 30 Jul 2024 01:04:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.767345.1177950 (Exim 4.92) (envelope-from ) id 1sYhqI-00013l-Ai; Tue, 30 Jul 2024 08:04:22 +0000 Received: by outflank-mailman (output) from mailman id 767345.1177950; Tue, 30 Jul 2024 08:04:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sYhqI-00013e-85; Tue, 30 Jul 2024 08:04:22 +0000 Received: by outflank-mailman (input) for mailman id 767345; Tue, 30 Jul 2024 08:04:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sYhqH-0000d6-9E for xen-devel@lists.xenproject.org; Tue, 30 Jul 2024 08:04:21 +0000 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [2607:f8b0:4864:20::72a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 528a467d-4e4a-11ef-8776-851b0ebba9a2; Tue, 30 Jul 2024 10:04:19 +0200 (CEST) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-7a1da036d35so265442085a.0 for ; Tue, 30 Jul 2024 01:04:19 -0700 (PDT) Received: from rossla-pc.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1f0153705sm259963885a.108.2024.07.30.01.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 01:04:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 528a467d-4e4a-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1722326658; x=1722931458; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2h7HiiJXVeJ+i1ScVuKzptcWqQHcv9MhlmldDZ9sR80=; b=etYe70o3jRmlzxfj4NIQIq7diIfMJV6mwgYeRbrM3Ka1NzWQl7QgwSiInQdg5CZnzy +40p78dqUbabOjs43r3WgUmAmNebPmsWHac6tnPOtttGKrQyUIbYpSEkdu2iuL3Oj8v7 FJUNiWYZ9X8h5zPLhI7/GJl1DKTPmZnmVSSkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722326658; x=1722931458; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2h7HiiJXVeJ+i1ScVuKzptcWqQHcv9MhlmldDZ9sR80=; b=Wa43UNrkIYhb8VyzGzPFaquFkbNTpt5TLgZiafC6rnh+du5oPJqPC4Tcy599OzwJIQ 2yF00NZv1nBZyb+O+KDKbwB5JDmEu/uj+GhGx4bbRGQUp4E2Cl/M53C/1v+fupz3UzY3 qA1xyRN40zJprmZa4gO1bo1jelqdL3xtXplCSNxn/P2TBQViZarsygkFPL53O5utVytT ZawC5mggTqUcanq3kg5HI7wXCTRBhDwHnm/m1EZZFnd3sDosPOshw+POScTXTXQX5oFF azm7H0azcaZECD51LakVBHFBXdq5MYyOQxytKOr6dNb42rSwkVgdjEAJe9qN15Cc72PC OCIw== X-Gm-Message-State: AOJu0YznvhCN2DxvJ+/pPZDwZ32OQTz8FySopg4amzcgMamfwSQVRIj8 UqAPvHRPxGu7m/1YPEmotEyh9kgkh0k4/iaLX8Iq4BRLf2+XkF9K5HEvFm4FatZvSY01hH8SEF0 = X-Google-Smtp-Source: AGHT+IFYzGTp4JN85y+xJB+bbDfT4w3vLxnCxFqldQRouVMaOxpVS0cEvsHMjaXmyq09TV+z7VmugA== X-Received: by 2002:a05:620a:45aa:b0:79f:38e:c015 with SMTP id af79cd13be357-7a1e52fc11emr1242934385a.62.1722326658280; Tue, 30 Jul 2024 01:04:18 -0700 (PDT) From: Ross Lagerwall To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini , Ross Lagerwall Subject: [PATCH] bunzip2: fix rare decompression failure Date: Tue, 30 Jul 2024 09:03:42 +0100 Message-ID: <20240730080342.1814470-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1722326672977116600 Content-Type: text/plain; charset="utf-8" The decompression code parses a huffman tree and counts the number of symbols for a given bit length. In rare cases, there may be >=3D 256 symbols with a given bit length, causing the unsigned char to overflow. This causes a decompression failure later when the code tries and fails to find the bit length for a given symbol. Since the maximum number of symbols is 258, use unsigned short instead. Signed-off-by: Ross Lagerwall Acked-by: Jan Beulich --- This issue was noticed in Linux decompressing initrds but since Xen has the same decompression code, it is possible the issue occurs here too. xen/common/bunzip2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/common/bunzip2.c b/xen/common/bunzip2.c index 4466426941e0..79f17162b138 100644 --- a/xen/common/bunzip2.c +++ b/xen/common/bunzip2.c @@ -221,7 +221,8 @@ static int __init get_next_block(struct bunzip_data *bd) RUNB) */ symCount =3D symTotal+2; for (j =3D 0; j < groupCount; j++) { - unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1]; + unsigned char length[MAX_SYMBOLS]; + unsigned short temp[MAX_HUFCODE_BITS+1]; int minLen, maxLen, pp; /* Read Huffman code lengths for each symbol. They're stored in a way similar to mtf; record a starting --=20 2.45.2