From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751808AbbJJHsB (ORCPT ); Sat, 10 Oct 2015 03:48:01 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:34422 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751753AbbJJHr6 (ORCPT ); Sat, 10 Oct 2015 03:47:58 -0400 Date: Sat, 10 Oct 2015 09:47:54 +0200 From: Ingo Molnar To: Rasmus Villemoes Cc: Linus Torvalds , Chris Metcalf , open list , Peter Zijlstra , Thomas Gleixner , "H. Peter Anvin" , Borislav Petkov Subject: Re: [RFC 0/3] eliminate potential race in string() (was: [PATCH] string: Improve the generic strlcpy() implementation) Message-ID: <20151010074753.GB1336@gmail.com> References: <20151005112700.GA1096@gmail.com> <87h9m57xwa.fsf@rasmusvillemoes.dk> <20151006080346.GB11523@gmail.com> <8737xnbqtn.fsf@rasmusvillemoes.dk> <20151007071821.GD7837@gmail.com> <87y4ffuk0r.fsf@rasmusvillemoes.dk> <20151008084837.GA4729@gmail.com> <87vbagwjgc.fsf@rasmusvillemoes.dk> <87r3l4wgom.fsf_-_@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r3l4wgom.fsf_-_@rasmusvillemoes.dk> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Rasmus Villemoes wrote: > On Fri, Oct 09 2015, Rasmus Villemoes wrote: > > > It's hard not to agree with the overall "let's make it more robust if it > > can be done sanely+cheaply+cleanly". I was a bit skeptical about whether > > those three requirements could be met, since we'd have to do > > byte-by-byte traversal of the string, maybe-copying it to the output as > > we go along, but then right-alignment would require us to do a memmove, > > but not before we've done some complicated bookkeeping > > exercise. However, now that I read the source again, it seems that Al > > Viro already did that exercise when he added dentry(). So maybe it's > > doable without a net increase in LOC. > > Something like this. The net increase is because I added a > comment. Passes the new printf test suite, but I'm not sure that's > thorough enough yet - still, it's better than nothing. There's also this > small bonus: > > $ scripts/bloat-o-meter /tmp/vsprintf.o.{old,new} > add/remove: 1/0 grow/shrink: 0/2 up/down: 178/-245 (-67) > function old new delta > widen_string.isra - 178 +178 > string.isra 186 109 -77 > dentry_name.isra 358 190 -168 > > > Rasmus Villemoes (3): > lib/vsprintf.c: pull out padding code from dentry_name() > lib/vsprintf.c: move string() below widen_string() > lib/vsprintf.c: eliminate potential race in string() > > lib/vsprintf.c | 98 +++++++++++++++++++++++++++++++--------------------------- > 1 file changed, 52 insertions(+), 46 deletions(-) Looks good to me! Thanks, Ingo