From patchwork Wed Aug 28 03:03:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13780367 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4C5CC54749 for ; Wed, 28 Aug 2024 03:04:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3777C6B009B; Tue, 27 Aug 2024 23:04:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 327F46B009C; Tue, 27 Aug 2024 23:04:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 216956B009D; Tue, 27 Aug 2024 23:04:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 031976B009B for ; Tue, 27 Aug 2024 23:04:36 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B37F141C13 for ; Wed, 28 Aug 2024 03:04:36 +0000 (UTC) X-FDA: 82500161352.26.3126311 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf11.hostedemail.com (Postfix) with ESMTP id E12584001E for ; Wed, 28 Aug 2024 03:04:33 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kCuY5PXA; spf=pass (imf11.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724814186; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XVdwfZoyZWde9aSN6zhMbNNaJxIyi5X3Dr8kaez296Q=; b=2P3/QSXE+R/cM0PHH6NLbX250N/E3G+9ASStirDcy9/kphMwhDxc0WZNj4RDBfXJcnfrjb cNzKu7XsY90fosnGKboMnyKbZrSWmwxUhMYe5rNL+3KEyR2qt7qPxZ4hRiDTKUW3vabIgM pxBfBRTc1yh5ZN19K4vKnZtXbCMN2z0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724814186; a=rsa-sha256; cv=none; b=FuzBdiRLup8qSXtCFDo/l6gs3lZZjArQfnOH9kEGEJ2/CsW8mT9QPHcqE6bFZ+8PlydiCY JuRzAz2kWh+tmCPc1REi3zy3GX34t9X/rkEs1kOUy/p8+sdrt09/66mr1GRS8I1zeP7ODL p56PJDAUrLHIJQk7Djc/YsJmWVPR05A= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kCuY5PXA; spf=pass (imf11.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2d3d58d6e08so4808787a91.3 for ; Tue, 27 Aug 2024 20:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724814272; x=1725419072; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XVdwfZoyZWde9aSN6zhMbNNaJxIyi5X3Dr8kaez296Q=; b=kCuY5PXAZdOBq/4Gng8+CEFf7qzXFtWVG3991RkATH/dIVjo5obSR1lyh9w/Q+5eqD 9z3hf86UnxJaxLVi6JpHvm3u6zmOhQZhrZm3VG0IlZTTmXI/q76i6wkuIN+Kbmsn7cEr 7CyukcXOPbFAdMWS9XQo6Z/CzoiY/fV9azW2KfpYdmg1rxz5gtbQdtRpW1sLf24wYQSQ bDwDuRDGxbZ0f68udr+j4Ezfe+7Jiu1NJ6q5K1FCYpVp34OMGRA1dtm1CYqcYZv+vX9q XVy1ngDTyrlEePJr+Ph8WkPgKpuYpwSZ+PTINirpXvoGOOSQsPv7EtXFQgmtCTd5cb9x MjLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724814272; x=1725419072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XVdwfZoyZWde9aSN6zhMbNNaJxIyi5X3Dr8kaez296Q=; b=rPBnnWqckcTlNbpa0dPk/9gAMDeyJss8aMldAukI6131TTAsY2yokDkUkIuuRXX7js yY7OWOgtq8CkR90fi5j758DKSM/tRFe3yvbE91TAXF6lWhc2pHnrgClhMlgPSXd8GVh+ ZaYmJGsAa67Qp43d1iA4Vex1MKMY44lDTTlBecirGw/SiB+9fBqArGlq/eiUZfacnnmf YtND0QeKrjYdsPMIVbIdC5Bzy+wP7ZkmGtzArEhCvd1IekrBe6/BrQaAIhK6DIIrHMni uzLJ8hvQCjN0s4m2RMTixPnC6yW28xqtdXYc+Adwmb+XbzbweHSdrQoUEEjdAXdRVuMo lNpg== X-Forwarded-Encrypted: i=1; AJvYcCWtYMOEY0DEQX7ZfAFXFOEk4M2sdDPBT1IvM8jFQcg3RY4bBrDPJcXTS1zznmSfJDT26ktaAaWI4A==@kvack.org X-Gm-Message-State: AOJu0YycGk7LcjJrsyQ4yB82ZlzqneQoiZC62dRdXv3O39ATO4HlobYJ /83iOboneTJggtBm7LbAqWvuZ4tn/ZP7STezJIHYsWJCnsvUSoWT X-Google-Smtp-Source: AGHT+IFb9q9yq9VVSwLC6AkI1/p1bhkyyRxy6O/7jYlaHznbpdfEJAgSG3Tzmhmlf5xXUEBbcGAPmA== X-Received: by 2002:a17:90b:356:b0:2c9:61f9:a141 with SMTP id 98e67ed59e1d1-2d646bf605amr17374556a91.16.1724814272564; Tue, 27 Aug 2024 20:04:32 -0700 (PDT) Received: from localhost.localdomain ([39.144.104.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d8445db8f6sm317977a91.1.2024.08.27.20.04.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Aug 2024 20:04:32 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, alx@kernel.org, justinstitt@google.com, ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, catalin.marinas@arm.com, penguin-kernel@i-love.sakura.ne.jp, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, audit@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Yafang Shao , "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v8 7/8] net: Replace strcpy() with strscpy() Date: Wed, 28 Aug 2024 11:03:20 +0800 Message-Id: <20240828030321.20688-8-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240828030321.20688-1-laoar.shao@gmail.com> References: <20240828030321.20688-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: cpwrn6ugrdji91gd7oftpxdibywn3hp3 X-Rspamd-Queue-Id: E12584001E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724814273-227454 X-HE-Meta: U2FsdGVkX1/7ViPCmWvOHboMAxINPJWeIx6NCunaMhZLYVsNoKymu7Bv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aaFpACtS+vw5A9yNCY6UQjH9Q8ws53haLA+Wx72LMjKHx051Y6WQBBxwHmZIH52fdpmfAMUA0kbe9z96pNqZqo278/Qhm+9tK9CV8zqihUMxqH6lCfCUHBWcchG1mDrGoqSId8X+Hm0KbocmJbcrtTdNQnA0xoLuXkfnayDzRC8l2yxBa+bI2WzfOqXvph9rp2XFxEJC/j0MVbU8X0KW+tIrYt4dUKwD3pNNPz8mN3vAqf8+G2VeiFTwBfN3wse2oTTbFOLhc75sD2Uqw1vSuNU7/76TyBPqhZRCpzUVXBQTo/OkGAOj9FkF/uEDcd1oBM+MAmqrMTmZdGGueGuJtd359KRdVAc9w9jnKtavZvuFUuxfHphlXdy0CJZ058v3UMEVGqMF0j6XBd10UJbm3WuAX4ryN3AZOpMwcBjkYrp9yPxTYrsoUjX5vGLw3kNrG+bzWCWXlddFASrcv/+wWxfBOE6vJDCPnOPVwrKwWwQEncSvFxGmo8ey/MKyk/F09vwMPjrn0ZWH/6cV8WkylsBIP6tVbIIiVamd5sHExh+EvBVD X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To prevent errors from occurring when the src string is longer than the dst string in strcpy(), we should use strscpy() instead. This approach also facilitates future extensions to the task comm. Signed-off-by: Yafang Shao Cc: "David S. Miller" Cc: David Ahern Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Reviewed-by: Justin Stitt --- 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 b8eec1b6cc2c..cf7c36463b33 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,