Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030194AbbENXKY (ORCPT ); Thu, 14 May 2015 19:10:24 -0400 Received: from ozlabs.org ([103.22.144.67]:33314 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbbENXKW (ORCPT ); Thu, 14 May 2015 19:10:22 -0400 Message-ID: <1431645018.2981.3.camel@ellerman.id.au> Subject: Re: [PATCH 0/3] add new strscpy() API for string copy From: Michael Ellerman To: Chris Metcalf Cc: Linus Torvalds , Al Viro , Fabian Frederick , Randy Dunlap , Rickard Strandqvist , gregkh@linuxfoundation.org, Peter Zijlstra , "David S. Miller" , Frederic Weisbecker , Andrew Morton , Sam Ravnborg , Stephen Rothwell , "Theodore Ts'o" , Grant Likely , Linux Kernel Mailing List , linux-arch@vger.kernel.org Date: Fri, 15 May 2015 09:10:18 +1000 In-Reply-To: <1430409677-13284-1-git-send-email-cmetcalf@ezchip.com> References: <1430409677-13284-1-git-send-email-cmetcalf@ezchip.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1913 Lines: 45 On Thu, 2015-04-30 at 12:01 -0400, Chris Metcalf wrote: > This patch series addresses limitations in strncpy() and strlcpy(); > both the old APIs are unpleasant, as Linus nicely summarized here > a couple of days ago: > > https://lkml.org/lkml/2015/4/28/570 > > and of course as other folks (Greg K-H and Linus again) said last year: > > https://plus.google.com/+gregkroahhartman/posts/1amLbuhWbh5 > > The proposed new API (strscpy(), for "s"afe string copy) has an > easy-to-use API for detecting buffer overflow, avoids unsafe truncation > by default, and isn't subject to thread-safety attacks like the current > strlcpy implementation. See patch 2/3 for more on why strscpy() is a > good thing. +1 on the concept. > To make strscpy() work more efficiently I did the minimum tweaking > necessary to allow to work on all architectures, > though of course individual maintainers can still make their versions > more efficient as needed. > > It's likely not necessary for per-architecture implementations of > strscpy() to be written, but I stuck with the standard __HAVE_ARCH_XXX > model just for consistency with the rest of . > > I tested the implementation with a simple user-space harness, so I > believe it is correct for the corner cases I could think of. In > particular I pairwise-tested all the unaligned values of source and > dest, and tested the restriction on src page-crossing at all > unaligned offsets approaching the page boundary. Can you please put that in tools/testing/selftests and merge it as part of the series? That way I can run the tests and be confident it works on powerpc. cheers -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/