From patchwork Sat Dec 4 09:52:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12656427 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 EBC22C433F5 for ; Sat, 4 Dec 2021 09:53:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 103906B0080; Sat, 4 Dec 2021 04:53:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B31B6B0081; Sat, 4 Dec 2021 04:53:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E95116B0082; Sat, 4 Dec 2021 04:53:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id DB9906B0080 for ; Sat, 4 Dec 2021 04:53:19 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8BC911828C636 for ; Sat, 4 Dec 2021 09:53:09 +0000 (UTC) X-FDA: 78879648498.19.105E6D8 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf17.hostedemail.com (Postfix) with ESMTP id 11D28F000090 for ; Sat, 4 Dec 2021 09:53:08 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so6617205pjb.1 for ; Sat, 04 Dec 2021 01:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GW6b3sF6GwXHhqR55kptdOe2KtH0uXmQ535WwxRDhsU=; b=eX8Wa48ra4eTAbUzCOJnNU1tZ8LQ+5YwkjMF4cC9JNp6JnMctLCfNTRZ7InZ0I+Qgw FVfECKW4F52lrzjt3vh137DZkIUoY7hB47gSfr/K9H2QoqO7465U7lEdZiIizj/JYnFk bRoRZO41cYRH7VnyoUgkvvtsKAQWU5ZI23WV9EZiRrldtZERlW98OTwXF+tHGZgWjmMX VZ8ZbEgTX590IeapTCgsueZoPBhgDl+0oMTt7QfPhE5JvJ06Zi4kfRFyaSkQQ/Ajklu3 uz1hArULEkefVEcgnMPS3o8gHsHiWGlBc4of8r6zd0yOpf6s9sWt4D2fMJk6/PdQTdMu e0yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GW6b3sF6GwXHhqR55kptdOe2KtH0uXmQ535WwxRDhsU=; b=AEtydIwyhvn/fe+l663SjdO2DMY/pVLHN6dW0Q9YpTI9DfwahbrKwSX7EPU/MF05ez pUmFXAWl4cnigP3z7FW1pyCS4gXAUqTk5HlDZ+v3nKWjM48ZrcZRq6gqjrlXB+OLBV4u a5nbUafaV3b0X49xeLj+bi3+1U2Kn7GZQnWPrDxucx3lwWnxj9p7b1YchBnA9WjMpS/t xLMRQGu3Ba0stz/4OaWKlDOzZhmnlo5YAvd2Mn56UggLrWZemP/ZQGt43t4RyYClhHrB HxwH2XiYU2B13M5+5EpihFAA6G8/pEqSBWAR7qVcfmTvXuJcgydFu7qgKbxfouDlDc4I V5lA== X-Gm-Message-State: AOAM532JxpvxWjiJLAyjw7V0di0toH1qvZ3znBgTCebenfAnKv3O0WKZ VQsbIC0ePnd4c328xz18OjY= X-Google-Smtp-Source: ABdhPJw12fabYSRxUnXmqlFx9H8BClcqkjFEXyD2Xgc+LCeTuaPuNjEU+nngQzdL92YKIn8kJzo0XA== X-Received: by 2002:a17:903:18d:b0:142:8ab:d11f with SMTP id z13-20020a170903018d00b0014208abd11fmr29233302plg.47.1638611588164; Sat, 04 Dec 2021 01:53:08 -0800 (PST) Received: from vultr.guest ([45.76.74.237]) by smtp.gmail.com with ESMTPSA id ms15sm4343198pjb.26.2021.12.04.01.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 01:53:07 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, rostedt@goodmis.org, keescook@chromium.org, pmladek@suse.com, david@redhat.com, arnaldo.melo@gmail.com, andrii.nakryiko@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Mathieu Desnoyers , Alexei Starovoitov , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro Subject: [PATCH -mm 1/5] elfcore: replace old hard-code 16 with TASK_COMM_LEN_16 Date: Sat, 4 Dec 2021 09:52:52 +0000 Message-Id: <20211204095256.78042-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211204095256.78042-1-laoar.shao@gmail.com> References: <20211204095256.78042-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 11D28F000090 X-Stat-Signature: yoyy6g1y4juqz9jibar6rp7xbkc3tfjd Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eX8Wa48r; spf=pass (imf17.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638611588-961534 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: A new macro TASK_COMM_LEN_16 is introduced for the old hard-coded 16 to make it more grepable. As explained above this marco, the difference between TASK_COMM_LEN and TASK_COMM_LEN_16 is that TASK_COMM_LEN_16 must be a fixed size 16 and can't be changed. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- include/linux/elfcore-compat.h | 8 ++------ include/linux/elfcore.h | 9 ++------- include/linux/sched.h | 5 +++++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/linux/elfcore-compat.h b/include/linux/elfcore-compat.h index 54feb64e9b5d..69fa1a728964 100644 --- a/include/linux/elfcore-compat.h +++ b/include/linux/elfcore-compat.h @@ -5,6 +5,7 @@ #include #include #include +#include /* * Make sure these layouts match the linux/elfcore.h native definitions. @@ -43,12 +44,7 @@ struct compat_elf_prpsinfo __compat_uid_t pr_uid; __compat_gid_t pr_gid; compat_pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; - /* - * The hard-coded 16 is derived from TASK_COMM_LEN, but it can't be - * changed as it is exposed to userspace. We'd better make it hard-coded - * here. - */ - char pr_fname[16]; + char pr_fname[TASK_COMM_LEN_16]; char pr_psargs[ELF_PRARGSZ]; }; diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h index 746e081879a5..d3bb4bd3c985 100644 --- a/include/linux/elfcore.h +++ b/include/linux/elfcore.h @@ -65,13 +65,8 @@ struct elf_prpsinfo __kernel_gid_t pr_gid; pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; /* Lots missing */ - /* - * The hard-coded 16 is derived from TASK_COMM_LEN, but it can't be - * changed as it is exposed to userspace. We'd better make it hard-coded - * here. - */ - char pr_fname[16]; /* filename of executable */ - char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ + char pr_fname[TASK_COMM_LEN_16]; /* filename of executable */ + char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ }; static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs) diff --git a/include/linux/sched.h b/include/linux/sched.h index c79bd7ee6029..8d963a50a2a8 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -279,6 +279,11 @@ struct task_group; * BPF programs. */ enum { + /* + * For the old hard-coded 16, which is exposed to userspace and can't + * be changed. + */ + TASK_COMM_LEN_16 = 16, TASK_COMM_LEN = 16, };