From patchwork Sat Aug 17 02:56:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13766929 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 40B89C3DA4A for ; Sat, 17 Aug 2024 02:57:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9A9C6B03FA; Fri, 16 Aug 2024 22:57:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4A316B03FB; Fri, 16 Aug 2024 22:57:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B119A8D0066; Fri, 16 Aug 2024 22:57:55 -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 937156B03FA for ; Fri, 16 Aug 2024 22:57:55 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4E0DC80446 for ; Sat, 17 Aug 2024 02:57:55 +0000 (UTC) X-FDA: 82460227710.03.7EC8C9C Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf08.hostedemail.com (Postfix) with ESMTP id 74C0016000F for ; Sat, 17 Aug 2024 02:57:52 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GXIbwtRI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723863458; a=rsa-sha256; cv=none; b=6pHzc6xElFkLuaux4Xn9c/7Naxgy1BD/1iGgOIdB2i9GmSXFeGJHGpYglp8w4l5uLR4tbW xQO/c56AHp0iv3qH2edADAVmZKgCtjpQlqyPhLgP9rvfM55vIQcRLF1iT2RliC2DEj0rvm Djyz+ynAXzghTpdlQfVRlmHJ5hDfNk4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GXIbwtRI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723863458; 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=by1YCv/9fNhFKuS7v7AkJGwNY9Y/YBFp3hXhZ5CbnE4=; b=jH0eMIV0MaazpM/u8yRQkO8lPucAanW4osIkoFhHBheKXL2E3yKFwaQyyHb4FM9t4gkVA+ jUWbjAxLTb4/u7LDn0Bw+fdtp2kpSnjKOyFoyyOo/ar23JVq784Qsal9l3TBexY/eqsyWX m9yk2hM73tDQihBRdvIB762f7au5+vQ= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1fd9e70b592so26244175ad.3 for ; Fri, 16 Aug 2024 19:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723863471; x=1724468271; 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=by1YCv/9fNhFKuS7v7AkJGwNY9Y/YBFp3hXhZ5CbnE4=; b=GXIbwtRIL1t43cxP9lcCqqfWvTzBA7+4+pHGVef+TyGCthaINlwFd69bOV5fwkL472 21YHb97ugtHTIZyBKCcrt+OSufiiR7M0Bp6ufkEn25zMeQ6aRwaqZoNeZPl+cWEhsZVw 9GzAbbTgB7jIK+nGbekdO2Kf593zG5HLVVudmU1t0QUGes8xpzcfbq7f73JJXlTRcp7v MfWn9dYDLHRc74jqPzC+c9UkMPBFobvmu8lQcsdtmxAPJyF0JApRPTEwpIgiQANDeNff Zps1/MKXDHrXENE8+7NZ1ciUKQ7CP17X6kOEqM7en0zNXoyQzmzFARUQVpoH6LttJWk9 j6bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723863471; x=1724468271; 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=by1YCv/9fNhFKuS7v7AkJGwNY9Y/YBFp3hXhZ5CbnE4=; b=Sm6U3EUjNsQCenVh232P5N87rf9A2fGyv/l+Glav59/cnms4FKuIzJp2CglCFaozWA E4pujqR0g/SvWtB6kYsWqxrZZmaKdnuPmrJNzijn+7PsHXKFWxlEdfRpSY5tH8s86mrc 6InOUfg1aCtUpol0o2pkPmMjl9BDzrpQmK69j7mpv7hfYi2rKf6NFU63XBloXimAqJq2 xgWNHBz/RsfzqZqXxoi2dzipvdLpt8Bb96wATe0NKuL//UEqQp67Q9zFbwt6aApjJ0Y3 vRS9s+F115xLgIoLen0DRPB5OWW+6bHIY0EuvzqzGrqbfVrjzCpjYFu/wA7rjIrwilGi AKsA== X-Forwarded-Encrypted: i=1; AJvYcCWT0GLXYOKE1A1xa1tsHcuRrcmpDRx58FA2ptdaFh0CW0T+FNZY07dbwdd4X/IidE9beBTztGVKVVAlhHurdpPM00g= X-Gm-Message-State: AOJu0YwK9d1PM506vlATEyaSiGF59Cp5fccOyevxTjCU88yZze5IrYgh krPy7gB87JlfcGuArZV/VAj+IxO3Nn7+x092SBc4QHCl8gw6uw0u X-Google-Smtp-Source: AGHT+IGmy8Jt8i1r5v72uMgbTh9QfFBoOAd1ReOek6MsKKuMaUCDeTlIuXQ+GXacq0NZtUUeDKoREg== X-Received: by 2002:a17:902:e542:b0:202:162c:1f36 with SMTP id d9443c01a7336-202195ff1e3mr12511865ad.36.1723863471180; Fri, 16 Aug 2024 19:57:51 -0700 (PDT) Received: from localhost.localdomain ([183.193.177.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f031c5e1sm31801785ad.94.2024.08.16.19.57.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 19:57:50 -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 v7 7/8] net: Replace strcpy() with strscpy() Date: Sat, 17 Aug 2024 10:56:23 +0800 Message-Id: <20240817025624.13157-8-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240817025624.13157-1-laoar.shao@gmail.com> References: <20240817025624.13157-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 74C0016000F X-Rspamd-Server: rspam01 X-Stat-Signature: frhqzewfk8tjcwdoudfxsk1bdux71uro X-HE-Tag: 1723863472-589290 X-HE-Meta: U2FsdGVkX18cCpCdEagyrL0imgqNi8PPzgYhdG4QHBA3jXn/hWEOe+NLajG9jnKT8Mrf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LNxvVCPOpAkOJOwjPdP3rWdlAf4Ong2rGcZNGQsgfNLTJDy4q4UdW3+0hsf+2z9JrpRoKynKISh7rwN7yNdrzMG/9fJJASgLbgJEkDI+RIcfRidxkqyy453EKSl3Nm1xBH7wS0K8NHF7yTW/3WylK/AhuTfKucACJmh9Z6jvGSDSqLnzoNl62K8b7gG34eW+mIDXOtlMmMCsNZvYouoXNf2A4UgIYvwBpa8Xluo4cZvO3wOUMZe6v1WsnIEXxmui+6oXRA+R5O2HQ6Mbd1mJ2jkDnlr5L7o/F56niN5cYN6YjTstyDLo0V1yFjdYE/8afGwICUYUeEI9q7YRL2Gd/gasw/d9gxP++y6NHIUQlAG+CM+Bb2josbqLOwuWJpD6pYBuLgjzfE/yAhcx3sgtOX2fEU3qm/Ju85sVYUdZdneJ/DfbkOVcpmoMMu4hvd4+f2gPCt/8gXW3Lx630/tYpem+rQd/d0vV0wu45qiWrg== 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 --- 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 254b192c5705..17f2e787e6f8 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1942,7 +1942,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,