Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2162793ioo; Mon, 23 May 2022 11:34:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGHkVFKZ+G5dzigM05NQk5gsMIMN6cGadH4SboHuRJbiwOtz3QVLB5RViijA71FLFa3Eju X-Received: by 2002:a65:6b8e:0:b0:39d:6760:1cd5 with SMTP id d14-20020a656b8e000000b0039d67601cd5mr21409046pgw.379.1653330882096; Mon, 23 May 2022 11:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330882; cv=none; d=google.com; s=arc-20160816; b=z9Ynxpq7QQLI5jl6GMhPl3Ff7+LDYjxfWn4n10r1Bk54CrggExjfs7SJumulVuDxRA 0vyXEzf+KfYaOM8VV8pPnzzmq3qO/5PHjYrPKp8em5As+rbYXOhfav2/wu6XF/0g6c/7 Yj9GXeT/WdkBvIa6inSUr7fnx96uFdSiOJWP3+WgcJH12ZaeJGSWbl0T9SSHAegk4hLv cGmhqGYM67qvMDZx36P/DL8RwBNpD/E9SEGEnmhRASQ1rmHUCGDRGGDzX1r0+UNiN5Xz h/jPhUzh/ldIGsZwdkV61RMJNPmUtdtHaRzJEyIk9Hzkj9mZhjAmoJM7801rt8KdNj5W JZkA== 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=WHu7FasyXt94+lHLecjiFWm98smkb4urQSYF3c2ZUdA=; b=vnRUZLDVP7DI23tl3k7ywKCAsyEtc4jA1F8ISlrz6ZUZGIcDnsRbXJbjsIdK4pqqw/ 962kdHMnDJFDoWAmfSCpQ4V6YWkc8ijw+a6THB00DpWjZB7rjM4knUZ1IXqQ4fi36hCj 1RzsRNOCPfwWPdECff65UzXP+Wdl6CTo9YgUpusSsbHF3NAX4D5VSgLvgKFc4TqD5Uyc 8Wy16GoN8uqSMFuAuikTZiQaY9Q4TcuE3ff84heRXCWRG8G28CKf+h+/CuFtIhzEH9zt oZbIsvt05asYz0TIuuPL8EacepS/nKAWR+iDQ30qRqs/9Ffbixwe4NIeEhxUsj8OXhm5 5BTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=piDoXEo5; 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 i9-20020a17090a138900b001d170dc834asi87035pja.62.2022.05.23.11.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:34:42 -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=piDoXEo5; 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 798081A4486; Mon, 23 May 2022 11:33:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239524AbiEWRNn (ORCPT + 99 others); Mon, 23 May 2022 13:13:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240193AbiEWRLq (ORCPT ); Mon, 23 May 2022 13:11:46 -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 532E310A4; Mon, 23 May 2022 10:11:14 -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 E1F8B61507; Mon, 23 May 2022 17:11:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7AB8C385A9; Mon, 23 May 2022 17:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325873; bh=VXtcAqn6/M6grVmBFWvrRlt1YfHPvmVTbARNuX4JhIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=piDoXEo54M1KxdfCC6Z4V6qNj+FfE4HrpG0CfvpZyqsIv4z1knTOexyqmArHbYQRq b2jh1XQIqGdPusiDj/jPPm1CLBxuLp3gaqlBhdtjOR0WgqBjQvF4Z0ak7s0iIVkQYk /Nl4oEyRdeRx06kPM2RF6xPV3eDchSZnbABf8Tjc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ondrej Mosnacek , Brian Masney , Herbert Xu Subject: [PATCH 4.19 15/44] crypto: qcom-rng - fix infinite loop on requests not multiple of WORD_SZ Date: Mon, 23 May 2022 19:04:59 +0200 Message-Id: <20220523165756.026136368@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165752.797318097@linuxfoundation.org> References: <20220523165752.797318097@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.6 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=unavailable 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: Ondrej Mosnacek commit 16287397ec5c08aa58db6acf7dbc55470d78087d upstream. The commit referenced in the Fixes tag removed the 'break' from the else branch in qcom_rng_read(), causing an infinite loop whenever 'max' is not a multiple of WORD_SZ. This can be reproduced e.g. by running: kcapi-rng -b 67 >/dev/null There are many ways to fix this without adding back the 'break', but they all seem more awkward than simply adding it back, so do just that. Tested on a machine with Qualcomm Amberwing processor. Fixes: a680b1832ced ("crypto: qcom-rng - ensure buffer for generate is completely filled") Cc: stable@vger.kernel.org Signed-off-by: Ondrej Mosnacek Reviewed-by: Brian Masney Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/qcom-rng.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/crypto/qcom-rng.c +++ b/drivers/crypto/qcom-rng.c @@ -64,6 +64,7 @@ static int qcom_rng_read(struct qcom_rng } else { /* copy only remaining bytes */ memcpy(data, &val, max - currsize); + break; } } while (currsize < max);