Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1020051ybg; Wed, 3 Jun 2020 21:42:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqR6h2woeTEmSoYaPBlD2FHn3Lk8lRoWehvzIl87cYqxHjzlIdM46io7VPf6cQcjjuwQJU X-Received: by 2002:aa7:d5c7:: with SMTP id d7mr2629074eds.11.1591245771287; Wed, 03 Jun 2020 21:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591245771; cv=none; d=google.com; s=arc-20160816; b=UpKHKJya9YztRvGn46q8q40ZxDGUe2PF29Q3ryXG+uy6CkVgZ4I1gxX9t/lrtrbORE L9tWNiL/vBbBHWx0VEaKzOSULvGB0SwOMMgDA5kwqXF7pFvMTwn/4K0UtPcFELbmBspk Tr8IaW/rff+rN3MMUtDPHLOZAxMF785BRwy9F78qeOqEqMCnLQ3AEZHDRrxA7fCCUdmX NFxF3yJH9piE+PUX2Nze/AwLAzP0pkNIOOJiJBZ4jeFJ8F4znDXHzqF9i/g7ydZ+Brkb QWDYWjUgN/YZmwsgJMubrhUDLi37VjqojCkJmoJdMwwb1ew7IjvWx6zs5cnhiSUwlQrx lP3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EcbDwjC6e+J4fqPVguK3ypyyOSloNImurJbFqg0dw7Y=; b=e4QsOx7DeeW05jjlDSAWZmRJLvYr2ojCBF6LtsqDUcILX024b72JDvcvTPzwszQ04Q 2MBpSudPC6MaUhIkVPcLB8J7bq2mirjPBIjRGCFZTBuchQFXg1LyGdxg4e1cfcIeu/h7 bQZckIBj8rf1i1PkW6QTUL6+r+wisa+Y9Z90sklfC57xCpoYobpEn1TUXS4wa/P+S3Lf LSKH8sdNf93qHOZTegikddJ6vr3Wf4Ygm85vX/7PWZze34d7Mj5tjh8tD5fcUCOWffDQ STlnJKJbMXljgYRuMZBDLzz7ZN2JV/HD78VNSFzGQxGnsQjFbkAA5Csd+ga6qKV5Xpmv QI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=jsYSBHtl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si936256eja.468.2020.06.03.21.42.28; Wed, 03 Jun 2020 21:42:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=jsYSBHtl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbgFDEk2 (ORCPT + 99 others); Thu, 4 Jun 2020 00:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725497AbgFDEk1 (ORCPT ); Thu, 4 Jun 2020 00:40:27 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82071C05BD43 for ; Wed, 3 Jun 2020 21:40:27 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id p5so4531964wrw.9 for ; Wed, 03 Jun 2020 21:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EcbDwjC6e+J4fqPVguK3ypyyOSloNImurJbFqg0dw7Y=; b=jsYSBHtll7SWI36OzbelpQca2Fwg2E/XU+PWy9Mk5O/1kAqQqdSk5rRP/aQwFk0Gut e76hK14wijPjAfpC0veKK88jYnMXw+P336ymGxWut+82FdaYsMr+m2jRvCYWLJclvWSw hTCMsza2t7ZwtyJviXOd+04tY28QYdP2ufwMCAeifxEhi4K4YSaWwsDFoKovQCAe4LZc oslbAIyli2XkXM9u4LrABghP4rW0knYW0bYV05kTnhnCOGkZaIAiR+Zv9S0lCq9Ddmxv VbTWY9ByWv/DPPjB5HpvVax56mqs31EjMLBtpD/r995pdOlrkXRv1biTaJqKDy2rFkY+ 01tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EcbDwjC6e+J4fqPVguK3ypyyOSloNImurJbFqg0dw7Y=; b=bhXhYL3EhitnW0wIo7C6VB/C+UFZzp5OjUZfPYf+f6ISytytB/rDh6DR4tgYDVuAxk lJFawW7cSsZbD5jG1ZnIyGClBfHegpCahpypXS0eJJ4tC1LneqOiP7F5vRf79ptRHHPC OZDm7LYZn+H4kZHXQ6oW3x+MIsPZgDz18CEahyjHyva9wfU8geckkx/DQ8CbsgApCzW2 cuqlBm2OwRrHsJzc7+LqFzX5b2OZe6009oRtr8gW9+dA3licgJw/sdjkiDnXczaplmJJ xJ1dhDII6m+bwMEb2LjmPBfAsxG85dSFlgKdVYdCHb18lFjy5cuLsYtehSdEurToTaCs zSew== X-Gm-Message-State: AOAM533RVQnV6ph175QNZrLjednNdzDIVpLETMvG6we5W9k/jPdRKIVd CB4FrbU3wtbEHqfqU9Ln2fqcrmzAwiAiSB3X1N84Hg== X-Received: by 2002:adf:e387:: with SMTP id e7mr2470525wrm.70.1591245625299; Wed, 03 Jun 2020 21:40:25 -0700 (PDT) MIME-Version: 1.0 References: <20200602184212.10813-1-bshanks@codeweavers.com> <20200604001243.GA24742@ranerica-svr.sc.intel.com> In-Reply-To: <20200604001243.GA24742@ranerica-svr.sc.intel.com> From: Andy Lutomirski Date: Wed, 3 Jun 2020 21:39:59 -0700 Message-ID: Subject: Re: [PATCH] x86/umip: Add emulation/spoofing for SLDT and STR instructions To: Ricardo Neri Cc: Brendan Shanks , LKML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , X86 ML , "Eric W. Biederman" , Andreas Rammhold , "Moger, Babu" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 3, 2020 at 5:12 PM Ricardo Neri wrote: > > On Tue, Jun 02, 2020 at 11:42:12AM -0700, Brendan Shanks wrote: > > Add emulation/spoofing of SLDT and STR for both 32- and 64-bit > > processes. > > > > Wine users have found a small number of Windows apps using SLDT that > > were crashing when run on UMIP-enabled systems. > > > > Reported-by: Andreas Rammhold > > Originally-by: Ricardo Neri > > Signed-off-by: Brendan Shanks > > --- > > arch/x86/kernel/umip.c | 23 ++++++++++++++--------- > > 1 file changed, 14 insertions(+), 9 deletions(-) > > > > diff --git a/arch/x86/kernel/umip.c b/arch/x86/kernel/umip.c > > index 8d5cbe1bbb3b..59dfceac5cc0 100644 > > --- a/arch/x86/kernel/umip.c > > +++ b/arch/x86/kernel/umip.c > > @@ -64,6 +64,8 @@ > > #define UMIP_DUMMY_GDT_BASE 0xfffffffffffe0000ULL > > #define UMIP_DUMMY_IDT_BASE 0xffffffffffff0000ULL > > > > +#define UMIP_DUMMY_TASK_REGISTER_SELECTOR 0x40 > > + > > /* > > * The SGDT and SIDT instructions store the contents of the global descriptor > > * table and interrupt table registers, respectively. The destination is a > > @@ -244,16 +246,24 @@ static int emulate_umip_insn(struct insn *insn, int umip_inst, > > *data_size += UMIP_GDT_IDT_LIMIT_SIZE; > > memcpy(data, &dummy_limit, UMIP_GDT_IDT_LIMIT_SIZE); > > > > - } else if (umip_inst == UMIP_INST_SMSW) { > > - unsigned long dummy_value = CR0_STATE; > > + } else if (umip_inst == UMIP_INST_SMSW || umip_inst == UMIP_INST_SLDT || > > + umip_inst == UMIP_INST_STR) { > > + unsigned long dummy_value; > > + > > + if (umip_inst == UMIP_INST_SMSW) > > + dummy_value = CR0_STATE; > > + else if (umip_inst == UMIP_INST_STR) > > + dummy_value = UMIP_DUMMY_TASK_REGISTER_SELECTOR; > > + else > > + dummy_value = 0; > > Perhaps you can return a non-zero value for SLDT if it has an LDT, as > Andy had suggested. Maybe this can be implemented by looking at > current->mm->context.ldt > > I guess the non-zero value can be (GDT_ENTRY_LDT*8). You could probably even get away with always returning a nonzero value. After all, an empty LDT is quite similar to no LDT. --Andy