Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3184569pxf; Sun, 21 Mar 2021 23:04:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYHk967v9xugX6+db3wV0nWCOwEzU/F1+8kWEniAr/38YMfvki3VQ1q89/IsFbrkF207vQ X-Received: by 2002:a17:906:4e17:: with SMTP id z23mr17605728eju.439.1616393046138; Sun, 21 Mar 2021 23:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616393046; cv=none; d=google.com; s=arc-20160816; b=lSo4BE9762WX49UlHID4aE0fXG7BDanUrBoa9sRxs3MKBGb0pWzP3p9yzJgdTan4AJ pcNApvxQ0UIVx21wyqzimSNJbRmlz84+NQbRg7B1abR0F/mfBqLHKOCHedhDIu5Z+eo3 b4EQHnusXXt54z1vmifYw3J0wSO/ncrX+QGM7tpFmlKIJccEBjOGl4Wuc1M358w3skpF vQB3SjnRG3fi/br5tGYzQeoYSPIUQX91NosA8ahngLMHEvGn7zMmRgMUYxQOu088srHX EeMaSnlsJmEw3SzjuqOa+d2kBAYTzgNnbwj38iDuZQ7iXaAbKFTAJ21pU+bMfpexkr7+ Xihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LpoqoYEadVEVwzUXGMiPZKx5DDyxFrFPESQCyxCF8tU=; b=N+wNIQyEawLKXhGTspzsChYVCsokVcdbixdh+Fjx0WSfOYUvV6O6aiG4b7qwYkV/4G SI6wHYM+1VmoKOSsl+mZQhUeIt5gFiE/yv66X9IYaK5KMRW635StaaT+PJlJx11AiIo8 H7vK7cHW84l5x2lsfcS/iGX3HbymEHbd9Vdjpuoq47804eeQTsbEL2686GtsGMT+ghHC I6T624s7z3/iOcvGbU7ch6Fl+Wm+qqA/k/frmq/izP/VfFQMETyPnsk5iBwJ2wEt7FhI 7PsgMlqARh6Cdok5H4ucYWa/tout0ia7Vi5DwIGOgWtUrbQUXllOwqWWPdXlL+wTOf9b RSWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ef48nPH3; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si11604670edj.210.2021.03.21.23.03.37; Sun, 21 Mar 2021 23:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@kernel.org header.s=k20201202 header.b=Ef48nPH3; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbhCVGAv (ORCPT + 99 others); Mon, 22 Mar 2021 02:00:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbhCVGAY (ORCPT ); Mon, 22 Mar 2021 02:00:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B741F61925; Mon, 22 Mar 2021 06:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616392823; bh=Da2kIHXdeLQLxHVtJ1X0RBS7P/w99Xfmpvej3S/icEo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ef48nPH3zvBkOLkb8veTf+jCHcnWBykU8Ac3RV5+FbxXDznhcvKjRUEjAopcfAi9G haCtYyjCzvhAtn3YvyQOx6Bu1g3AbngUwd6NpspUKciyvPfBuzajkHYrLWzUOz881O i4KPu6DF1CwvV0yffu/mwPdFA5eFZuZkRpNKZwcQXPMpuGVDgRsrIbPRyk2hEf5eAM aULf7xN3htptwMY4qm53AAxyNPINN1Wim2bk/nihZEqYWaeyXIPXQJDStDRNVmJQZ6 rtaifP/D4mLPNJsftTuYePga44YSQHv6Ru7TPDhBac3Ci8ClHOqSRhuiWu5iZ3YJIv ZNaN6f4pJqG6g== Date: Sun, 21 Mar 2021 23:00:09 -0700 From: Eric Biggers To: Dan Carpenter Cc: linux-crypto@vger.kernel.org, Neil Horman , Corentin Labbe , stable@vger.kernel.org Subject: Re: [PATCH] crypto: rng - fix crypto_rng_reset() refcounting when !CRYPTO_STATS Message-ID: References: <20210322050748.265604-1-ebiggers@kernel.org> <20210322054522.GC1667@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210322054522.GC1667@kadam> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Mar 22, 2021 at 08:45:22AM +0300, Dan Carpenter wrote: > On Sun, Mar 21, 2021 at 10:07:48PM -0700, Eric Biggers wrote: > > From: Eric Biggers > > > > crypto_stats_get() is a no-op when the kernel is compiled without > > CONFIG_CRYPTO_STATS, so pairing it with crypto_alg_put() unconditionally > > (as crypto_rng_reset() does) is wrong. > > > > Presumably the intention was that _get() and _put() should always pair. > It's really ugly and horrible that they don't. We could have > predicted bug like this would happen and will continue to happen until > the crypto_stats_get() is renamed. > Well, the crypto stats stuff has always been pretty broken, so I don't think people have looked at it too closely. Currently crypto_stats_get() pairs with one of the functions that tallies the statistics, such as crypto_stats_rng_seed() or crypto_stats_aead_encrypt(). What change are you suggesting, exactly? Maybe moving the conditional crypto_alg_put() into a new function crypto_stats_put() and moving it into the callers? Or do you think the functions should just be renamed to something like crypto_stats_begin() and crypto_stats_end_{rng_seed,aead_encrypt}()? Another issue is that a lot of operations (such as the rng one in question here) don't actually need the get/put at all because they are never asynchronous. I didn't aim to address that in my patch though... - Eric