Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2120633ioo; Mon, 23 May 2022 10:30:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvdR9aOvP5lIqXnUTk1fvVtG/uFngQUXtL7mhLyEojmSuBUFXX0JhhxpC4Dzt/qulHNsu6 X-Received: by 2002:a05:6a00:2a03:b0:518:2d8d:8c46 with SMTP id ce3-20020a056a002a0300b005182d8d8c46mr24419949pfb.15.1653327011919; Mon, 23 May 2022 10:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653327011; cv=none; d=google.com; s=arc-20160816; b=ndEPv9uyOZFPPWUz+18pUd4abGO6+u6fzmBDXoO298VRzguIRSi9UbkFRfmMpk37Cq dqAHljchVSOaZxRTMdFMtY1S5a+Is2hL5PFoXYCtX9Lhv/FDf04qyoZ0oh4KFijY4uqM cUy3x3xphqpb3crv32n+IGBXlblL9uOhNivN+kveXHD86Cnyt5q9F9QF0g9QaMLj1a3x QN6rQlLZtebLk1gcbHX5fgIrnG88NCrvizHaXicCAwHJQANAZ24r6MBtTziCg3IIGeS+ eqD21eCgg26Unp+F+KUJDOQz0EtRqBCRLg6yqS7zCTIJ4a4TBAM7g5C4BahEcCKzjQ77 vjsg== 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=vjVUcc706w2gDtjmMQabWcGi3qN3tUCxRQIpvm3wX8yhZuj5LgF2aGO+Jfm4E+VyJA dG7Kye3Oww1ob7zPNpHzpfbEt3A+wKWQg9hEGtcEPssE9B/2c1H6ek4CVvUGp40f6kgM bh47/84iykXOBDrF8ECh2pkSxdYL8Foryb9me1rlg80FDL1DdiWM5BGiygxySnbZ0N76 VesJJVVZXsDhc9ib2hl7KfN0+vOsaFhZn7Q1HAtRgR5KlhlhruJMLQpioH/87QUQ4+dO AtAq2VHxi1AItOUq7XqChQBO2YGbTOk5EjAO1xyxWAtxtFv4lXBWuJOH4dIlPXnr9KHS mvfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WBBIo5eX; 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 x22-20020a056a00189600b0050a75ed9e6bsi14144477pfh.69.2022.05.23.10.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:30: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=WBBIo5eX; 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 9A98D8FFB6; Mon, 23 May 2022 10:29:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241020AbiEWR1r (ORCPT + 99 others); Mon, 23 May 2022 13:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240429AbiEWRRj (ORCPT ); Mon, 23 May 2022 13:17:39 -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 5C1B4532CA; Mon, 23 May 2022 10:17:31 -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 EA875614EB; Mon, 23 May 2022 17:15:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6E96C385A9; Mon, 23 May 2022 17:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326124; bh=VXtcAqn6/M6grVmBFWvrRlt1YfHPvmVTbARNuX4JhIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WBBIo5eXAdIoTob0jt8DTy/pFv4ATL0gSs/AUu14LG2ID3dxIyIbRc3Xhpv1GYLeJ +S4Y2wBxzmZRxixb8psOCG+9gijiqzcrqaqGebhxcoVMTLHTh+kzxaggYJ6PiswntF uGLOQ94oRYnZBRQdtWfyB8HSPoPx0lLE0GWu2jTY= 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 5.4 31/68] crypto: qcom-rng - fix infinite loop on requests not multiple of WORD_SZ Date: Mon, 23 May 2022 19:04:58 +0200 Message-Id: <20220523165807.782143812@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@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);