Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2467104pxj; Mon, 10 May 2021 03:48:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUX2Cc8g0zTmp8DcewFh6RDo74v4tAB48nQW34Y9DA3+z/9Lyqt5WiPF0JYogoT8Q9X0Ap X-Received: by 2002:a05:6402:7c7:: with SMTP id u7mr28461023edy.2.1620643705633; Mon, 10 May 2021 03:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643705; cv=none; d=google.com; s=arc-20160816; b=PzCCLOJrI6xzrurSnwOIVP7oirZJ1O8jSwlDly6YdaJ4smhcePII/Skf970UUEu5Pw 8R94pjTPYp4aP3PVc2iQ6RZLFK4PQZhY1Sp0xfbgAM4oonZxOvIxkg3QN+9QnJW7mhst Jqr3pE5gdSpAPPYx9pVxFmsEs+0bjq+LB/TUsU/yS31CF82fvRB10do0p+kjL/hTSTdT ar1idKBAXZA4oBhndULWXOekcDZY1F8upmcbzI/bNiAUNbdMoeCca796I43ehf6WPXnr Hdkk2Rg2lw0bSQlvYhR7Y2+sj24Gax1p2gfLH60czFctbTZUPyUfT+cAV/xoFd87oIqK mmyw== 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=F6aCbYY+3FazziiiR5tTwOPGaKyxrl69/Pau9R6hPlQ=; b=cLZ5QlvZZ/GKPJlMAEoJ5R5LapjQE+a7cCiENhMjkUZ83Gan/BSNdXTY0x2Eog4bC9 cYczqVm1ddMc5IRwjfT2Q4hJrvLr+xDtQ30PUrIGU2fLox1J0DZ26XrKAYvuzP6Z3fID 6sgWuPAieBGPesV+XAt7PfJFV3vyzgLpLtBhPecFDDRTZKo9pcYiVdGcDEMyxlLuHfri 7GLfnj7HqLEf/rjlLTrYt2Kv/DiFjnJPVkWo1UMYVNIFvAJi8+2LICYHkBE81pJe7CzS HL82ZZxAM5fCp7zb+agISmMizs0YIxMQsf4S5HfOTbSDR3OOpdbttquiCPZ2HNP+kDSG 2GBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kg5d94kX; 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 u6si12606242ejc.208.2021.05.10.03.48.02; Mon, 10 May 2021 03:48:25 -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=kg5d94kX; 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 S232921AbhEJKos (ORCPT + 99 others); Mon, 10 May 2021 06:44:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:41508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232260AbhEJKgM (ORCPT ); Mon, 10 May 2021 06:36:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADB6961943; Mon, 10 May 2021 10:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642553; bh=zdyythD21HvJgoFCj/9ADYkiuDf0zulSgc++zqebsM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kg5d94kXQd6aW4MXy1XRte2ktf8LD4cL7CeZf82lDAxIiFWDhVdeMPYOjJPkP+J64 UnnaEC8WwoFBnik6zlI1LIEFqFdzN/COLMvtfZsrgXRqMDqOT2evedFVIcQW0bZE4L jl7tToyAIRxK7E+vsZXugbdzAFGLeG8pptn3GXKQ= 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.4 124/184] s390/archrandom: add parameter check for s390_arch_random_generate Date: Mon, 10 May 2021 12:20:18 +0200 Message-Id: <20210510101954.238752805@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510101950.200777181@linuxfoundation.org> References: <20210510101950.200777181@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 dd95cdbd22ce..4cbb4b6d85a8 100644 --- a/arch/s390/crypto/arch_random.c +++ b/arch/s390/crypto/arch_random.c @@ -53,6 +53,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