From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6787283FDF; Tue, 26 Aug 2025 11:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756207037; cv=none; b=Sfy6UhY8fvq0Yd1hz/VrYoYHkRmxzU42HdgeerNwMG4wFTqBl99fCOOibWuQZurdsv0S60GI0+V59vxwzhaU8UhwI/6SXqq37n8NrE3VyAYdDYpHTxer1I8ZAz91cl7EQKsgSI2oZ1Do/vUpMOR9IPi8MoF+K83ki7vI4w8ifwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756207037; c=relaxed/simple; bh=5lZoCaNl6N+RmmVkpE6MAK2Qevg4699JeABKrONUNV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DKUHrfZtGsawHFYRo8aIQHJ9mJJF6+ucfez1SpkuYl/m7aqsMno4BCgxY8JOT6wlDNdQ8NSCNIWFyV8vFvhYB2MELjaCp8cpS9h1Pa9lAFYHSJdivyi9B7nwERiJ57MDJT/Bj9xlqVmLaQ0PDqygyx//pSLPm3GUOAcuD4GOgts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xCsQo3Ut; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xCsQo3Ut" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6715EC4CEF1; Tue, 26 Aug 2025 11:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756207037; bh=5lZoCaNl6N+RmmVkpE6MAK2Qevg4699JeABKrONUNV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xCsQo3UtS8geheAMjKaeuzw4+EC6TU9+fCq8xMXUiwUPYvWwOPouq74gKYZrzMx9x 2sOhqZstRYnoI8LEkPeG3Sj8QI34kN7uUBCCx9N5LIWHsdX/20E4wV+eNzI2xYagGZ FIjNhlobfnmmWAMxG6O72Q83k+X9kzdA9gt9Q208= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Biggers , Herbert Xu Subject: [PATCH 6.16 027/457] crypto: x86/aegis - Fix sleeping when disallowed on PREEMPT_RT Date: Tue, 26 Aug 2025 13:05:11 +0200 Message-ID: <20250826110938.006909528@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110937.289866482@linuxfoundation.org> References: <20250826110937.289866482@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit c7f49dadfcdf27e1f747442e874e9baa52ab7674 upstream. skcipher_walk_done() can call kfree(), which takes a spinlock, which makes it incorrect to call while preemption is disabled on PREEMPT_RT. Therefore, end the kernel-mode FPU section before calling skcipher_walk_done(), and restart it afterwards. Moreover, pass atomic=false to skcipher_walk_aead_encrypt() instead of atomic=true. The point of atomic=true was to make skcipher_walk_done() safe to call while in a kernel-mode FPU section, but that does not actually work. So just use the usual atomic=false. Fixes: 1d373d4e8e15 ("crypto: x86 - Add optimized AEGIS implementations") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/x86/crypto/aegis128-aesni-glue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/arch/x86/crypto/aegis128-aesni-glue.c +++ b/arch/x86/crypto/aegis128-aesni-glue.c @@ -119,7 +119,9 @@ crypto_aegis128_aesni_process_crypt(stru walk->dst.virt.addr, round_down(walk->nbytes, AEGIS128_BLOCK_SIZE)); + kernel_fpu_end(); skcipher_walk_done(walk, walk->nbytes % AEGIS128_BLOCK_SIZE); + kernel_fpu_begin(); } if (walk->nbytes) { @@ -131,7 +133,9 @@ crypto_aegis128_aesni_process_crypt(stru aegis128_aesni_dec_tail(state, walk->src.virt.addr, walk->dst.virt.addr, walk->nbytes); + kernel_fpu_end(); skcipher_walk_done(walk, 0); + kernel_fpu_begin(); } } @@ -176,9 +180,9 @@ crypto_aegis128_aesni_crypt(struct aead_ struct aegis_state state; if (enc) - skcipher_walk_aead_encrypt(&walk, req, true); + skcipher_walk_aead_encrypt(&walk, req, false); else - skcipher_walk_aead_decrypt(&walk, req, true); + skcipher_walk_aead_decrypt(&walk, req, false); kernel_fpu_begin();