From patchwork Wed Aug 28 12:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13781230 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF6816A95E; Wed, 28 Aug 2024 12:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724847875; cv=none; b=K/Q4dJjjCNckk8RBy5UBV4S+hI4WhqFCLyy/475PKmqLzX5ui3eS/r44Gv6b2f+Ssls+4inyy7K6mF2GdiiTnH4efEslIT530FQbMwUHT9BQ1MoWUIt1w/xoPOqq3zvOI+Gy0/r73yKai0WPX7FPU5hyKbvIRLPZLIGRF4+SdJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724847875; c=relaxed/simple; bh=NgFJgLaUBynhaQWd86IXwRzo8RQEzeBXvB/2iU2Sgkk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XoMKPbf0jIgah1Bxtz1CRmcIi+RZn71QqOZKhHRd8nvFSouUhyd0I4iGcZjwGNndk8LAimON+CKmMyX4QzTwYXbYhPPaTZ8B3qv5d/EoloRxOB6EM/KvX+nObDTQmp0j4Dge3zM+C8PDng0u0VBRoz+Y2areLbU7Qi/d4bemT7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Wv3Sx5mdfzfZ2S; Wed, 28 Aug 2024 20:22:25 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id B8D99140118; Wed, 28 Aug 2024 20:24:29 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 28 Aug 2024 20:24:29 +0800 From: Hongbo Li To: , , , , , , , , CC: , , , Subject: [PATCH net-next v2 2/6] net/ipv6: replace deprecated strcpy with strscpy Date: Wed, 28 Aug 2024 20:32:20 +0800 Message-ID: <20240828123224.3697672-3-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828123224.3697672-1-lihongbo22@huawei.com> References: <20240828123224.3697672-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500022.china.huawei.com (7.185.36.66) X-Patchwork-Delegate: kuba@kernel.org The deprecated helper strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy() [1]. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1] Signed-off-by: Hongbo Li --- net/ipv6/ndisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 1e42e40fb379..aba94a348673 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1944,7 +1944,7 @@ static void ndisc_warn_deprecated_sysctl(const struct ctl_table *ctl, static char warncomm[TASK_COMM_LEN]; static int warned; if (strcmp(warncomm, current->comm) && warned < 5) { - strcpy(warncomm, current->comm); + strscpy(warncomm, current->comm); pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n", warncomm, func, dev_name, ctl->procname,