Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2548423pxj; Mon, 10 May 2021 05:41:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmG9FU6kzThe/UVnRw/du0K4OIo1WUUWUXwF0dB3dkF4rAzF5kzL86blUMmIRwOkaAUYat X-Received: by 2002:a92:da06:: with SMTP id z6mr22218923ilm.129.1620650488848; Mon, 10 May 2021 05:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650488; cv=none; d=google.com; s=arc-20160816; b=voJ+R8TPegxjZDyjRfGN1lPfWR1odwJH9llHTCGgzEf29tKWn2G40TPXriIapykpgC BKjZMJql6Nnhjd2T4qX41aFD4JKLpuCH+5CNKWcbP0nGAm4JCSREai6nVGmu0n4AbeQ7 azCSw+5SIPTccHocuS5WLyVqLJlIrJzsB8UR7RhoZQl3FnwWLnSJbtRt4QeZ228GgyIs YForvo612y9/HS6JLtKIsf33pddsDi98O2l7MEGx+BR5qKZYRU/sSZo+p1jFhAHj5sJW N8gEGVBzYhUoBffQtVnDSXaZhqy3vi2UrU/IBfRvHnY4HzWmi8+QaIh535cqTdwiDk+0 359A== 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=i01gDOzBd9jab4I7lP1eGzyqufTejEvbK8AzNPJsTYVNGfPf3Rd+d1ozKfMxbOvxtH HpDg4CPLgWBOLAdG4Oy7tNnh6jAp5kNjXPkog464mTakqP9CmiH4fXRPOdCJD4i9hSeR UADPr4wxDyiOaIbJ5Ml4Xdx8hB9V27ZkLWlpHIKElsMtSERlTOHDToIRt4XGjZdZVrK1 KMJlK+PYetLBV2IFzG8Pd5INymejTWp0jfnNbSicUpb++4c/r5PM0mt5Z59LTRdcoAvV /h/KAIWkiUcX/L2ZIyBT4q9Ejr6m3slDD+4d5sUL3MP380LiwN6DW7XSjxpbR5B4IZRi uf2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1ur+lvfO; 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 r13si16657051ilg.23.2021.05.10.05.41.16; Mon, 10 May 2021 05:41:28 -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=1ur+lvfO; 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 S1347233AbhEJMdp (ORCPT + 99 others); Mon, 10 May 2021 08:33:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232864AbhEJLLz (ORCPT ); Mon, 10 May 2021 07:11:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B95761939; Mon, 10 May 2021 11:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644980; bh=Ffa6ELVMUGV4itxSLyDqva7PAs6fN/3nhJDRmakNfq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ur+lvfOS8Jt9n/Wr7FUgChKvZSi5nWoDbiHWKsOikJ5C2zvjJNJd0KRzRJmNcfH8 veLgJsxJoyCtTIJEEtN5I6RzU/VI8fLG5PYLKXePw60jInmGET4lQ6EiUdeXIvqZ6u ly10n/m7YXLarlf01ASjkFpCJNUMbwVoxDQ/DWQs= 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.12 267/384] s390/archrandom: add parameter check for s390_arch_random_generate Date: Mon, 10 May 2021 12:20:56 +0200 Message-Id: <20210510102023.648939431@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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