Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934762AbbEOPPp (ORCPT ); Fri, 15 May 2015 11:15:45 -0400 Received: from mail-am1on0067.outbound.protection.outlook.com ([157.56.112.67]:31264 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754101AbbEOPPn (ORCPT ); Fri, 15 May 2015 11:15:43 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; Message-ID: <55560D8F.60704@ezchip.com> Date: Fri, 15 May 2015 11:15:27 -0400 From: Chris Metcalf User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Michael Ellerman CC: Linus Torvalds , Al Viro , Fabian Frederick , Randy Dunlap , Rickard Strandqvist , , Peter Zijlstra , "David S. Miller" , Frederic Weisbecker , Andrew Morton , Sam Ravnborg , Stephen Rothwell , "Theodore Ts'o" , Grant Likely , Linux Kernel Mailing List , Subject: Re: [PATCH 0/3] add new strscpy() API for string copy References: <1430409677-13284-1-git-send-email-cmetcalf@ezchip.com> <1431645018.2981.3.camel@ellerman.id.au> In-Reply-To: <1431645018.2981.3.camel@ellerman.id.au> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [12.216.194.146] X-ClientProxiedBy: BLUPR0101CA0006.prod.exchangelabs.com (25.163.116.144) To HE1PR02MB0777.eurprd02.prod.outlook.com (25.161.118.141) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0777; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:HE1PR02MB0777;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0777; X-Forefront-PRVS: 0577AD41D6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(6009001)(24454002)(377454003)(51704005)(377424004)(479174004)(77096005)(15975445007)(189998001)(5001960100002)(110136002)(83506001)(50986999)(54356999)(76176999)(65816999)(19580395003)(46102003)(47776003)(65956001)(66066001)(86362001)(23676002)(42186005)(87976001)(33656002)(77156002)(62966003)(36756003)(92566002)(40100003)(2950100001)(50466002)(122386002)(4001350100001)(21314002)(18886065003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR02MB0777;H:[10.7.0.41];FPR:;SPF:None;MLV:sfv;LANG:en; X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2015 15:15:37.2987 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR02MB0777 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2717 Lines: 60 On 05/14/2015 07:10 PM, Michael Ellerman wrote: > 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. Thanks. >> 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. Unfortunately, the strscpy patch series only changes the one previous user of the API, which is a tile-architecture-only driver piece, not particularly useful for anyone else for testing. The testing I did pulled strscpy() and word-at-a-time out into a separate, standalone userspace implementation, and tested it there, rather than doing tests through the syscall API like tools/testing/selftests. So I don't really see a way of committing my test framework, other than as a real Kconfig-enabled boot-time self-test or some such; I can certainly do that but I don't know how excited people are to have that additional level of source-code and Kconfig bloat. -- Chris Metcalf, EZChip Semiconductor http://www.ezchip.com -- 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/