Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp657414pxb; Tue, 5 Apr 2022 17:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdtltnQWwANb3y0Pnx1xoS0upoOjxSiplkc077ZGCioG6lIb/mzfq26/7w0YaLvNy9XnwT X-Received: by 2002:a17:903:22d1:b0:154:4cfa:2b12 with SMTP id y17-20020a17090322d100b001544cfa2b12mr5859350plg.47.1649205330292; Tue, 05 Apr 2022 17:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205330; cv=none; d=google.com; s=arc-20160816; b=w21xVwG/KvI7Q59W/xT3x3xWA5DwbZKiBWD+Vf/ATaYpU74MIyGh4XO/1KkWqfON5p ia8UI9me1E8Ay9i3OzNX94p+FdvR7NPdKT/15Hpb+kjpyAd5I+p++oYtUKFO4J2x1naJ zXU31tKMryie61PP88HInsCwd0MCDGYXsrYMf9WYJpUSfEmhQyc0cykwiUw3p03ytplG q4tat4iIUncwFQ779l7okNJVk8+6WnEd8vRq+JpBP1WKKxtkSu4EWbFsi/n4/6n7nTip ePfJN0CR7SzOipfDfh4niVW8Qzfx2U7DSw67jT0NyDjnwBQbqs7zYNJIkdUFZ2Lo24zl iQdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/Lx54BsLdNwzMrIyYU+nMCoUGJd5Mhc1JQmfBz5UvJk=; b=Q0VEpckWJ0iWJHVAL5o8/5qCZbZbZBwC2yroSKZsdEgb7h62PkTnVHIWrsfSPXWoor q1FgGy8kG7iT8myKJKAQ/neEiFWQFC+goZL4UVGLY180wI031aQc39cf/IPCF4TvSI9S C4/7RgmVXkglBoWF22svwidEdya+Qytbcx7n4IxzIOGyyacSHt0WyLd06JEweV6lVZ5l Qz+1LIARmjfC87uau0ltYTDNptevJG/3tiNaxbjnMRRdibnm3Gt3+v8dF7ZH+pz8JVly jeDDKrgokRa0oY8eNq31jmHkUhqRv8NC5XJcNP1pvdB2ptF1J4CtEAuY8HpZ92DPA31/ pC9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IIXIWI9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a056a0016c700b004fa939797d0si14515211pfc.2.2022.04.05.17.35.15; Tue, 05 Apr 2022 17:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IIXIWI9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389206AbiDEOoH (ORCPT + 99 others); Tue, 5 Apr 2022 10:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244217AbiDEJlK (ORCPT ); Tue, 5 Apr 2022 05:41:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585FABABBF; Tue, 5 Apr 2022 02:25:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E7EAB614F9; Tue, 5 Apr 2022 09:25:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2A8DC385A2; Tue, 5 Apr 2022 09:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150733; bh=+3MwjoxU6y9Rz147dPjjPlPFEMsY7UQgaL93494ZQ1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIXIWI9DACj5S9BKMbhGExJZ2KR+MRJz1DosANVPVdwhk3Y89bEi6bH81h4p+rPiZ yTnwlq28Ga0dgzbX7tx1gq72WW8+XfBhI4ZGXvK6neUuw/1kU0GaOaEYY01zwWIs+L wga/tPcaL7+ycGfZiGSyd+uLL+L8jZgJvuDiysg0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tadeusz Struk , Eric Biggers , Herbert Xu Subject: [PATCH 5.15 160/913] crypto: rsa-pkcs1pad - fix buffer overread in pkcs1pad_verify_complete() Date: Tue, 5 Apr 2022 09:20:22 +0200 Message-Id: <20220405070344.638617599@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers commit a24611ea356c7f3f0ec926da11b9482ac1f414fd upstream. Before checking whether the expected digest_info is present, we need to check that there are enough bytes remaining. Fixes: a49de377e051 ("crypto: Add hash param to pkcs1pad") Cc: # v4.6+ Cc: Tadeusz Struk Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/rsa-pkcs1pad.c | 2 ++ 1 file changed, 2 insertions(+) --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -476,6 +476,8 @@ static int pkcs1pad_verify_complete(stru pos++; if (digest_info) { + if (digest_info->size > dst_len - pos) + goto done; if (crypto_memneq(out_buf + pos, digest_info->data, digest_info->size)) goto done;