From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5FDC3DA79 for ; Thu, 29 Dec 2022 20:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233793AbiL2UwB (ORCPT ); Thu, 29 Dec 2022 15:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbiL2Uv6 (ORCPT ); Thu, 29 Dec 2022 15:51:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F465A46F; Thu, 29 Dec 2022 12:51:57 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D2778B81A6B; Thu, 29 Dec 2022 20:51:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B315C433EF; Thu, 29 Dec 2022 20:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672347114; bh=KD2racd09CWRWSYr+UM/gcKzPGBLEtjPUw7DEP7BMe8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R4hGThcUk03B+WYSCPxwIBw0ihw3lsfONpfBnDtHms4NyrYWV4SgdZHDf5ivynAax SVuLmoFi1oYaNwIZNQN+WmLG5Cg5F31EjP/AhkYuW93n0mvRpbFPQDuzC2w341739h yNkgtcpFKLYWRRX3G+IbSaknI5sxghV6+Yusp1HfSaRxecvn4KoMqDvchbnE2uCRtp rCUFrU2p/D8um9uF0wyaIXoOjvf4y1Rn4Y3gEVfmogClblgifqZCT12gXDX87LiFkE W3pXbr3lj1dl4aCjjxBNMVCI6MyMeqOSKYwbW0UNBjuVjYDfIRlnQrsfce0Fgsuz/A 0B4FCpSRi+ouA== Date: Thu, 29 Dec 2022 12:51:52 -0800 From: Eric Biggers To: yang.yang29@zte.com.cn Cc: code@tyhicks.com, ira.weiny@intel.com, fmdefrancesco@gmail.com, ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Subject: Re: [PATCH linux-next] ecryptfs: crypto: use strscpy() to instead of strncpy() Message-ID: References: <202212280936545669762@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202212280936545669762@zte.com.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 28, 2022 at 09:36:54AM +0800, yang.yang29@zte.com.cn wrote: > From: Xu Panda > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL-terminated strings. Unlike strncpy(), strscpy() does not initialize the full destination array, so it is unsafe in some situations, such as initializing structures that are then copied to userspace or to disk. Please include an actual explanation for why this patch is correct. - Eric