Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031014AbbD1Vss (ORCPT ); Tue, 28 Apr 2015 17:48:48 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:35843 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030787AbbD1Vsp (ORCPT ); Tue, 28 Apr 2015 17:48:45 -0400 MIME-Version: 1.0 In-Reply-To: <553FFDE9.9070700@ezchip.com> References: <20150428034859.GI889@ZenIV.linux.org.uk> <1363736428.511175.1430199310500.open-xchange@webmail.nmp.proximus.be> <20150428160523.GJ889@ZenIV.linux.org.uk> <553FE3F0.4060803@ezchip.com> <553FFDE9.9070700@ezchip.com> Date: Tue, 28 Apr 2015 14:48:45 -0700 X-Google-Sender-Auth: UpvZmiHj1AJ_98v8g27rDmLDTT0 Message-ID: Subject: Re: revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy" From: Linus Torvalds To: Chris Metcalf Cc: Al Viro , Fabian Frederick , Linux Kernel Mailing List , Randy Dunlap , Rickard Strandqvist Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1112 Lines: 25 On Tue, Apr 28, 2015 at 2:38 PM, Chris Metcalf wrote: > > To do that we'd probably want to provide a generic version that > just copied byte-by-byte, and encourage architecture variants > that were more efficient. Our generic "strncpy_from_user()" is actually fairly efficient, and reasonably portable. It almost has to be, since this is actually a much more common - and much more critical - load than any regular strncpy I know of in the kernel. I suspect you could take that lib/strncpy_from_user.c and massage it reasonably trivially to be a good function. That said, I can't think of a single strncpy (or strlcpy) in kernel space that is actually worth even optimizing for. They just don't tend to be in the critical path. So correctness is likely *much* more important than worrying about performance. Linus -- 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/