Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2551890rbb; Wed, 28 Feb 2024 05:38:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHmTktVSRWmD5IsrStSQEvDHz/14fQmzoHYWj+UJQbvjpzqumGnUkw5a9FVX0WeaiB8KvdEa7D1UJNmb8Sh0PBKjANd39tIRYgp6ykVQ== X-Google-Smtp-Source: AGHT+IGhkKFrsPjl9tDSBwFdVSnnDVyXAy5WDiCyyhNUxxUXAlxhdF4Muedt1MjDIjI4NHDW2vZg X-Received: by 2002:a05:6358:910a:b0:17b:5afc:2f04 with SMTP id q10-20020a056358910a00b0017b5afc2f04mr17609649rwq.15.1709127483407; Wed, 28 Feb 2024 05:38:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709127483; cv=pass; d=google.com; s=arc-20160816; b=M2ruyAUS3LgnQqE1yTo3JdtUmA5PvAbdHxFovHyVeN3KsI4QSMkGfDdh2BiiksWf+h uM0tDeH9b4Ir8ExOMXj+dOR3utThtJ0ucIRv1U348OAtqfZcf3voJN1DjTMW975mGQzg jF/DHpTwaAMn5j1zp0qYus5cTDhFFQ26/k1n67wlH7E7E54OepMqOB8Ls0ZANt8pgN8/ LhSEfBLvnZnAmCiTnmHrIThxAcblI7URQsE4UEHyP7muePitfQ494msPkc1E5+YAt778 xAEmSZnAv4Cc2sV1EHCNtx9GEpFb1qd0LaTxmLMj6WKgFwdC6f3Ug0nEp9M6jswv0Evu 8EPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=SxWgL4sElI1B0/tx2GgHOxLa5Q0889pBGSF5c/6AjSo=; fh=YEoJ0DFs9zEUXndLCucQl5Kk27tja6Lb4HuX4axw//Y=; b=rii5ONpqImc56k9qYEEPvlVXICHeLzzFclyMYqwRZ/5/mOvQYcoD2Jvoc4yAeACDxt OzZAI3aNBkFR76XT1P0APMUj+ffEpdIs4x9uKujMm7yJ2g0p0eCy8E1vz+YEDhyuySPv aANrJpRiJGnNeUxeo2V37Wka1tjGYYLP7U3j4woRcS9/bwDIr5E21egJKqoUtBunfQR3 S1YOVpdsXX3/CFWAMWka6O/+nQTzyP/5e8OydCcViNsP3PmFYRMibOb2iDXnU5F9fgWU dhI5M0YPe5bVgpW08yCy4C+yZ0tiWdRfwI5+dXp6uD4QU49xRDAXfYcQ3YA7G1Xw1LzC MQZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=APWU8rZM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-crypto+bounces-2359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t9-20020a05621421a900b0068f3f89e119si9606564qvc.101.2024.02.28.05.38.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 05:38:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=APWU8rZM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-crypto+bounces-2359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9899B1C223B9 for ; Wed, 28 Feb 2024 13:38:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F21C114C59D; Wed, 28 Feb 2024 13:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="APWU8rZM" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2536F14AD07; Wed, 28 Feb 2024 13:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709127477; cv=none; b=WGuor1psIn3zRHmH+kiBC4a/xvSjFqOdjWoFrISnf0Mga6Ae2DHEGRZgaUB+TpoGTYbC6vAlkR45as5Mk3v59o+A72lrcDr6vYr2Bk6ilZ7CrMTE2eZNQfS/dTs1huMatVCO8fQPpZclHgv/Jozl5cNgC9MHBkczZOtdiB8zrBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709127477; c=relaxed/simple; bh=ZrIig3MM4Z+bo/sqJIChCKj/Pje7QWTe1w+LQ7AYd7o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t3C5wje0ZBAMHkEDJvs/QqxLp7xj68H4AxADUJ30bVqnq/zL3/dwYb+lQ4TbFyRpFNJfLWwzOw7KwwSdLSUoX1A7HWEHru0gsSY9JOpKCY0hXAYR4ZMw0wqPWlPswHAHJOgW+0TMSo4ap3UvhrqzFGetE3VXcmMG5EFQROzjmw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=APWU8rZM; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d21cdbc85bso84619211fa.2; Wed, 28 Feb 2024 05:37:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709127474; x=1709732274; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=SxWgL4sElI1B0/tx2GgHOxLa5Q0889pBGSF5c/6AjSo=; b=APWU8rZMSd44oQK4cQwmDyD10Bati7iN4EYq2cFJf/V1ausdaVI0S7ZjOw/vMsnBRs vuaSteWGsJjghSjwCoFIInKuskyETVmni6mymCmQ+EkMnHpVJmHFB3VmbTGDQUH5uVdy LMyjr2UQddYb9ilHugc46oTLuxy+zyr3VgEnMH0XRl5vzQCEMB2WY1O4+dYVTtBn3oEQ 21qUR6CUxggCQaOU1EVUv6oR65e2On0zkmsdyv9nOe8CI1Mnq/xMd8rrK8hz/an8Iv57 ESdhQF/ktOUnINjlQTMdCG655Q/E4E35Y9WzLS393DhvubtnnRYYqJ3nEK/X9FGEQM50 S88w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709127474; x=1709732274; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SxWgL4sElI1B0/tx2GgHOxLa5Q0889pBGSF5c/6AjSo=; b=VY91DAgGmj4xy6cWHWafm6sXi3ULU/y5c2HQbT2VSny1jOzBRcEJ1mq1gy8QInJMh0 uJv8iRrqZ0E8a9tv66LVFhKrQDvUAiz0mKkBIdffJr6UUr+xuNwrOcyRS3Tugb94Xm6P /aYUZe4ccKuLG+Km4Bc1LVcq0zcRVQ32+DzHa2nDeJQ2bYCzOW9YWjqGHEGmn4DxoLrE PQIXvzrbDvEm8jteDyJSjmbiKDMRDUJ93w1/S9OHOOkrKTi7gVvqZg7hQIzGrP8YH91L m/3Op4tM0O4awnEXvOyQ/j1Xzd50YTh4AIfC6SETtDcrG/fsP9UOUYnrcG1qLqP6tf9P AOig== X-Forwarded-Encrypted: i=1; AJvYcCXAK/oy7uXDCa+avjP2kvJT4XQg4eEoz3fJ4OaHQtjI0EeDpgyw1XjhWm8u+7aWAsJ5XGTWmZumgC6nni2bApivkZAjkhuMsZtkdlshf7Me3xLtOXeX9+rCGy+7lZvPqWM5b7zoNe1I2iYT X-Gm-Message-State: AOJu0YyRLeHfdObX//0GiDh/Ik5rlTBNGFCD5q4YEW6M6hbAD+wZ0z/z VV6Oi74J+q8r6+33tS+y3y04BK8GwIZMSLs3rx2CBNicuOF9PcAf X-Received: by 2002:a05:6512:21b1:b0:512:f733:9eb with SMTP id c17-20020a05651221b100b00512f73309ebmr5671413lft.11.1709127473910; Wed, 28 Feb 2024 05:37:53 -0800 (PST) Received: from localhost ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id o11-20020ac2494b000000b005131434454bsm433619lfi.228.2024.02.28.05.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 05:37:53 -0800 (PST) Date: Wed, 28 Feb 2024 16:35:39 +0300 From: Andrey Skvortsov To: Herbert Xu Cc: Corentin Labbe , "David S. Miller" , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Corbet , Ovidiu Panait , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Arnaud Ferraris Subject: Re: [PATCH] crypto: rk3288 - Fix use after free in unprepare Message-ID: Mail-Followup-To: Andrey Skvortsov , Herbert Xu , Corentin Labbe , "David S. Miller" , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Corbet , Ovidiu Panait , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Arnaud Ferraris References: <20240226215358.555234-1-andrej.skvortzov@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On 24-02-28 17:13, Herbert Xu wrote: > The unprepare call must be carried out before the finalize call > as the latter can free the request. > > Fixes: c66c17a0f69b ("crypto: rk3288 - Remove prepare/unprepare request") > Reported-by: Andrey Skvortsov > Cc: > Signed-off-by: Herbert Xu > > diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c > index 1b13b4aa16ec..a235e6c300f1 100644 > --- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c > +++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c > @@ -332,12 +332,12 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq) > theend: > pm_runtime_put_autosuspend(rkc->dev); > > + rk_hash_unprepare(engine, breq); > + > local_bh_disable(); > crypto_finalize_hash_request(engine, breq, err); > local_bh_enable(); > > - rk_hash_unprepare(engine, breq); > - > return 0; > } > Thanks, that was quick. I had locally the same change. Reviewed-by: Andrey Skvortsov -- Best regards, Andrey Skvortsov