From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D387C07E99 for ; Sat, 3 Jul 2021 15:22:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E4E96192E for ; Sat, 3 Jul 2021 15:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbhGCPYm (ORCPT ); Sat, 3 Jul 2021 11:24:42 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:39196 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbhGCPYl (ORCPT ); Sat, 3 Jul 2021 11:24:41 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id E7E0F1C0B81; Sat, 3 Jul 2021 17:22:06 +0200 (CEST) Date: Sat, 3 Jul 2021 17:22:05 +0200 From: Pavel Machek To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Greg Kroah-Hartman Subject: Re: [PATCH 4.4 41/57] x86/fpu: Reset state for all signal restore failures Message-ID: <20210703152205.GC3004@amd> References: <20210628144256.34524-1-sashal@kernel.org> <20210628144256.34524-42-sashal@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Pk6IbRAofICFmK5e" Content-Disposition: inline In-Reply-To: <20210628144256.34524-42-sashal@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Pk6IbRAofICFmK5e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > commit efa165504943f2128d50f63de0c02faf6dcceb0d upstream. >=20 > If access_ok() or fpregs_soft_set() fails in __fpu__restore_sig() then the > function just returns but does not clear the FPU state as it does for all > other fatal failures. >=20 > Clear the FPU state for these failures as well. That's quite a confusing calling convention, right? > +++ b/arch/x86/kernel/fpu/signal.c > @@ -262,15 +262,23 @@ static int __fpu__restore_sig(void __user *buf, voi= d __user *buf_fx, int size) > return 0; > } > =20 > - if (!access_ok(VERIFY_READ, buf, size)) > + if (!access_ok(VERIFY_READ, buf, size)) { > + fpu__clear(fpu); > return -EACCES; > + } This returns -errno on failure. > fpu__activate_curr(fpu); > =20 > - if (!static_cpu_has(X86_FEATURE_FPU)) > - return fpregs_soft_set(current, NULL, > - 0, sizeof(struct user_i387_ia32_struct), > - NULL, buf) !=3D 0; > + if (!static_cpu_has(X86_FEATURE_FPU)) { > + int ret =3D fpregs_soft_set(current, NULL, 0, > + sizeof(struct user_i387_ia32_struct), > + NULL, buf); > + > + if (ret) > + fpu__clear(fpu); > + > + return ret !=3D 0; > + } And this explicitely turns negative error into 1 for maximum confusion. I don't see the same confusion in mainline. Best regards, Pavel --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --Pk6IbRAofICFmK5e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmDggJ0ACgkQMOfwapXb+vILuwCfZgedwyD/ZOuDzetWeuyKpdCn 5H4AoJYYkAsv+IsY6ADwONrtiVJv54t3 =2R9/ -----END PGP SIGNATURE----- --Pk6IbRAofICFmK5e--