[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200326172146.GF11398@zn.tnic>
Date: Thu, 26 Mar 2020 18:21:46 +0100
From: Borislav Petkov <bp@...en8.de>
To: Joerg Roedel <joro@...tes.org>
Cc: x86@...nel.org, hpa@...or.com, Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Hellstrom <thellstrom@...are.com>,
Jiri Slaby <jslaby@...e.cz>,
Dan Williams <dan.j.williams@...el.com>,
Tom Lendacky <thomas.lendacky@....com>,
Juergen Gross <jgross@...e.com>,
Kees Cook <keescook@...omium.org>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
virtualization@...ts.linux-foundation.org,
Joerg Roedel <jroedel@...e.de>
Subject: Re: [PATCH 06/70] x86/umip: Factor out instruction fetch
On Thu, Mar 19, 2020 at 10:13:03AM +0100, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@...e.de>
>
> Factor out the code to fetch the instruction from user-space to a helper
> function.
Add "No functional changes." here.
> Signed-off-by: Joerg Roedel <jroedel@...e.de>
> ---
> arch/x86/include/asm/insn-eval.h | 2 ++
> arch/x86/kernel/umip.c | 26 +++++-----------------
> arch/x86/lib/insn-eval.c | 38 ++++++++++++++++++++++++++++++++
> 3 files changed, 46 insertions(+), 20 deletions(-)
...
> +int insn_fetch_from_user(struct pt_regs *regs,
> + unsigned char buf[MAX_INSN_SIZE])
No need for that linebreak - fits in 80 cols.
> +{
> + unsigned long seg_base = 0;
> + int not_copied;
> +
> + /*
> + * If not in user-space long mode, a custom code segment could be in
> + * use. This is true in protected mode (if the process defined a local
> + * descriptor table), or virtual-8086 mode. In most of the cases
> + * seg_base will be zero as in USER_CS.
> + */
> + if (!user_64bit_mode(regs))
> + seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
> +
> + if (seg_base == -1L)
> + return 0;
This reads strange: seg_base is changed only inside that if test so I
guess we could test it there too:
if (!user_64bit_mode(regs)) {
seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
if (seg_base == -1L)
return 0;
}
which is a small enough change to not require a separate patch.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists