[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALOAHbArfDWT8VhL3btWme8s+T8VLGUYKtYDmotgSnY1heBjJA@mail.gmail.com>
Date: Thu, 7 Oct 2021 23:45:08 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: Kees Cook <keescook@...omium.org>
Cc: Petr Mladek <pmladek@...e.com>, Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Valentin Schneider <valentin.schneider@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
qiang.zhang@...driver.com, robdclark@...omium.org,
christian@...uner.io, Dietmar Eggemann <dietmar.eggemann@....com>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Steven Rostedt <rostedt@...dmis.org>,
Benjamin Segall <bsegall@...gle.com>,
Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
Vladimir Zapolskiy <vzapolskiy@...il.com>
Subject: Re: [PATCH v2 1/4] cn_proc.h: use TASK_COMM_LEN instread of 16 in
struct proc_event
On Thu, Oct 7, 2021 at 11:09 PM Kees Cook <keescook@...omium.org> wrote:
>
> On Thu, Oct 07, 2021 at 07:51:35AM -0700, Kees Cook wrote:
> > On Thu, Oct 07, 2021 at 12:07:49PM +0000, Yafang Shao wrote:
> > > struct comm_proc_event was introduced in commit
> > > f786ecba4158 ("connector: add comm change event report to proc connector").
> > > It seems that there is no strong reason we must define the comm as a
> > > hardcode 16 bytes. So we can use TASK_COMM_LEN instead.
> > >
> > > Signed-off-by: Yafang Shao <laoar.shao@...il.com>
> > > Cc: Vladimir Zapolskiy <vzapolskiy@...il.com>
> > > Cc: Kees Cook <keescook@...omium.org>
> > > Cc: Al Viro <viro@...iv.linux.org.uk>
> > > Cc: Petr Mladek <pmladek@...e.com>
> > > ---
> > > include/uapi/linux/cn_proc.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h
> > > index db210625cee8..351d02786350 100644
> > > --- a/include/uapi/linux/cn_proc.h
> > > +++ b/include/uapi/linux/cn_proc.h
> > > @@ -110,7 +110,7 @@ struct proc_event {
> > > struct comm_proc_event {
> > > __kernel_pid_t process_pid;
> > > __kernel_pid_t process_tgid;
> > > - char comm[16];
> > > + char comm[TASK_COMM_LEN];
> > > } comm;
> >
> > Hrmm. This is UAPI -- we can't change it without potentially breaking
> > things (i.e. userspace binaries have this size built in, so we can't
> > just change the size). This will either need to stay truncated, or may
> > need a new interface with a variable-sized structure...
>
> Specifically, this is needed for this series:
>
>
> diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
> index 646ad385e490..34bcba25c488 100644
> --- a/drivers/connector/cn_proc.c
> +++ b/drivers/connector/cn_proc.c
> @@ -230,7 +230,9 @@ void proc_comm_connector(struct task_struct *task)
> ev->what = PROC_EVENT_COMM;
> ev->event_data.comm.process_pid = task->pid;
> ev->event_data.comm.process_tgid = task->tgid;
> - get_task_comm(ev->event_data.comm.comm, task);
> + /* This may get truncated. */
> + __get_task_comm(ev->event_data.comm.comm,
> + sizeof(ev->event_data.comm.comm), task);
>
> memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
> msg->ack = 0; /* not used */
>
Thanks for the suggestion. I will keep the UAPI code as-is and change
it as you suggested.
--
Thanks
Yafang
Powered by blists - more mailing lists