From: Ingo Molnar <mingo@kernel.org>
To: Yu-cheng Yu <yu-cheng.yu@intel.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] x86/ptrace: Add comments to x86_regset about empty slots
Date: Mon, 16 Jul 2018 00:54:33 +0200 [thread overview]
Message-ID: <20180715225433.GA30102@gmail.com> (raw)
In-Reply-To: <20180713171249.11510-1-yu-cheng.yu@intel.com>
* Yu-cheng Yu <yu-cheng.yu@intel.com> wrote:
> find_regset() goes through regsets sequentially. Empty slots
> in regset arrays causes mismatch. Add comments to x86_regset
> enum.
>
> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
> ---
> arch/x86/kernel/ptrace.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
> index e2ee403865eb..130ca4f27a17 100644
> --- a/arch/x86/kernel/ptrace.c
> +++ b/arch/x86/kernel/ptrace.c
> @@ -42,6 +42,11 @@
>
> #include "tls.h"
>
> +/*
> + * find_regset() goes through regsets sequentially.
> + * Do not create empty slots in x86_64_regsets[] or
> + * x86_32_regsets[] below.
> + */
> enum x86_regset {
> REGSET_GENERAL,
> REGSET_FP,
What mismatch exactly? The logic in find_regset() is:
for (n = 0; n < view->n; ++n) {
regset = view->regsets + n;
if (regset->core_note_type == type)
return regset;
}
and an 'empty' slot would have .core_note_type of 0 - which would be easy to skip
or warn about.
It appears to me user-space ptrace users can control 'type' via PTRACE_GETREGSET,
so it might make sense to filter out the value of 0 there.
Or something like that. The patch doesn't really explain the problem, and I
maintain my argument that the current code of relying on no empty slots and not
having any mechanism other than human review ensuring it is both ugly and fragile.
Thanks,
Ingo
prev parent reply other threads:[~2018-07-15 22:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-13 17:12 Yu-cheng Yu
2018-07-15 22:54 ` Ingo Molnar [this message]
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=20180715225433.GA30102@gmail.com \
--to=mingo@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yu-cheng.yu@intel.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