Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp579690ybt; Wed, 17 Jun 2020 08:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk3cZxezuzfUa7IzMjAFXCMYxArlIZFJkxvcKdqtQvIMW881obkDkVJ7N4LUAbUnUoaQLu X-Received: by 2002:a17:906:7c56:: with SMTP id g22mr7900671ejp.507.1592408073077; Wed, 17 Jun 2020 08:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592408073; cv=none; d=google.com; s=arc-20160816; b=QH+xGAC8n612Unf9JrY4+HQDnEJ46uNFsGQ/uVs71Wpd6dnLbmY6PbHJoRu+NCdtsB Ije8rrB7UVBgfU62xZTKb1DrYd0zv/oyKzH/NcAK7ZdzvKo1dSCtOWfJ2KeB8tTV7bv4 u+zZ0da8OOnRFc1ZW+ffIQPzHEx0C6/GyWFeka2ikZyQ0iEDTQcQ88zlhe8n5oNpdiDV aAyykDygado0egkN3SrjqeoP2qOfLbEiQ6ZYPOfed8NjkZCa5xPD4SdZis2XRqtESKNd tMyIUr8wnWupAV7Dgzg28qQWQpauCnGghH6Spk0c1tgov2/rSkNyEz36teiuAg0mIdnU UA8A== 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=XzuFJr+z38abHyDJT1M3HNwIucjiKS45llqpq/HQRxc=; b=qTKCTgnDFpkYgrK217t5rAnZllxVeHM18wGnvxXULfjEo5D7HZWD5xRPMrw4CYaGtr u0iJyB2anyvmAI/ZOSYfhnWUaRyckFK732XOQFggkIElQY0yQpYZYOM52OO8F8RQtYag l7jtBhVPS1fdl0oCxa1ujVA10ijjfRu3tOtPq+DnEdm6nJUiaPUCCEbgXMtFBVxyTx8v rkbBBG2G+gcMlBHl7ddTQL22Sd13LOCesPMvB1pD05gLjO2ejDZFV010+3cT25PlRbd+ zJ6vuneDEh13phE7/oZqVkkATZLgsPCB55OmyHnuXIOw+ikJwoR6Ytooq9phCNvlCOha 2QFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m8E4I8fP; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id md18si124844ejb.275.2020.06.17.08.34.10; Wed, 17 Jun 2020 08:34:33 -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=@kernel.org header.s=default header.b=m8E4I8fP; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbgFQP36 (ORCPT + 99 others); Wed, 17 Jun 2020 11:29:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:33000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbgFQP36 (ORCPT ); Wed, 17 Jun 2020 11:29:58 -0400 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 205F420CC7 for ; Wed, 17 Jun 2020 15:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592407797; bh=27jdkWmDRhhCwAMVdzVBNUCaMhK3ANLmpo6tDzme/RY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=m8E4I8fP6RGkvsWHgoknUnkuc8ycHHihswytSXi0vOMfarjSX/vKNYOQbZCYirpJ6 c+x6u/nfAEbMdakQHJLhYn22GlGz0CY8+uK6fcid7nztrcpcl2vBDSjexLE/SY95fS Eseay/9LVF+5kSGvGguIjHnmw9OocqZ+PR3tQd00= Received: by mail-wm1-f54.google.com with SMTP id t194so2449448wmt.4 for ; Wed, 17 Jun 2020 08:29:57 -0700 (PDT) X-Gm-Message-State: AOAM533vSZ3dH6BkA0Dy54RhB6KmDqdnC+lxtEXDxFbM+CB+kLUKXIcD x5+keqeDn6BMduFqwqsffH4wdC6nwEa5iEO6pUcutg== X-Received: by 2002:a1c:46c3:: with SMTP id t186mr8801236wma.36.1592407795664; Wed, 17 Jun 2020 08:29:55 -0700 (PDT) MIME-Version: 1.0 References: <20200616074934.1600036-1-keescook@chromium.org> <20200616074934.1600036-4-keescook@chromium.org> In-Reply-To: From: Andy Lutomirski Date: Wed, 17 Jun 2020 08:29:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/8] seccomp: Introduce SECCOMP_PIN_ARCHITECTURE To: Jann Horn Cc: Kees Cook , kernel list , Will Drewry , Christian Brauner , Sargun Dhillon , Tycho Andersen , "zhujianwei (C)" , Dave Hansen , Matthew Wilcox , Andy Lutomirski , Shuah Khan , Matt Denton , Chris Palmer , Jeffrey Vander Stoep , Aleksa Sarai , Hehuazhen , "the arch/x86 maintainers" , Linux Containers , linux-security-module , Linux API 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 17, 2020 at 8:25 AM Jann Horn wrote: > > On Tue, Jun 16, 2020 at 9:49 AM Kees Cook wrote: > > For systems that provide multiple syscall maps based on architectures > > (e.g. AUDIT_ARCH_X86_64 and AUDIT_ARCH_I386 via CONFIG_COMPAT), allow > > a fast way to pin the process to a specific syscall mapping, instead of > > needing to generate all filters with an architecture check as the first > > filter action. > > This seems reasonable; but can we maybe also add X86-specific handling > for that X32 mess? AFAIK there are four ways to do syscalls with > AUDIT_ARCH_X86_64: You're out of date :) I fixed the mess. commit 6365b842aae4490ebfafadfc6bb27a6d3cc54757 Author: Andy Lutomirski Date: Wed Jul 3 13:34:04 2019 -0700 x86/syscalls: Split the x32 syscalls into their own table > > 1. normal x86-64 syscall, X32 bit unset (native case) > 2. normal x86-64 syscall, X32 bit set (for X32 code calling syscalls > with no special X32 version) Returns -ENOSYS now if an x32 version was supposed to be used. > 3. x32-specific syscall, X32 bit unset (never happens legitimately) Returns -ENOSYS now. > 4. x32-specific syscall, X32 bit set (for X32 code calling syscalls > with special X32 version) > > (I got this wrong when I wrote the notes on x32 in the seccomp manpage...) > > Can we add a flag for AUDIT_ARCH_X86_64 that says either "I want > native x64-64" (enforcing case 1) or "I want X32" (enforcing case 2 or > 4, and in case 2 checking that the syscall has no X32 equivalent)? (Of > course, if the kernel is built without X32 support, we can leave out > these extra checks.) No extra checks needed. Trying to do a syscall with a wrongly-encoded x32 nr just generates -ENOSYS now. Henceforth, all new syscalls will have the same number for native and x32 and will differ only in the presence of the x32 bit. --Andy