From: Dmitry Safonov <0x7f454c46@gmail.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>,
LKML <linux-kernel@vger.kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
Oleg Nesterov <oleg@redhat.com>, Andrey Vagin <avagin@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2] prctl: PR_SET_MM - unify copying of user's auvx
Date: Fri, 26 Mar 2021 00:24:47 +0000 [thread overview]
Message-ID: <14931afb-903b-e7c6-5276-416dab5f08ed@gmail.com> (raw)
In-Reply-To: <YFpmdGXmGQ6IetoX@grain>
Hi Cyrill,
On 3/23/21 10:06 PM, Cyrill Gorcunov wrote:
[..]
> --- linux-tip.git.orig/kernel/sys.c
> +++ linux-tip.git/kernel/sys.c
> @@ -1961,6 +1961,30 @@ out:
> return error;
> }
>
> +static int copy_auxv_from_user(unsigned long *auxv, size_t auxv_size,
> + const void __user *addr, size_t len)
> +{
> + BUG_ON(auxv_size != sizeof(current->mm->saved_auxv));
Nit:
size_t auxv_size = sizeof(user_auxv);
BUILD_BUG_ON(sizeof(user_auxv) != sizeof(current->mm->saved_auxv));
(to make it local variable instead of a parameter and get rid of a new
BUG_ON())
> +
> + if (!addr || len > auxv_size)
> + return -EINVAL;
> +
> + memset(auxv, 0, auxv_size);
> + if (len && copy_from_user(auxv, addr, len))
> + return -EFAULT;
> +
> + /*
> + * Specification requires the vector to be
> + * ended up with AT_NULL entry so user space
> + * will notice where to stop enumerating.
> + */
> + if (len == auxv_size) {
> + auxv[AT_VECTOR_SIZE - 2] = AT_NULL;
> + auxv[AT_VECTOR_SIZE - 1] = AT_NULL;
I don't follow why it became conditional.
Perhaps, you meant that memset(0) above will zerofy it anyway, but in
case (len == auxv_size - 1) it won't work. Or I'm missing something
obvious :-)
Thanks,
Dima
next prev parent reply other threads:[~2021-03-26 0:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 20:36 [PATCH] prctl: fix overwrite last but one entry in auxv vector Cyrill Gorcunov
2021-03-22 6:42 ` Cyrill Gorcunov
2021-03-23 22:06 ` [PATCH v2] prctl: PR_SET_MM - unify copying of user's auvx Cyrill Gorcunov
2021-03-26 0:24 ` Dmitry Safonov [this message]
2021-09-29 15:20 ` kernel test robot
2021-09-29 15:34 ` Cyrill Gorcunov
2021-11-12 17:21 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14931afb-903b-e7c6-5276-416dab5f08ed@gmail.com \
--to=0x7f454c46@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=gorcunov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome