From patchwork Mon Jul 29 02:37: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: 13744272 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 A9646C3DA49 for ; Mon, 29 Jul 2024 02:47:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CF386B00A7; Sun, 28 Jul 2024 22:47:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37E956B00A8; Sun, 28 Jul 2024 22:47:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2208C6B00A9; Sun, 28 Jul 2024 22:47:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0066E6B00A7 for ; Sun, 28 Jul 2024 22:47:57 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B994B1A02EE for ; Mon, 29 Jul 2024 02:47:57 +0000 (UTC) X-FDA: 82391255394.17.1C76FD1 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf27.hostedemail.com (Postfix) with ESMTP id E33A540016 for ; Mon, 29 Jul 2024 02:47:55 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ZHusiAei; spf=pass (imf27.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.171 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=1722221272; 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=YS5JkKLpH7rBBlezu3RsuBopuhXkHEJwrCmaySM0BwQ=; b=envVdi8eFhzbPEggrY3dTEOynBVuRRAllncyx8uDd/XATLe+RKLp2Hw12qyN3oLLklHZ71 r9ZCZS1oW4eHH6bz/qJ5OnkrTWWj7yn87PnjG5n+frESCd3qK36eNsPoI15rVJZDDU1rQb hi7QE1+niaKV0WKcERKq5rZ0J73Yz1g= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ZHusiAei; spf=pass (imf27.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722221272; a=rsa-sha256; cv=none; b=De+2aJLN8ZNQxSzkSTxvq9cuet57BfT+l+f8Bi8jO03UByf6L/sR4NPCCnjf7JoeDaSELJ X6RR2luywpJiw7cvDljlCeRAY+WkiHwde5qV8BsN2vMust3rz47Z5wY6G4VXwDSw/TpkoX W1qiZ/G+w/OxLq3bdP08LyLl61L4UGg= Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7ab34117cc2so1941562a12.0 for ; Sun, 28 Jul 2024 19:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722221275; x=1722826075; 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=YS5JkKLpH7rBBlezu3RsuBopuhXkHEJwrCmaySM0BwQ=; b=ZHusiAeio8y6LK3hoplsOztnB2w0NfFzlrhb3Wo2/X2QZ5JCP4cAi7ltYpo25R3B8g QMrPZ1w3YhKJBJqaLMPSw1gUe7eyFqIfXkpPEQd6jQqn+tNboO3DeSsbpGhsf1pjPRCi gJx6CENp02G1hW98UT0HQCA+UOKNxf/0biVF1DSyYhOGJV/sM32Cvr5xqcOxXHmAfCkt +CeKTNviiwQcFGbgX79Gh4uqtC4PPgey0AtwDJAbndj/9ZYhPULqUcFCY9OxC21wJNXa kY+LP+3dwznGhTMbq4oibnlzTjI1ugc+t7hiLRkLGmhe9xZQSSh/Va2NMfavv2Tq4hVz pyfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722221275; x=1722826075; 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=YS5JkKLpH7rBBlezu3RsuBopuhXkHEJwrCmaySM0BwQ=; b=LNw+QaoTY7Xck7p74ggdLN2p5uearjz5LlK45MVJ12Y+OdsHt/yuzHSupomsuniqR5 OVkWRo2jJK5DBNrcgwpI5Gio+oQl71ezepjO8veeG8ziZWHmak3PUnGQoY7BxGNZwLwM JKuKYHyqOQJ1Ep0xcJYntgGELr/d1svbtKzYVQ7y66L1aFSf3UcYb5XoNpKkjyGDFBw9 TlknKn8f3N/m/z4K8GKxpDVzZ5ZmbNbtIqh8IGCYlIOdsNwUg/GsTmydiqY29phZ4Adw +FbPPT6IOtB0ja7yMWbrzROoO5TtZCb4Vu8wcboTwhesQkTivGtKgGgNWibbOY5KoVvM fphA== X-Forwarded-Encrypted: i=1; AJvYcCUPVzfp9s070fKB4mDWuEgWiAnAwwUBZcuc+hJA93OagfXi/bqZrEPS/izWTjenYBrA7M0uMjg4eod7HI6ljzWWbKQ= X-Gm-Message-State: AOJu0Yx9ZR91U4OTkxECUWRXGzoz6FErs+B1/lQwpGFrM69FnxdJOmdB QDoLePWHfISt1I9ZYea+CEu7EoLn3G16GA+vovQCb/gxccH9DlKh X-Google-Smtp-Source: AGHT+IGXxWNnJLIJ5uPecbp6KsT2OOK8/ZuVg1FUEXn71WfglTXG9UPP1KLmHGuFVJ6pD1f6J8wciA== X-Received: by 2002:a17:90a:e00f:b0:2c9:7aa6:e15d with SMTP id 98e67ed59e1d1-2cf7e1fac4fmr7206984a91.20.1722221274655; Sun, 28 Jul 2024 19:47:54 -0700 (PDT) Received: from localhost.localdomain ([223.104.210.31]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cf28c55a38sm7332247a91.10.2024.07.28.19.47.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2024 19:47:54 -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 v4 10/11] net: Replace strcpy() with __get_task_comm() Date: Mon, 29 Jul 2024 10:37:18 +0800 Message-Id: <20240729023719.1933-11-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240729023719.1933-1-laoar.shao@gmail.com> References: <20240729023719.1933-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: zp1bw5g7gssc7n8rye59f6kdue9rgxzj X-Rspamd-Queue-Id: E33A540016 X-Rspamd-Server: rspam11 X-HE-Tag: 1722221275-471378 X-HE-Meta: U2FsdGVkX1/bea126YSS9clVNOpGCfUIh75iB7oiredm1aAT82G4J+Pi+uQk5trEOZ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C9EcABuVJTlWK60gjahG91M9M5sfN/jEr7liQV3hozGVQD8vz0A/Cas1FAuDqacJvCYYYkwIboMq5uDasrbnik3yiYZ/7Xdbnnrsr0LJVfamyD0e5wO5PEKqx6Gx72JThWYK5Gb0LEOmPJ37OtaQO0BIj1CD7IeCuEfAvpHaCNDukWsQTc69QeodK1DHQiN6J4yia1nyTrDDmUV5XT78zUfVQxWj8Seorwd9Poh362a7FAxdOVSBw4/jOJKVuNZgQEQ5QejVy73bhdE9mGsOK9bQ1yDCInHFfBhU1iYcv3yX3LCIgYwdRhAp8DNtFGQXTTUB0kNICE58S0M39DmRAYn0G98blE0tsBVeDzHavKIoKgm/R1feKbB4BahjNG3SDEE49Lvjlo82jXWiiMK7BtTyX1du51jrEQuDkbsi/dJIlPZ7HIK7CZV89jl2f3qVZwUeeUWLniV7xDJ/2K//uARG5Hx2n3dxVT228lCaDQapG/EqWhSNv4x+TQOiDhb5KdxS75Qhj3Nr 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 254b192c5705..10d8e8c6ca02 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,