xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Borislav Petkov <bp@alien8.de>
Cc: "security@kernel.org" <security@kernel.org>,
	Jan Beulich <jbeulich@suse.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	X86 ML <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	xen-devel <xen-devel@lists.xen.org>,
	stable <stable@vger.kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	Sasha Levin <sasha.levin@oracle.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH v3 1/3] x86/ldt: Make modify_ldt synchronous
Date: Fri, 24 Jul 2015 21:52:01 -0700	[thread overview]
Message-ID: <CALCETrX=uGdTfmz7KkbVyMKEmwcS4C43L5eNsy65VjNsL=7KJA__45040.6492491767$1437800039$gmane$org@mail.gmail.com> (raw)
In-Reply-To: <20150724152955.GC21441@nazgul.tnic>

On Fri, Jul 24, 2015 at 8:29 AM, Borislav Petkov <bp@alien8.de> wrote:
> Let it stick out:
>
>         if (!cpumask_equal(mm_cpumask(current_mm), cpumask_of(smp_processor_id())))
>                 smp_call_function(flush_ldt, current_mm, 1);

I see your wide terminal and raise you a complete rewrite of that
function.  Sigh, why did I assume the old code was the right way to do
it?

>>  #endif
>> -     }
>> -     if (oldsize) {
>> -             paravirt_free_ldt(oldldt, oldsize);
>> -             if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE)
>> -                     vfree(oldldt);
>> -             else
>> -                     put_page(virt_to_page(oldldt));
>> -     }
>> -     return 0;
>> +     preempt_enable();
>>  }
>>
>> -static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
>> +static void free_ldt_struct(struct ldt_struct *ldt)
>>  {
>> -     int err = alloc_ldt(new, old->size, 0);
>> -     int i;
>> -
>> -     if (err < 0)
>> -             return err;
>> -
>> -     for (i = 0; i < old->size; i++)
>> -             write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
>> -     return 0;
>> +     if (unlikely(ldt)) {
>
> Save an indentation level:
>
>         int alloc_size;
>
>         if (!ldt)
>                 return;
>
>         alloc_size = sizeof(struct ldt_struct) + ldt->size * LDT_ENTRY_SIZE;
>

Hah¸ we both missed it.  This is wrong.  (Fix your backport!)

>         ...
>
>> +             paravirt_free_ldt(ldt->entries, ldt->size);
>> +             if (alloc_size > PAGE_SIZE)
>> +                     vfree(ldt->entries);
>> +             else
>> +                     put_page(virt_to_page(ldt->entries));

I'm not sure this is correct, so I changed it to something obviously
correct (kmalloc/kfree).

>>
>> -     fill_ldt(&ldt, &ldt_info);
>> -     if (oldmode)
>> -             ldt.avl = 0;
>> +     if (old_ldt) {
>> +             memcpy(new_ldt->entries, old_ldt->entries,
>> +                    oldsize * LDT_ENTRY_SIZE);
>> +     }
>
> Single if-statement doesn't need {} and you don't absolutely need to
> keep 80cols. Just let it stick out.

You read too many of Linus' comments about using wider terminals :)

--Andy

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2015-07-25  4:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1437592883.git.luto@kernel.org>
2015-07-22 19:23 ` [PATCH v3 1/3] x86/ldt: Make modify_ldt synchronous Andy Lutomirski
2015-07-22 19:23 ` [PATCH v3 2/3] x86/ldt: Make modify_ldt optional Andy Lutomirski
2015-07-22 19:23 ` [PATCH v3 3/3] selftests/x86, x86/ldt: Add a selftest for modify_ldt Andy Lutomirski
     [not found] ` <7bfde005b84a90a83bf668a320c7d4ad1b940065.1437592883.git.luto@kernel.org>
2015-07-23  7:13   ` [PATCH v3 2/3] x86/ldt: Make modify_ldt optional Jan Beulich
2015-07-23 10:24   ` Willy Tarreau
     [not found]   ` <20150723102434.GA2929@1wt.eu>
2015-07-23 23:36     ` Kees Cook
     [not found]     ` <CAGXu5j+yEWLuxJ9JUGyN7BxME+iOVXfpFgrZ-_2WXUn6A=0dVg@mail.gmail.com>
2015-07-23 23:40       ` Andy Lutomirski
     [not found]       ` <CALCETrVvfA+_N_tU2LUwvh+2Q_4AExbQkSgW1C4tESAvhY+4Dg@mail.gmail.com>
2015-07-23 23:58         ` Willy Tarreau
     [not found]         ` <20150723235805.GA3191@1wt.eu>
2015-07-24  0:09           ` Kees Cook
     [not found]           ` <CAGXu5jJNfMvvdr0q17nBz+HiEJuFa7Kvo=ZPAnb4E7So4W0QOA@mail.gmail.com>
2015-07-24  7:24             ` Willy Tarreau
     [not found]             ` <20150724072451.GB3293@1wt.eu>
2015-07-24  7:48               ` Willy Tarreau
     [not found] ` <049fdbab8ae2ecac1c8b40ecd558e9df45ccd5d3.1437592883.git.luto@kernel.org>
2015-07-22 22:20   ` [PATCH v3 1/3] x86/ldt: Make modify_ldt synchronous Boris Ostrovsky
2015-07-24  6:37   ` Borislav Petkov
2015-07-24 15:29   ` Borislav Petkov
     [not found]   ` <55B01745.4010702@oracle.com>
2015-07-25  4:13     ` Boris Ostrovsky
     [not found]     ` <55B30CE3.2010902@oracle.com>
2015-07-25  4:58       ` Andy Lutomirski
     [not found]   ` <20150724152955.GC21441@nazgul.tnic>
2015-07-25  4:52     ` Andy Lutomirski [this message]
     [not found]     ` <CALCETrX=uGdTfmz7KkbVyMKEmwcS4C43L5eNsy65VjNsL=7KJA@mail.gmail.com>
2015-07-25  8:37       ` Borislav Petkov

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='CALCETrX=uGdTfmz7KkbVyMKEmwcS4C43L5eNsy65VjNsL=7KJA__45040.6492491767$1437800039$gmane$org@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=jbeulich@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sasha.levin@oracle.com \
    --cc=security@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xen.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).