From mboxrd@z Thu Jan 1 00:00:00 1970 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 05746C433F5 for ; Tue, 30 Nov 2021 03:02:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 711756B0071; Mon, 29 Nov 2021 22:02:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 698C16B0072; Mon, 29 Nov 2021 22:02:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 512796B0073; Mon, 29 Nov 2021 22:02:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3E71F6B0071 for ; Mon, 29 Nov 2021 22:02:14 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03B148E2CB for ; Tue, 30 Nov 2021 03:02:04 +0000 (UTC) X-FDA: 78864097368.03.C08D828 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 9B7FC400209D for ; Tue, 30 Nov 2021 03:01:58 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id i9so25269978qki.3 for ; Mon, 29 Nov 2021 19:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hilByPD8L3h9Ytyg6eTvXqp0WXWx+OL3wX2IRfH8TVI=; b=Xo1NrVoBOqABaaCVvLLEZyjUAmGr5+STOyjB+Pl/KgnHbeqPB0r+ESX4feZTOYkB2q aoweXGM9moAULJSK1z/msCYVpKpkCwdkqiyZNGpMWWv481qk8A19r1fU1siANLz0Hgn1 vKfwoyFzqm0Ai8EVILk3tVtyor84mNb1ryzwvrXiTnCII28eF/u7hesuFgSHxxVyZwCX UAU0N60V6jiuC/x3h1E9V0VqtqaKb2D8va5yc3TskropS9N2TlDwZz8Ct8OdEMGXBz+D /BikptCg66Nw8qd2stBC6QJQ2u1tQDQYaXDFqtm9suppBCUNCU5cJVmuoyvOKAHT1/B9 3xtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hilByPD8L3h9Ytyg6eTvXqp0WXWx+OL3wX2IRfH8TVI=; b=pdiQDpSnqRoFp95+1a0FUYKjTUeu7LcdF2LkdhdddiNCeQ93iADD17Q+Q6rGm49n34 l4lMGBd76oQ53DyKXReFOfsnwy2Xip2QxNCVN/WSra8TcTi1gp7uR4oqkjpyC6N9zsqV v7R7etQ1DiBYWkO+cKYsV+IkCL+1qyXLZtf2HSMAQzEoTcaq/qWrn85JexWgRJl2kn2m O8yEO/NFRsVP3epX8Rp9f02UsYVG8+j4e2DlLM4MVPHEEhUMtWY+PN+T0frgSVh3Jxqg vRfwelx8g11zqLqqxLWblB/9SVVfceEYbFM2+C5//FX5XVNR7ITOR8LATbTCzISE5uML uApg== X-Gm-Message-State: AOAM531eXcRgO8CyOFQXHPU0U7qZ4yellBlI3iGJ079xcT6n8jshhKIc 5phZxEiq0cIAIVleGXEB1BDzn8x6MR8Tt/jcMg0= X-Google-Smtp-Source: ABdhPJyUj8zY9/gTmJm9gnBT3BhDDzchPwLsvCPELhO/9hrEsiUYremqHf1uk5r6y5RjtYcFFgfFfydWTIJYBrtoeSk= X-Received: by 2002:a05:620a:134a:: with SMTP id c10mr43400535qkl.207.1638241322873; Mon, 29 Nov 2021 19:02:02 -0800 (PST) MIME-Version: 1.0 References: <20211120112738.45980-1-laoar.shao@gmail.com> <20211120112738.45980-5-laoar.shao@gmail.com> <20211129110140.733475f3@gandalf.local.home> In-Reply-To: <20211129110140.733475f3@gandalf.local.home> From: Yafang Shao Date: Tue, 30 Nov 2021 11:01:27 +0800 Message-ID: Subject: Re: [PATCH v2 4/7] fs/binfmt_elf: replace open-coded string copy with get_task_comm To: Steven Rostedt Cc: Andrew Morton , netdev , bpf , "linux-perf-use." , linux-fsdevel@vger.kernel.org, Linux MM , LKML , kernel test robot , kbuild test robot , Kees Cook , David Hildenbrand , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro , Petr Mladek Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 9B7FC400209D X-Stat-Signature: qkf9uceozqp4sah3qotdh6nkwsj4frky Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Xo1NrVoB; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-HE-Tag: 1638241318-584095 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: On Tue, Nov 30, 2021 at 12:01 AM Steven Rostedt wrote: > > On Sat, 20 Nov 2021 11:27:35 +0000 > Yafang Shao wrote: > > > diff --git a/include/linux/elfcore-compat.h b/include/linux/elfcore-compat.h > > index e272c3d452ce..54feb64e9b5d 100644 > > --- a/include/linux/elfcore-compat.h > > +++ b/include/linux/elfcore-compat.h > > @@ -43,6 +43,11 @@ 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. > > Didn't I once suggest having a macro called something like: > > TASK_COMM_LEN_16 ? > > > https://lore.kernel.org/all/20211014221409.5da58a42@oasis.local.home/ Hi Steven, TASK_COMM_LEN_16 is a good idea, but not all hard-coded 16 can be replaced by this macro (which is defined in include/sched.h). For example, the comm[16] in include/uapi/linux/cn_proc.h can't be replaced as it is a uapi header which can't include linux/sched.h. That's why I prefer to keep the hard-coded 16 as-is. There are three options, - option 1 comment on all the hard-coded 16 to explain why it is hard-coded - option 2 replace the hard-coded 16 that can be replaced and comment on the others which can't be replaced. - option 3 replace the hard-coded 16 that can be replaced and specifically define TASK_COMM_LEN_16 in other files which can't include linux/sched.h. Which one do you prefer ? > > > > + */ > > char pr_fname[16]; > > char pr_psargs[ELF_PRARGSZ]; > > }; > > diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h > > index 957ebec35aad..746e081879a5 100644 > > --- a/include/linux/elfcore.h > > +++ b/include/linux/elfcore.h > > @@ -65,6 +65,11 @@ 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 */ > > }; -- Thanks Yafang