Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp755349pxb; Tue, 5 Apr 2022 21:56:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3fGTob/Hf54OUk3MdvIbj68PPQVopDPXyQX7zc3QbutUeBEM4hkwtFJ2/ay2YPstyfRs/ X-Received: by 2002:a17:902:da8f:b0:156:3b3c:b128 with SMTP id j15-20020a170902da8f00b001563b3cb128mr7159096plx.50.1649220971246; Tue, 05 Apr 2022 21:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649220971; cv=none; d=google.com; s=arc-20160816; b=weT8XOXNZdGPSYUD8VsHQEjuNciWhw2Lx4NBXr9m8ndU1EJXTLRtXQXDC5Wtgpm8H8 e/qi3FLjzoXa9GB+Q7Df9EZw0HWtyVzovyjcz3YLwkbp6uef580yfNeMt/Yx+PtKue6i NrD/5ST9ENXSV0TUJ+Rss1p5ge9fmDguewZOknDTqxwM5J9YKprpOsbQmSsTH25yqO8e jpC5rjSn0LWMsazjF//Y6NsAAOyU/M0p/HlIlswROuw5OnG6nq7gclKfc0B8UxauGfUm aldVHv+7w9eUuQfs79pHso6RHb9d/ABi2WWAp12RTymr3DTMpnlyOsneKu0sTotRTgvS 9SPQ== 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=bhEQ5orcmGVyLfUNx7jaSK4GXZt/SxKLAM07hDUNk1Q=; b=QcXWMigbCyPlixPGhv3CmHbs2s5pdHl9St3dZLHoPw+juJr+5B/Pb/zxDesQuGwna7 RybdlQWuzkQeCvfHf0nn5Y0JDRugHyCXjxXKpuLz7jiRxP6mSWfPtqnciJQugCnTIHE0 vz7bN3g6T2gixCPffiMjTZEQ+6JvUn6wsUiVMnUHEKfz8BEooDb78P/DH3y6lXQKs49B lYy896IwaSRGmqFd0areM4fXkxTnIEBZzAbxSFrZdJpMsLoaiYX27O7VAu6HnckvxgRQ /EvHWSddq/Nf3UJMbLzhl4IoiI6xUC/Dl8SQE8yYEeorbJ5dqSwfelidey0lsbgWYLIS hesw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LNQpXYzu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f31-20020a63101f000000b003816043ee23si15237391pgl.24.2022.04.05.21.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 21:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LNQpXYzu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B7FF2DE927; Tue, 5 Apr 2022 20:16:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233041AbiDEH4q (ORCPT + 99 others); Tue, 5 Apr 2022 03:56:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233576AbiDEHsA (ORCPT ); Tue, 5 Apr 2022 03:48:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1A026C; Tue, 5 Apr 2022 00:46:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id B83F8B81B9C; Tue, 5 Apr 2022 07:45:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F29EC340EE; Tue, 5 Apr 2022 07:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144757; bh=C/750eIEw2xnKQ7Z3W6sdUklRUAe3atwbovg2TFjKWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNQpXYzuVRDemEUOQqomLbTiGsTbX6dia6nCxjbD9euckWwcredTRce5d8L8Gq1ww yC+vqByKxqg13K9n3/smWQ2OhTLZW1mPhfqh+o5Huf+eEAqesBQVYoqOeu8gmE83+I dBAwc3EDljW9dASPd6zOhZhNo5O88owMsvT/UZ5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Herbert Xu Subject: [PATCH 5.17 0160/1126] crypto: rsa-pkcs1pad - only allow with rsa Date: Tue, 5 Apr 2022 09:15:07 +0200 Message-Id: <20220405070412.287396986@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 9b30430ea356f237945e52f8a3a42158877bd5a9 upstream. The pkcs1pad template can be instantiated with an arbitrary akcipher algorithm, which doesn't make sense; it is specifically an RSA padding scheme. Make it check that the underlying algorithm really is RSA. Fixes: 3d5b1ecdea6f ("crypto: rsa - RSA padding algorithm") Cc: # v4.5+ Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/rsa-pkcs1pad.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -621,6 +621,11 @@ static int pkcs1pad_create(struct crypto rsa_alg = crypto_spawn_akcipher_alg(&ctx->spawn); + if (strcmp(rsa_alg->base.cra_name, "rsa") != 0) { + err = -EINVAL; + goto err_free_inst; + } + err = -ENAMETOOLONG; hash_name = crypto_attr_alg_name(tb[2]); if (IS_ERR(hash_name)) {