All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: billm@melbpc.org.au,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: correct fpu emulation access to ldt
Date: Thu, 6 Aug 2015 05:35:17 +0200	[thread overview]
Message-ID: <55C2D5F5.4010809@suse.com> (raw)
In-Reply-To: <CALCETrWqr_UV3vZNppjcaUDe+AKc3QcK4fDXMHbGc0Mk_QESog@mail.gmail.com>

On 08/05/2015 08:24 PM, Andy Lutomirski wrote:
> On Wed, Aug 5, 2015 at 2:11 AM, Juergen Gross <jgross@suse.com> wrote:
>> On 08/04/2015 08:01 PM, Andy Lutomirski wrote:
>>>
>>> On Tue, Aug 4, 2015 at 8:02 AM, Juergen Gross <jgross@suse.com> wrote:
>>>>
>>>> Commit 14805442532c ("x86/ldt: Make modify_ldt synchronous") introduced
>>>> a new struct ldt_struct anchored at mm->context.ldt.
>>>>
>>>> Adapt the x86 fpu emulation to use that new structure.
>>>>
>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>
>>>
>>> Whoops!
>>>
>>> Does this need to Cc: stable?
>>
>>
>> Probably.
>>
>>> Also, want to make it slightly fancier so we can drop the dependency
>>> on CONFIG_MODIFY_LDT_SYSCALL?
>>
>>
>> Something like:
>>
>> -#define LDT_DESCRIPTOR(s) (((struct desc_struct
>> *)current->mm->context.ldt)[(s) >> 3])
>> +#ifdef CONFIG_MODIFY_LDT_SYSCALL
>> +#define LDT_DESCRIPTOR(s) (current->mm->context.ldt->entries[(s) >> 3])
>> +#else
>> +#define LDT_DESCRIPTOR(s) ((struct desc_struct){{{ .a = 0, .b = 0, }}})
>
> Careful!  I think that akpm uses some ancient gcc version that can't
> compile that.  Maybe have a global empty segment somewhere that this
> returns, or just ifdef out the two call sites.
>
> Also, I don't believe this for a second:
>
> /* s is always from a cpu register, and the cpu does bounds checking
>   * during register load --> no further bounds checks needed */
> #define LDT_DESCRIPTOR(s)    (((struct desc_struct
> *)current->mm->context.ldt)[(s) >> 3])
>
> "What the comment means is that s always came from a cpu register at
> some point in the recent past (assuming that no lazy segment save
> logic is in effect) and we cross our fingers and hope that we never
> end up accessing out of bounds if the LDT isn't the same as it was at
> the time of the fault we're handling."
>
> Sigh.
>
> Maybe the best approach would be to replace LDT_DESCRIPTOR with an
> actual function that returns a struct desc_struct.  If it's out of
> bounds or !CONFIG_MODIFY_LDT_SYSCALL, return zeros.  Otherwise return
> the descriptor.

Yeah, seems to be the better approach.

>
>> +#endif
>>
>> I'd need to specify the corresponding patch as a prerequisite for stable
>> I guess? How to do this before it is picked by Linus?
>
> Send a v2 with Cc: stable@vger.kernel.org # [commit hash you depend
> on].  Presumably Ingo will pick it up, not Linus.

I know how to specify a prerequisite. I just wasn't sure which commit
hash to use, as up to now I've only one from your tree and I guessed
that wouldn't do it.


Juergen


  reply	other threads:[~2015-08-06  3:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-04 15:02 [PATCH] x86: correct fpu emulation access to ldt Juergen Gross
2015-08-04 18:01 ` Andy Lutomirski
2015-08-05  9:11   ` Juergen Gross
2015-08-05 18:24     ` Andy Lutomirski
2015-08-06  3:35       ` Juergen Gross [this message]
2015-08-06  4:38         ` Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55C2D5F5.4010809@suse.com \
    --to=jgross@suse.com \
    --cc=billm@melbpc.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.