lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210703152205.GC3004@amd>
Date:   Sat, 3 Jul 2021 17:22:05 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Sasha Levin <sashal@...nel.org>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Thomas Gleixner <tglx@...utronix.de>,
        Borislav Petkov <bp@...e.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 4.4 41/57] x86/fpu: Reset state for all signal restore
 failures

Hi!

> commit efa165504943f2128d50f63de0c02faf6dcceb0d upstream.
> 
> 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.
> 
> 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, void __user *buf_fx, int size)
>  		return 0;
>  	}
>  
> -	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);
>  
> -	if (!static_cpu_has(X86_FEATURE_FPU))
> -		return fpregs_soft_set(current, NULL,
> -				       0, sizeof(struct user_i387_ia32_struct),
> -				       NULL, buf) != 0;
> +	if (!static_cpu_has(X86_FEATURE_FPU)) {
> +		int ret = fpregs_soft_set(current, NULL, 0,
> +					  sizeof(struct user_i387_ia32_struct),
> +					  NULL, buf);
> +
> +		if (ret)
> +			fpu__clear(fpu);
> +
> +		return ret != 0;
> +	}

And this explicitely turns negative error into 1 for maximum confusion.

I don't see the same confusion in mainline.

Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ