[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230228183351.GB15021@redhat.com>
Date: Tue, 28 Feb 2023 19:33:52 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Dmitry Safonov <0x7f454c46@...il.com>
Cc: Gregory Price <gourry.memverge@...il.com>,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
avagin@...il.com, peterz@...radead.org, luto@...nel.org,
krisman@...labora.com, tglx@...utronix.de, corbet@....net,
shuah@...nel.org, Gregory Price <gregory.price@...verge.com>
Subject: Re: [PATCH v12 2/3] ptrace,syscall_user_dispatch: checkpoint/restore
support for SUD
On 02/28, Dmitry Safonov wrote:
>
> On 2/28/23 16:52, Oleg Nesterov wrote:
> > On 02/27, Dmitry Safonov wrote:
> >>
> >>> +int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
> >>> + void __user *data)
> >>> +{
> >>> + int rc;
> >>> + struct ptrace_sud_config cfg;
> >>> +
> >>> + if (size != sizeof(struct ptrace_sud_config))
> >>> + return -EINVAL;
> >>> +
> >>> + if (copy_from_user(&cfg, data, sizeof(struct ptrace_sud_config)))
> >>> + return -EFAULT;
> >>
> >> It seems that the tool you want here would be copy_struct_from_user(),
> >> which is designed for extendable syscalls.
> >
> > Hmm. Why?
> >
> > In this case ksize == usize, so why do we need copy_struct_from_user ?
>
> In case the structure extends in future, that will let newer userspace
> run on an older kernel (as long as it doesn't use [set] any new fields).
Sure, I understand that, but I don't think it's worth the trouble
in this case.
If (unlikely, I think) this structure ever extends we can switch to
copy_struct_from_user() or do something else if check_zeroed_user()
makes no real sense for the new fields.
Right now I think it is more important to ensure that the new users
of this API use the correct size.
Oleg.
Powered by blists - more mailing lists