Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6453651rwl; Thu, 29 Dec 2022 13:11:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXu6JsT+2YgYzCrerP5g5oC3D98ArUbNJcrfReXwLLnFw+Nl+rHTCJ9qayCqboDwy3Vae1DE X-Received: by 2002:a17:907:7da1:b0:7c0:d6b6:1ee9 with SMTP id oz33-20020a1709077da100b007c0d6b61ee9mr30280599ejc.11.1672348303495; Thu, 29 Dec 2022 13:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672348303; cv=none; d=google.com; s=arc-20160816; b=YGGHHwgY9TVERpBptG+0w0EGhjHK6NgbxmmVlrmYm3iUhAWiNiXs2r5xMybuJ0wf9v rekxVJJW9JVafKR3MINYGfYIhzpfCVxHgaZ0xH4/3x5FI0x3ysXK2XDPlW8Nokv79TZZ OVGApgmTUXKKWr/bI0fpE7SFdRT0VQCRnSh/TvSmzfrPKi9QNsV7trfHMHv1f1ZcfqN5 l+Rpt/42oo1hKEnjMBwsqn5nr+v0o94W0GOe+WZ17XcTPanqtkY1ieBg7/G7bfMPtiy2 VHRS7OjiKkRP3QCTOqGP0fTjqBDaPImOmvGgbx1Gqr+pkeRD+aXUgaBBbMmwfy/+iz2v 33Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1pB3ddgZ7HBkSe2VRf6rc0I3cDcP6C80B9AbxJ5lq8g=; b=dTN99vBBSk9iiXyZUh0ASm2J8teNpOF91FWV5Vhc3BlpDnch/HlsuMSa6v7VA1rMd5 exsB7GutM8LVb4bALo1c8jcwsoAZXap1e8b0XazAZ9qNXgR3nt85EbflHJcNDiBjE8x0 RJ4nRSzLG91wZxpg692kJHGTlUVV0NpjwDenb1TH36G0TOAhL3Eyosu4dZ8U6wYKUeBk +C+GYD1qnn/FOwWGHmwVyKmvM1V12BIHg9LoI93hKrBLidLuly6V5lQsiwe1bA0ZJJPM QRIsKalbzNaiLkUOviZeUrmjSiReajZCanhtSZ0QYyjqNoaPwo6HbucMdObh1v3iplEG nk9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R4hGThcU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji19-20020a170907981300b007c157940720si16401931ejc.440.2022.12.29.13.11.25; Thu, 29 Dec 2022 13:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R4hGThcU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233908AbiL2UwA (ORCPT + 62 others); Thu, 29 Dec 2022 15:52:00 -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> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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