Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp5028392pxy; Tue, 27 Apr 2021 19:07:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyENtbJy9IBNmEhTtZUSn89JHEL+gXI8/OptIhJx4DeoiwOkeze0210Lixc8jfnsffqmYmF X-Received: by 2002:a17:906:6ace:: with SMTP id q14mr27355016ejs.79.1619575646813; Tue, 27 Apr 2021 19:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619575646; cv=none; d=google.com; s=arc-20160816; b=UuwB976EBzWsUM3w385jCi1kDfWuGljmsPdd2mLcIQS+sTMJSnJn/hF6Sdb9lHWH8d 6IzLhggtz3oTbON1XWeUTi/yyRqqM6M1E5kgxduFZOsjw/vh7CcCS/bAQNzPvndrlkcE jarhoDCEtoDATrIx2pZsWGzP2vGBeQObTa+sYhUREWr3rjk+g3RcPOpaMx67aItgK9kQ R1ziE8RfiTbXxOiTPVxMlxzULasRwOxEGUlI16BD55d09NGz5zvqYqpNMzBQFJVgi9p7 isNaqB7cXKoPWwHaYL7ahzskFIv6gd5M9CB78ej/KXuBrzZ8AzxdizPdWEsWNwwjmscU 0QvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K+/8ltcSzj4pSeYeJlp5W8nRAMi5XqdxM0qLV1h4WPc=; b=PqlzMHxpJbyeJG/I5l5WBhVbisVa0VJTAX3HIaqtnQ0rw4uWV2D72Q+o/2bR0PFt75 hE0RtZc8MJVW1M6dFUdo3ShJaKg29O6bMut9ECMymmlUMSMp+kBOm8uI/SSo7O9XEvzG ORTPrmMrjbdOld9pcThAHvKnptP511lhqxnvLiKxcY7F+nsGFkVgJ0W8ZKNBKqExlFdg 9mVJCwf2OTUAOHFrE8AHKy/xFbhmVUXN20kuunEYYzwXb1Ab+4jXNmyl3zN9VFeGoleN pezFWYVKD1O5dhA6Z03/WJhObYaZYooU6x7QuHENl/q0I6XG93/GH3FljBECUI6sGG3N T2cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cHr7TQZu; 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 v26si1507702eje.15.2021.04.27.19.07.03; Tue, 27 Apr 2021 19:07:26 -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=cHr7TQZu; 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 S238227AbhD1CGp (ORCPT + 99 others); Tue, 27 Apr 2021 22:06:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235984AbhD1CGo (ORCPT ); Tue, 27 Apr 2021 22:06:44 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03F7C061574 for ; Tue, 27 Apr 2021 19:05:58 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id q2so10715294pfk.9 for ; Tue, 27 Apr 2021 19:05:58 -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=K+/8ltcSzj4pSeYeJlp5W8nRAMi5XqdxM0qLV1h4WPc=; b=cHr7TQZuhTt9nEbf4BGsvSxM9oRZVh4iXC1Hg7xHRZu0NscWQN4Frnenp7jQNl/63x j+7aaXvpZntmVwR1xNnuxtkJjsgsKIMQ8s/Qzxxe439zNf9VxIermbBj9GYjmp088LDZ rChKWyFpSrmY+yNa3JzjnqkRWUXF5k78BHy0o= 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=K+/8ltcSzj4pSeYeJlp5W8nRAMi5XqdxM0qLV1h4WPc=; b=uZTvsIMoDiuaV9eb10kUGvYr0uCQIUZ6tOtU4cnIXPRmgKjRNX2ZyFaRNedolToGfz abLrDsaY6BjxaJjvUxglXhNVrcGMRsVpiakEVyixMKc8Wig9dhh7bbd8LSBRIt/WT+8Q 4wn3m/X6fYcE/K5o+yT1RgrxDqYwZ94E8gY7sDfSX5fBMT0IXjzOPM2TTqhgfzu8ViEa ZORrNoMBae86GdxWhVglmthAF8bOxUSUKv8buZVBMWrEJ9YpWgEUoFsioakQSdekHJ/n TA+Fr0iwEui9VVVv1RbG0x5auh/Jx26gn+Qa8t2Y2KYOMoky12ybRXetfaBGcWHj5K6G BCCA== X-Gm-Message-State: AOAM531h5/Na2+5aZadFZpEnTjxiqfFor1By1xCBxaTZqyDogpGPaLNB 35dr0oXMP9Bfy+o5PLqix0u4bg== X-Received: by 2002:a05:6a00:1742:b029:27a:218b:5a85 with SMTP id j2-20020a056a001742b029027a218b5a85mr7128173pfc.64.1619575558452; Tue, 27 Apr 2021 19:05:58 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id f3sm855747pgg.70.2021.04.27.19.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 19:05:57 -0700 (PDT) Date: Tue, 27 Apr 2021 19:05:56 -0700 From: Kees Cook To: Andy Lutomirski Cc: "H. Peter Anvin" , Linus Torvalds , Ingo Molnar , Thomas Gleixner , Andrew Lutomirski , Borislav Petkov , linux-kernel@vger.kernel.org, oleg@redhat.com, Will Drewry Subject: Re: pt_regs->ax == -ENOSYS Message-ID: <202104271857.4708C9A25@keescook> References: <202104271619.0DBE456@keescook> <78327AF2-575F-415E-98D4-6ECDFE311D0F@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <78327AF2-575F-415E-98D4-6ECDFE311D0F@amacapital.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 27, 2021 at 04:51:06PM -0700, Andy Lutomirski wrote: > Fortunately there is not, and never will be, a syscall -1. But I > agree that calling max syscall + 1 should behave identically to calling > a nonexistent syscall in the middle of the table. If that happens, we have to separate the meaning of -1L from ptrace, seccomp, etc. (i.e. we can't just add an "else { result = -ENOSYS; }" to the syscall table dispatching code, since that'll overwrite any written return value when the syscall is meant to be skipped with a specific return value set by ptrace/seccomp. syscall_trace_enter() will currently return either -1 or the syscall. Which means someone making a "syscall -1" will get the skip semantics currently (though the preloaded -ENOSYS results in the "expected" outcome). arm64 recently had to untangle this too: 15956689a0e6 arm64: compat: Ensure upper 32 bits of x0 are zero on syscall return 59ee987ea47c arm64: ptrace: Add a comment describing our syscall entry/exit trap ABI 139dbe5d8ed3 arm64: syscall: Expand the comment about ptrace and syscall(-1) d83ee6e3e75d arm64: ptrace: Use NO_SYSCALL instead of -1 in syscall_trace_enter() -- Kees Cook