Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1570877pxa; Thu, 20 Aug 2020 15:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlOVx5uUof9dkXSfYZAo0DMgunqrkyQHiSzMIOgebT1/F1DSPflcoce2P4RIfwdm1gxwPq X-Received: by 2002:a17:906:f847:: with SMTP id ks7mr780874ejb.402.1597960867800; Thu, 20 Aug 2020 15:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597960867; cv=none; d=google.com; s=arc-20160816; b=jlmj1PvZOyTljZ6WNDpBf8vw8yksPYVEXWA6uYAhrMkU41NFRjYlpxrs7SBaiI9ai2 +PNllQhnqPBwwqztvxmeD8vSxnwBqWu5HTodPa1vQADItfpXSHIOjxM4zawfWLqfXs/a inlBrJOLpgKvUxE7s4o71ShkfbuBdoDBKqsGZmy86algztnCpNgSM6OQ9jGxiOE4GWsx bojrDfFWNr1FjmybGqVK3GRVWdRk2xgE15NbUvk/aBEIH6Y4jKU+NMpv4pbXp6/xbbnB JH8GwXzke9yM7WSqzBOd2cWa31hoE+QVD/tf3Y5mlMQUUDFO6xIzz7JyTT1VEnOiMr87 IM1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UjiSaglQ75jI6j88glVf44Uda/sc/Nr405Wx3MU9i90=; b=KA0nhMp3F121S7AbDxrAdZ1Px8ChXS5Yr9n9nbxzXqZUmj9rdSXC99mTUWMLXb3dzy tUdXC1q58qaXccYp89DHZ1mx6ILkdU7ZNK78VTvN2bu10l/RsczzMBNFT7CVXxM+uM3F CBrA7Qx/+x+n5euAxrR547CZXNLlHGkUx9/7le6TWnxdDAnTleBHJW441kYGoaTf2425 DMzuOZMPx917/bR6iVfXoGC8CUGq1j2dley3ZR9PgEhC/fz0o/ZpXJZZk4DuuTZ6Ycrh X1vbtmhnANk5cSOnkzx/ozwqdSkVrgoeIHIjf0VzIu8CbL4JcxN6usq2Fle+XMDxxCDl sUmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KFYniuhU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f23si2055706ejc.740.2020.08.20.15.00.44; Thu, 20 Aug 2020 15:01:07 -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=@chromium.org header.s=google header.b=KFYniuhU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbgHTVJd (ORCPT + 99 others); Thu, 20 Aug 2020 17:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725859AbgHTVJa (ORCPT ); Thu, 20 Aug 2020 17:09:30 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42845C061385 for ; Thu, 20 Aug 2020 14:09:30 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 128so1729904pgd.5 for ; Thu, 20 Aug 2020 14:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UjiSaglQ75jI6j88glVf44Uda/sc/Nr405Wx3MU9i90=; b=KFYniuhUyJt0GJ/A5NuqlGTAZAU0+V6ncRNsqE69SnlvmWq3pPM1dcbNXIRc0yOFfS ntNdLnM8VpRXyXQP28VGNro2B+sblcS3igMaecVpFUisMoLpkoaihi/0QtfLnd9fSxle qS3nnwfCInkPpXuf33rVOZB3rs20oebdgTRl4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UjiSaglQ75jI6j88glVf44Uda/sc/Nr405Wx3MU9i90=; b=fQ+pEJiBuk7jt5txedvEOi3Df1GiWsQyaf/tP68H1pjWxXwWLI5ZgG/eYoOFbK+C4O xp5xyBBdYtW/ytHZYDaRmsxyvM0H7Ua0vpi8yQyGOO2oGMyeHH/vibDEK2g5zcHB+wcp 68rors/TmN20vGeGOAaKtS51qBlhbHsxLdjLDujmdiEsdAEq2Sgd/Hxun8eQ1v4Prbg/ Pk2YwX71LeeMb5t66xqyGUz5/1anx+c3G1cvQbGRi2duP/kmBqpm/CnMXeAShcpR4172 ouPue4xUQaOoXXF8a30HJy1PtzJQc8EdkBepJ8LH3ZyHn69pBjfPJ7vZDHqBLcFmVfLm 87uA== X-Gm-Message-State: AOAM531/RvKmfCYXKc+Com5dHOYEk4U4V4zx1b1vO/hFhkcbAT4hBKhx 1n9t6rGjbJ6HH8bzURsrSarfgw== X-Received: by 2002:a63:b51a:: with SMTP id y26mr456024pge.376.1597957769546; Thu, 20 Aug 2020 14:09:29 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g5sm3824348pfh.168.2020.08.20.14.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 14:09:16 -0700 (PDT) Date: Thu, 20 Aug 2020 14:09:15 -0700 From: Kees Cook To: Thomas Gleixner Cc: Kyle Huey , Robert O'Callahan , LKML , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , linux-arch@vger.kernel.org, Will Deacon , Arnd Bergmann , Mark Rutland , Keno Fischer , Paolo Bonzini , kvm list , Gabriel Krisman Bertazi , Sean Christopherson Subject: Re: [REGRESSION] x86/entry: Tracer no longer has opportunity to change the syscall number at entry via orig_ax Message-ID: <202008201404.6A0D5736@keescook> References: <87blj6ifo8.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87blj6ifo8.fsf@nanos.tec.linutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 09:44:39PM +0200, Thomas Gleixner wrote: > On Wed, Aug 19 2020 at 10:14, Kyle Huey wrote: > > tl;dr: after 27d6b4d14f5c3ab21c4aef87dd04055a2d7adf14 ptracer > > modifications to orig_ax in a syscall entry trace stop are not honored > > and this breaks our code. > > My fault and I have no idead why none of the silly test cases > noticed. Fix below. Hmm, which were you trying? Looking just now, I see that the seccomp selftests were failing for all their syscall-changing tests. Regardless, I can confirm both the failure and the fix. Reported-by: Kyle Huey Tested-by: Kees Cook Acked-by: Kees Cook kernelci.org is *so* close to having the kernel selftests actually running with their builds. :) https://github.com/kernelci/kernelci-core/issues/331 -Kees > > Thanks, > > tglx > --- > diff --git a/kernel/entry/common.c b/kernel/entry/common.c > index 9852e0d62d95..fcae019158ca 100644 > --- a/kernel/entry/common.c > +++ b/kernel/entry/common.c > @@ -65,7 +65,8 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall, > > syscall_enter_audit(regs, syscall); > > - return ret ? : syscall; > + /* The above might have changed the syscall number */ > + return ret ? : syscall_get_nr(current, regs); > } > > noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) -- Kees Cook