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]
Date:   Mon, 18 Mar 2019 14:37:39 -0400
From:   Waiman Long <longman@...hat.com>
To:     Manfred Spraul <manfred@...orfullife.com>,
        "Luis R. Rodriguez" <mcgrof@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jonathan Corbet <corbet@....net>
Cc:     linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-doc@...r.kernel.org, Al Viro <viro@...iv.linux.org.uk>,
        Matthew Wilcox <willy@...radead.org>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        Takashi Iwai <tiwai@...e.de>, Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH v12 3/3] ipc: Do cyclic id allocation with ipcmni_extend
 mode

On 03/17/2019 02:27 PM, Manfred Spraul wrote:
> Hi Waiman,
>
> On 2/28/19 7:47 PM, Waiman Long wrote:
>> For ipcmni_extend mode, the sequence number space is only 7 bits. So
>> the chance of id reuse is relatively high compared with the non-extended
>> mode.
>>
>> To alleviate this id reuse problem, the id allocation will be done
>> cyclically to cycle through all the 24-bit id space before wrapping
>> around when in ipcmni_extend mode. This may cause the use of more memory
>> in term of the number of xa_nodes allocated as well as potentially more
>> cachelines used as the xa_nodes may be spread more sparsely in this
>> case.
>>
>> There is probably a slight memory and performance cost in doing cyclic
>> id allocation. For applications that really need more than 32k unique
>> IPC
>> identifiers, this is a small price to pay to avoid the id reuse problem.
>
> Have you measured it?
>
> I have observed -3% for semop() for a 4 level radix tree compared to a
> 1-level radix tree, and I'm a bit reluctant to accept that.
> Especially as the percentage will increase if the syscall overhead
> goes down again (-> less spectre impact).
>

It is both Spectre (retpoline) and Meltdown (PTI). PTI is not needed in
AMD CPU and so you may see a bit higher slowdown.

> [...]
>
>> --- a/ipc/util.c
>> +++ b/ipc/util.c
>> @@ -221,7 +221,12 @@ static inline int ipc_idr_alloc(struct ipc_ids
>> *ids, struct kern_ipc_perm *new)
>>        */
>>         if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */
>> -        idx = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT);
>> +        if (ipc_mni_extended)
>> +            idx = idr_alloc_cyclic(&ids->ipcs_idr, new, 0, ipc_mni,
>> +                        GFP_NOWAIT);
>> +        else
>> +            idx = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT);
>> +
>>           if ((idx <= ids->last_idx) && (++ids->seq > IPCID_SEQ_MAX))
>>               ids->seq = 0;
>
> I don't like it that there are two different codepaths.
>
> Attached is a different proposal:
>
> Always use cyclic allocation, with some logic to minimize the
> additional radix tree levels.
>
> What do you think?

Your proposed patch look good. I saw that you use the max_idx to limit
radix tree nesting level which mitigate my concern of using more memory
and slower performance. I do have some minor comments about the patch in
a later email.

-Longman


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ