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: <57665273-e56e-4b66-9dbd-003d592eb65d@www.fastmail.com>
Date:   Fri, 03 Dec 2021 11:39:19 +0000
From:   "Jiaxun Yang" <jiaxun.yang@...goat.com>
To:     "Dave Hansen" <dave.hansen@...el.com>, x86@...nel.org
Cc:     "Thomas Gleixner" <tglx@...utronix.de>,
        "Ingo Molnar" <mingo@...hat.com>, bp@...en8.de,
        dave.hansen@...ux.intel.com, hpa@...or.com,
        chang.seok.bae@...el.com, linux-kernel@...r.kernel.org,
        "Jiaxun Yang" <j.yang-87@....ed.ac.uk>
Subject: Re: [RFC PATCH 07/10] x86/fpu: Rellocate fpstate on save_fpregs_to_fpstate



在2021年12月3日十二月 上午12:44,Dave Hansen写道:
> On 12/2/21 4:36 PM, Jiaxun Yang wrote:
>> --- a/arch/x86/kernel/fpu/core.c
>> +++ b/arch/x86/kernel/fpu/core.c
>> @@ -112,6 +112,22 @@ static void update_avx_timestamp(struct fpu *fpu)
>>  		fpu->avx512_timestamp = jiffies;
>>  }
>>  
>> +/* Update xstate size if it more dynamic features are opted-in. */
>> +static inline void xstate_update_size(struct fpu *fpu)
>> +{
>> +	int err;
>> +	struct fpstate *fpstate = fpu->fpstate;
>> +	u64 fpsmask = fpstate->xfeatures;
>> +	u64 curmask = fpsmask | xfeatures_in_use();
>> +
>> +	if (fpu_state_size_dynamic()) {
>> +		if (fpsmask != curmask) {
>> +			err = fpstate_realloc(fpu, curmask);
>> +			WARN_ON_FPU(err);
>> +		}
>> +	}
>> +}
>> +
>>  /*
>>   * Save the FPU register state in fpu->fpstate->regs. The register state is
>>   * preserved.
>> @@ -129,6 +145,7 @@ static void update_avx_timestamp(struct fpu *fpu)
>>  void save_fpregs_to_fpstate(struct fpu *fpu)
>>  {
>>  	if (likely(use_xsave())) {
>> +		xstate_update_size(fpu);
>>  		os_xsave(fpu->fpstate);
>>  		update_avx_timestamp(fpu);
>>  		return;
>
> Have you considered what exactly happens when you hit that WARN_ON_FPU()
> which otherwise ignores the allocation error?  Have you considered what
> happens on the os_xsave() that follows it immediately?  How about what
> happens the next time this task runs after that failure?

Thank you for the catch.
This is a few questions that I don't have answer, so it's a RFC.

I thought it is unlikely to happen as kmalloc has emergency pool.
But in case it happens, I guess the best way to handle it is just
send SIGILL to corresponding user process or panic if it's kernel
fpu use?

Thanks.
-- 
- Jiaxun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ