Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2510702pxj; Mon, 10 May 2021 04:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaWk6rdUJHYF8FEQ/MqZkQ0hCQEq/g4e3RfwyC38FN6uBv0iU51orzl9w2RemwdMAz2LGl X-Received: by 2002:aa7:d40e:: with SMTP id z14mr23932352edq.73.1620647590010; Mon, 10 May 2021 04:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620647590; cv=none; d=google.com; s=arc-20160816; b=0nFAz2uZXAO9Wq0g29cMwKYfUNtlBwpvM/DC9ReF2NYipSKTVSEZxa6AcxSgo8uhsu 6ws41UlARxq9e7Cf7EYdinDIDATlEi2t68T37eh2P8zCYZFqANjHea7K5LtB7EWzCl7V bO1aKbaGPzZWQ0EfyiI1RLkWkZ0qIBxtlnPLqjcyXUtjpYV0Cz/Uli2DksN1lYQigRX3 qw833E52HD5aV8rjbE2MBe/+YRm9sOBfN5B3aIXjVxGJHusmZy9IaVpjwLd680Gexjx+ gToodWS3idn720Dil6dxVXNfxq29et0hDg1lPSyN2P5lTe8GPLqpgA8gqKCITux54eVU Qjmw== 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=HTDQFJxvUiKbLo0NWevy0iGB24NI8ko4IUnUp/sxP2g=; b=aWaOjIkYd+VUEkeEhax3EXlX9bnZJX7ePvwBtL2QEECMLACg2JYDK9L33bRoA1Tluz M5H75BXNg6x5yzhSS3rHp6aeFAR7DIepCGT6o+O048nnqibQC/5Teiy9OPAJbyE6Sn17 /nVv3u/vilcHEBz1b3z8qY0mBX25ros4wavmPKAopT4/YcIXSBio5RrzehSURvh+vczV 8pNxceq56EMd4vjsTrRs+bForskwyEuEKGsoC0IqQUYP6GQaGa2oIiI/QvMvt6MLakXo I0xR9RDwOxzE2jRj/i9d/9ScOTy9cw/UMNQDQBgi+dpOcxSJVURYjaD8f4vu585PUqoh TyUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pMXa+luC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pg9si12593297ejb.22.2021.05.10.04.52.42; Mon, 10 May 2021 04:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pMXa+luC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242603AbhEJLrW (ORCPT + 99 others); Mon, 10 May 2021 07:47:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:52164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233726AbhEJK7r (ORCPT ); Mon, 10 May 2021 06:59:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43EE361876; Mon, 10 May 2021 10:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643976; bh=Ffa6ELVMUGV4itxSLyDqva7PAs6fN/3nhJDRmakNfq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pMXa+luC1/eW6P6DFBBZ5hfhaozNc+Z8Pm7IP/Cj6z6jhTvOPIIJ0hYd7n1kLFm3m BN5j2m0jtue36DRGAiim8CLGVfjVcLPc3cZJjOSTkKOvCsnNy4cZUaVRlewYLJV24j 9oWYsSLpBibYD9VaHHpZBPOTb/LmmW/cQNZTwGfw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Schnelle , Harald Freudenberger , Heiko Carstens , Sasha Levin Subject: [PATCH 5.11 237/342] s390/archrandom: add parameter check for s390_arch_random_generate Date: Mon, 10 May 2021 12:20:27 +0200 Message-Id: <20210510102017.908200270@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Harald Freudenberger [ Upstream commit 28096067686c5a5cbd4c35b079749bd805df5010 ] A review of the code showed, that this function which is exposed within the whole kernel should do a parameter check for the amount of bytes requested. If this requested bytes is too high an unsigned int overflow could happen causing this function to try to memcpy a really big memory chunk. This is not a security issue as there are only two invocations of this function from arch/s390/include/asm/archrandom.h and both are not exposed to userland. Reported-by: Sven Schnelle Signed-off-by: Harald Freudenberger Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/crypto/arch_random.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/s390/crypto/arch_random.c b/arch/s390/crypto/arch_random.c index 7b947728d57e..56007c763902 100644 --- a/arch/s390/crypto/arch_random.c +++ b/arch/s390/crypto/arch_random.c @@ -54,6 +54,10 @@ static DECLARE_DELAYED_WORK(arch_rng_work, arch_rng_refill_buffer); bool s390_arch_random_generate(u8 *buf, unsigned int nbytes) { + /* max hunk is ARCH_RNG_BUF_SIZE */ + if (nbytes > ARCH_RNG_BUF_SIZE) + return false; + /* lock rng buffer */ if (!spin_trylock(&arch_rng_lock)) return false; -- 2.30.2