From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 109DBC433E1 for ; Thu, 20 Aug 2020 21:09:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9F0820FC3 for ; Thu, 20 Aug 2020 21:09:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KFYniuhU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728684AbgHTVJd (ORCPT ); Thu, 20 Aug 2020 17:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726806AbgHTVJa (ORCPT ); Thu, 20 Aug 2020 17:09:30 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B13FC061386 for ; Thu, 20 Aug 2020 14:09:30 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id j21so1724240pgi.9 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=U7xDWm2R2z6ZRXDEHZ8/r7f3iRc4InzE/ZEq7DqUknSExLuC5Nqs8i+7x7Z4vmAg8r 0OVHqbTiuSAK4zUejBUjnp7uJKmyJ2vRKqEKPLzXspT9G8D/yrA7OM+6HjivQEh08gtJ CtZD2MsguTa979vUU1LDGnqHium53E3r0yZ+KQG3jidwsFT5n4w6TJap55uxdebH60lJ 0PDH5jPGjTvMmDCJUpE7zCW2y1FSTEyhNKIfKjDzYAX3S1p2j3KBGnOIfYqf+pV1/pjq 4OtE2P9Zq0tzcKca1goN3hpJ8DKxl1/Vd9MCSfB3v/gvLNku3LFXPm9SF2xg6K82gbbO Ry1Q== X-Gm-Message-State: AOAM533wnZGXvJNDyIz0mZlQs0Ldh2x3uPC8EQhJ6UmFKo1ZMX84SK6O yD1l2bgUkxJLVgoHNQTF+9QHU84vsGHXvQ== X-Google-Smtp-Source: ABdhPJzOdlZPLpvYzaIPGI9VzyzZNO0QSe5HCusBzEZ5k6gseQIYvoR42UFn1kWQeXXeIPfqkQAIZw== 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: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@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