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: <CALCETrX=uGdTfmz7KkbVyMKEmwcS4C43L5eNsy65VjNsL=7KJA@mail.gmail.com>
Date:	Fri, 24 Jul 2015 21:52:01 -0700
From:	Andy Lutomirski <luto@...capital.net>
To:	Borislav Petkov <bp@...en8.de>
Cc:	Andy Lutomirski <luto@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	"security@...nel.org" <security@...nel.org>,
	X86 ML <x86@...nel.org>, Sasha Levin <sasha.levin@...cle.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
	Boris Ostrovsky <boris.ostrovsky@...cle.com>,
	Andrew Cooper <andrew.cooper3@...rix.com>,
	Jan Beulich <jbeulich@...e.com>,
	xen-devel <xen-devel@...ts.xen.org>,
	stable <stable@...r.kernel.org>
Subject: Re: [PATCH v3 1/3] x86/ldt: Make modify_ldt synchronous

On Fri, Jul 24, 2015 at 8:29 AM, Borislav Petkov <bp@...en8.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ