Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6677898rwl; Mon, 9 Jan 2023 11:27:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvZHsCuq65Y4sqstYlkCP81diWBt4YgrI90S+nM1Ui8MCLs2fKJfCSMdthXbiGnlqVQ6Xl X-Received: by 2002:a17:90a:3b4c:b0:219:b8f5:5b68 with SMTP id t12-20020a17090a3b4c00b00219b8f55b68mr70289226pjf.43.1673292438418; Mon, 09 Jan 2023 11:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673292438; cv=none; d=google.com; s=arc-20160816; b=fIJ+vgIKPPz3/XtfQLnmX8cMdjyeXj7S+zzOZCNjjTdRchLKtAuUhQSLcgzFc/cVYm OqeGtsOMBpMsOu9D/x6JyQ6WIjmXICcdd6RHTJ42BCad9swYBrNyU3YrG4kkqM10Uf5S gUbWdYtl//ISyMf2lPhWezMpAuJ7zDcIn54lheSqBpjIYHGLkv15BEbiUUiLlvttFwdx QGYIehRWpx5KT7+wJtQsG3muz7qpyPPUmk3JvXptE1wo9HFTamwX7fLjE4/iowIlRZEq 9u9XTXH5jlcwLcH2HqfCTPsmpbf9LS+PAFqM4gnc3n/NEPIhxPns6fsj+PNqmB4jr5Jp ymJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8Y6EWm8R0UHPXhm0X/WKB274TniC72HXOsdghwIdvhc=; b=C3I1urMtpaPSnJGlp9+fP35l5zjcDDFEPlCxdHVoaUvPkznhHBsxZt90iH0/ynuieD nQfom67x0W9O1QSZIPeSDCxhduA+Nge1u3SzFBt24gd8ijQwKL37E1eDLlixqr5ZBOAv 9RiWkoPmqnvYtJD75I8jFZ+PWoEWMmM4kTUeMLD8nCMJNNo91qZO+R3G7/2eF3TpmuWH 4eRAI3afC7yvQITW8i9bzW1mNVrMrnR8PGiCLYvIOgxY6QjHe14unRYGuF3cRrrotwxE Xh30XNwa3HmEv+KFGDTxcBgslRtVOPLOGN1RhGY4L7eQG0522f2fgI6s7UVnVXvCl2nn Or4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ekvh4iIs; 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 nd10-20020a17090b4cca00b0022618cab553si13280466pjb.73.2023.01.09.11.27.11; Mon, 09 Jan 2023 11:27:18 -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=Ekvh4iIs; 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 S237333AbjAISe0 (ORCPT + 53 others); Mon, 9 Jan 2023 13:34:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237771AbjAISdO (ORCPT ); Mon, 9 Jan 2023 13:33:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB3317425 for ; Mon, 9 Jan 2023 10:30:30 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C9CCA61311 for ; Mon, 9 Jan 2023 18:30:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8720BC433EF; Mon, 9 Jan 2023 18:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673289029; bh=HQCfjExHsVNbVU5V07LRXzsNiZRcHQX4rgcNmgWNn+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ekvh4iIsqIQ6GVoHVm4thN3+73pRDwghhkwnJMdooRgauK2v8ypGCA8euo1Hdwuy+ odwUC+onI9Vz3U5pqKaxD7TfvgPVoStViH1Aj8MXlJAjPvHyAaMbCegJ/neqtzAkQX DC2nPYGcYA4MZG6QNROSn+xKL+5wn3d12jFlsNOZM9TKviXEiyDt9qj3/jAVYciPH9 rFu+UUDJMewoERsuNkRS9z7TcDyHXfCBrwI4XLHtz/8SnZk9u+JkSaEXUJWJqcRCtU tE/zEAmdovsr4vYJLvseGqVf1JKFK92T6sHu79sj3d9nIeSV2UZVKG2KkDFVfC5P1F Ft9kUMud2Qvdg== From: SeongJae Park To: yang.yang29@zte.com.cn Cc: sj@kernel.org, akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Subject: Re: [PATCH linux-next] mm/damon/sysfs-schemes: use strscpy() to instead of strncpy() Date: Mon, 9 Jan 2023 18:30:26 +0000 Message-Id: <20230109183026.157393-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <202301091946553770006@zte.com.cn> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hello Xu, Thank you for this patch. On Mon, 9 Jan 2023 19:46:55 +0800 (CST) wrote: > From: Xu Panda > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL-terminated strings. > > Signed-off-by: Xu Panda > Signed-off-by: Yang Yang Reviewed-by: SeongJae Park Thanks, SJ > --- > mm/damon/sysfs-schemes.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c > index f0dabe3e2dc0..86edca66aab1 100644 > --- a/mm/damon/sysfs-schemes.c > +++ b/mm/damon/sysfs-schemes.c > @@ -353,8 +353,7 @@ static ssize_t memcg_path_store(struct kobject *kobj, > if (!path) > return -ENOMEM; > > - strncpy(path, buf, count); > - path[count] = '\0'; > + strscpy(path, buf, count + 1); > filter->memcg_path = path; > return count; > } > -- > 2.15.2