From patchwork Sun Aug 4 07:56:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13752531 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 41510C3DA7F for ; Sun, 4 Aug 2024 07:58:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA9886B009B; Sun, 4 Aug 2024 03:58:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C58DA6B009C; Sun, 4 Aug 2024 03:58:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B21296B009D; Sun, 4 Aug 2024 03:58:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 904726B009B for ; Sun, 4 Aug 2024 03:58:55 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 38466A78A1 for ; Sun, 4 Aug 2024 07:58:55 +0000 (UTC) X-FDA: 82413811830.19.7FC4235 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) by imf04.hostedemail.com (Postfix) with ESMTP id 5EDC440003 for ; Sun, 4 Aug 2024 07:58:53 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RI0L91HE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.169 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722758288; a=rsa-sha256; cv=none; b=ASYJNR1FYH2jG5e2/sSLlC6bKbez76aC78FrfHsW6SoBoQCp2G94/JC+lmDG0W4Mt/4MhG /OAfsJsIpAUdp0dl8zPP3uT21rCJPthUFLzUiEruM3PwF+GxhA13zWCRvt7LRr4/XibxB8 aXjb8izigwnEHRKJfps4FQ6eqoatKeg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RI0L91HE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.169 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=1722758288; 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=Iy8s8HUuCpYYzqYVYDLibKnXKIG+UtFNyRBbbBdMpkI=; b=H8oa7BxJnCH/5Fi8Ym+IZGz4A2hRBWaUHLHEDU5AIr/hMD00omxjEr8Ffz7h4N85PDz8KI OKvtGMMmvl1OvjkOBaOtRciGoV5CZn+SUO+759evgXGU3iNS+V7R0Mgv/g3wX0Bo/FmplR f1uUBwE3KfAEprIpLbVpxyO5pKEdNNA= Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3db51133978so2542890b6e.3 for ; Sun, 04 Aug 2024 00:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722758332; x=1723363132; 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=Iy8s8HUuCpYYzqYVYDLibKnXKIG+UtFNyRBbbBdMpkI=; b=RI0L91HErNasqIouNBMx8JGlTh1wR8wTuTD1wkqrLyVuukwf/5iX9CeRrtO8kX4atz JwS24LeoELH5eCjq0Sau3JN9HAatK165slgsdSzYytuyQ5U/1HruflOqUcBqXIaJ9rc+ IUb4ucu4ROXKTqrFezeMqb/+NwBB7mTKXc5vRxtjEh7CguClzvhmRrlOLOGfUkCYu8qb 5eXlj917Ko4iCZYQhQhf4CBhd7n3MhCJU+fEPBTEkLWPoiLQGRFUA2KXZpl6xQM+qSKl ahgUiUVXHYZippWzgKYTSfVlz9D6yKT0Qvr6x797yZae/lepNYf+++tt1xRQmdR/kOXX az4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722758332; x=1723363132; 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=Iy8s8HUuCpYYzqYVYDLibKnXKIG+UtFNyRBbbBdMpkI=; b=pWIELjGkxK9/Z0UrxLKZa4BHmUdHkT1W/8YT5CTtsOXKGSK6P1oDr0qw3o8DuBTmpX O4usv4XBJgb333jXoCMds5nsBMW8yd2Jd3RvnaPYLqtDda7mwSU1i0ZaJg/knowBcG3g 8x2LmjkSWWci7jiV6gKFWi19iUKSpTPs5FdgvfZxvpXktuERDu+2j1TPaX32titjLgTo 9OIwaPoPfFEZhfuP95jcJS9JNPzX90MqyfYdjx//M9HyEG0OJHOeuNgb9k+vAVH6O9Wk K/EIhBvVNA9pIRMZGNuBZ8DkRDR7QxSL5fXFhnchi2vkOg5SStRGTOGJh7+hYTZwqr4I e6aQ== X-Forwarded-Encrypted: i=1; AJvYcCVHx3Ecx3+QwjT73IcWGeILVS5SI1sv3J074nXliOwSIh9eqeeY9zzgFpzkqZa5lidRhDZfBA5aRaCLjYOePmDTK/o= X-Gm-Message-State: AOJu0YyoPar6BCUbCTeJpn6YxbKzGrEDs3ruFX5CkeRxu1KhG2haNeCJ QqjtpjgChTgjozKeN3TRkLYZKIaQQ7dg5xCTw75d/N47C2ZSu2qf X-Google-Smtp-Source: AGHT+IEAdxuBVNyLOuAyS4g3ON7ORD29wxk4r6CpWYYml3q2XeTU12w4OJdy/NnFgIlYXJGGtsOOlw== X-Received: by 2002:a05:6808:1984:b0:3d9:9e78:420c with SMTP id 5614622812f47-3db5583270amr9335216b6e.38.1722758332352; Sun, 04 Aug 2024 00:58:52 -0700 (PDT) Received: from localhost.localdomain ([39.144.105.172]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff59178248sm46387605ad.202.2024.08.04.00.58.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2024 00:58:51 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, 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 v5 8/9] net: Replace strcpy() with __get_task_comm() Date: Sun, 4 Aug 2024 15:56:18 +0800 Message-Id: <20240804075619.20804-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240804075619.20804-1-laoar.shao@gmail.com> References: <20240804075619.20804-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5EDC440003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: n3udrj7cdg3zmh5kstp35ioh6izpund3 X-HE-Tag: 1722758333-566946 X-HE-Meta: U2FsdGVkX1/HTQREqpwPdhLsCO2HkPWv+RTakterr2o6SaWWnljkpQMijCKOKHXiJ8580zkl12qXTdPo5c9hii3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WfqPyFm80SK2H+nwPUsQoEQMnScfUI4hjKKFWmF1xT/alRBC/AJXEnrzDgKCq0Q7QVrGz5lhARiIoSNFyWEkm/HaNmd5jEXIhmj97s8XD2lx5p3tIsaLoUGgKkeb9l3MzbF9ytJLG/9Irai7atJwjg8/7LcpqNPZ5DzgbybNM/vJ8UCYiBJXw/VAVb86U221D5zqErQQZSo4EPO8A6knqVkJ2wcIg7kyc1CxV/oSk60nUSxQ+QfyynQmlQmjAShT/BJdyXp2nVhpucNLkcwjN+lu124KWGi5R7McNdf5CTIrt7ugv6zV8spa7ZkwnouaWXSzBrWAjufOPB5gwGBmYTooYSXuoFPTobSIpk4Tqc1v3e+rOfGrOw4iPMkcNlb7mXBKIw/IocszEy87eLfuZuHnAEwlqwYKqij8Jw0JHWie4mfHpp2iZi3A7ubNCusiOcdSjllMdmemid2yhhmLiChYUtTdaPJPLgzOHMZFIPLuR+AurrPpcTIoxCA 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 __get_task_comm() 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 70a0b2ad6bd7..fa3a91e36ba0 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); + __get_task_comm(warncomm, TASK_COMM_LEN, current); 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,