Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6102939rwl; Mon, 9 Jan 2023 04:21:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXv68KkKmsc9qk5RxXQp5YRKm9iFSijcSLXtx1D4A1v0kRcB3bEPCN8spb9KQpHr7dnIwTve X-Received: by 2002:a17:902:ed0b:b0:193:2ed4:5627 with SMTP id b11-20020a170902ed0b00b001932ed45627mr3762842pld.27.1673266887606; Mon, 09 Jan 2023 04:21:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673266887; cv=none; d=google.com; s=arc-20160816; b=yTZhfjyGi7NGR2YjSDYwLeBkJTQor0hkqvpCmv8O3Q5LN8A3d+2CoQTk4WtD29BARn 56q4xWlEvqvISAvxtzURaWu6//ncFf/bGXo/rK/xdV1mp9519KYn21uDJuFn8J0dx7Cp jwQtGsQPSj6hJSgGwbCSmyQX6EvAKs3Mwo12VLIkpcA03rB9X2T/1BFbuEqZPFhfpAqO sRPVjKTIFgOqAk9D0u6P96Oya1hCEW6KTltGHZ4hmMIvFOng+8GfDTTpnksxjLgtYP89 kX0JwehLZsY8nlIstbPZh7wFLSSWBAFKs96qZEpT8D6THbLeX0SKfnbgO8fhJ2fYuLv9 NKKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=Cxh/T4jfjLRUXA8f3qIMDXWhhWv5vokZw4+DnXiq9tQ=; b=IsoUpABaTq/xQL7QP++DmcD93CzNxy/GAca8QsRpaSHYmIlPP4+blToTQappkmFjSZ /lxOEY9lVGI4XAK0BJ9W43whKdyqMFGvr+8K4qMyzmtu6E8L+4z7moT6IWNNl+GPc7JE I9KQg1+g4TADRKWo4nwPWmHfxLren9Xd/G4CAaiidfBQ2nTi/n5NdqOBVTuIYHkSrB4l CooD74e9byUmn9u2RUhjd8G655a+pe58P2as2x8As+0cIf/ynpXZromANmZOOrsHZkpy v5ZzYjD1lu2D20AgG+MdIi0o2Uzraz/pdMhegKR45T6UpQWJjUlqXt/vo7lx1j25dpFu n04Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a170903018500b00189d0fa14d6si10182666plg.13.2023.01.09.04.21.21; Mon, 09 Jan 2023 04:21:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234353AbjAILrS (ORCPT + 53 others); Mon, 9 Jan 2023 06:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234309AbjAILrC (ORCPT ); Mon, 9 Jan 2023 06:47:02 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56034D136 for ; Mon, 9 Jan 2023 03:47:01 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NrBxc0fcLz8QrkZ; Mon, 9 Jan 2023 19:47:00 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 309BkqU1093359; Mon, 9 Jan 2023 19:46:52 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Mon, 9 Jan 2023 19:46:55 +0800 (CST) Date: Mon, 9 Jan 2023 19:46:55 +0800 (CST) X-Zmail-TransId: 2b0363bbfeafffffffffb62deb1a X-Mailer: Zmail v1.0 Message-ID: <202301091946553770006@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIG1tL2RhbW9uL3N5c2ZzLXNjaGVtZXM6IHVzZSBzdHJzY3B5KCkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 309BkqU1093359 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63BBFEB4.000 by FangMail milter! X-FangMail-Envelope: 1673264820/4NrBxc0fcLz8QrkZ/63BBFEB4.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63BBFEB4.000/4NrBxc0fcLz8QrkZ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 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 --- 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