Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp574702ybt; Wed, 17 Jun 2020 08:27:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt/Z2mXtHqQEaFCe7l6I/zGtsyzd99pOhxhhdql2yFeK+YnrXr9l7Kb75hOzwyF1SJuZil X-Received: by 2002:a17:906:4d14:: with SMTP id r20mr7791852eju.346.1592407671921; Wed, 17 Jun 2020 08:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592407671; cv=none; d=google.com; s=arc-20160816; b=HOmj9lc22IDosy14V0OFsE/T0ZOkyV1lRKt5Brivlpl770k7aOZz8L/c7nwSV2QbG1 pjr39QsBp64k+bdGyFiXyybgwQhNtMrL74iNqmzQopbQ1mK7kcG/FEMVUnt39jWa1crc lfSW9T3h0NObdVzby8tevyYa/3El6s2EYyCYxH85gHpGonixjNGgin88lokWxv/ZRVyC pRpz0twPiu47a8CeD6JwxfVSUyfDXojeJYiWdN8MRbfSiqGAyXaq3oYLJUrW+OmSesgB CNikFspMwCf/PyzntYYTWylktT0He/WcoGUFUOljqoPfUQE5RmWC2HcmgEEbtzC84N8M BRZA== 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=I6nIuDWwcfkNRxXhFGKJnyws0bUwaKcz08/Ho8g5tJI=; b=ywATsc3GynZ4bRh+hRg/sF+HKIHgFDo33wx5t63PQIIG5T74qi9LlHS6W6wWdUmWYc qtgWF1wV6rHZ6ype40sGoouG2Ilbp48kU2zakXdmmKDgySbP5Aq/Atq6an7AUtsRaTra kYHBpbMR6WhJAhqDX0J7uqHAHbeYk/Dlnlq2fYB4rwZEfNNtF47VeqTdn2pjXPniMuSH vsTuc8+oYcB9P8Xk4zTur1Pju9YBHFylSoNsiZt4TMfY8U3dPh3//bxGozWUVdz91sdp naHHhyAS4SrGRzqRda1W4+BJQAbREzkYLksMl9cxRSv2A0l3ow5Awb0GkimIqiK3XDC1 AnCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ojk5dxH9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lj13si96943ejb.528.2020.06.17.08.27.28; Wed, 17 Jun 2020 08:27: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=@google.com header.s=20161025 header.b=Ojk5dxH9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726835AbgFQPZj (ORCPT + 99 others); Wed, 17 Jun 2020 11:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbgFQPZg (ORCPT ); Wed, 17 Jun 2020 11:25:36 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3ABC061755 for ; Wed, 17 Jun 2020 08:25:36 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id c21so1555822lfb.3 for ; Wed, 17 Jun 2020 08:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I6nIuDWwcfkNRxXhFGKJnyws0bUwaKcz08/Ho8g5tJI=; b=Ojk5dxH9+DvMUGom64AEv7XfBLXa9lBuwrzwGTnlOsPxiMkrbDSwj3LZ3zSHPWkGyz 9ToRm9j64HKaH0C201cTSBPfUeD4L0jyv5gL+/6/qmIuqmzEXURqwTgpPiQXDB2VaGwF qZGvTCrWNr19Q9uHIQ+fcZ1aHaKDOq/bAgerWk0+0yn6/A9lDR5bDmAYvM4uNp9prxVZ 6DKX/iKAs8nUP3ny4EOtz7D3j7wO3sIdHgCvXEeJ9MwLbCjJEVdGxS6Z/XsWBmYs70uj wm5KADMa/2iKCqFHgyU/T9kpJ7tGuHoa9yFAJtaAAvyHQEClmKdmqy0zBbSl7zmeo1PX BUuQ== 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=I6nIuDWwcfkNRxXhFGKJnyws0bUwaKcz08/Ho8g5tJI=; b=Wd6Kupg5B1btY0m9BGAHwVAYgRCAksH+Dt+735HQHJIC2PRH+lkbv7ufBal0+L2noN UXFYaE78VVPsFCh+fb2FjUinTkgpt3XUwQ5guVTuLsn9WGuVWuBgIBsiZKG+vkHX3lia HJuNhg0XMtwxmdAaAUsnY2cB/3af3s99ekSZIbeEF+58tBjaQAziEffuFWwNhtIf96BX fmH5aMnIlZ+vgcLUniywXTssWMbFL4FWUPPx5prJoc++dP+a2rvACpl5Y9CEkpAYvHM/ l9inJ5KTrRZr5vXL5EWd3aYlwqTF/FZLVuNTihtGnp6B4MnY2wwyqMrTuMsbCB2QBeQn BxnA== X-Gm-Message-State: AOAM531l/EEPt8q9UrgkkEbLTHz0N+6E5b+LR/dozf4xaRS0cLmyjCYl G7ZihzD685nNDL3R3gVLnsujf3/5ybKbjYTuSE3A3Q== X-Received: by 2002:ac2:544b:: with SMTP id d11mr4879243lfn.157.1592407533670; Wed, 17 Jun 2020 08:25:33 -0700 (PDT) MIME-Version: 1.0 References: <20200616074934.1600036-1-keescook@chromium.org> <20200616074934.1600036-4-keescook@chromium.org> In-Reply-To: <20200616074934.1600036-4-keescook@chromium.org> From: Jann Horn Date: Wed, 17 Jun 2020 17:25:07 +0200 Message-ID: Subject: Re: [PATCH 3/8] seccomp: Introduce SECCOMP_PIN_ARCHITECTURE To: Kees Cook Cc: kernel list , Andy Lutomirski , 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 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: 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) 3. x32-specific syscall, X32 bit unset (never happens legitimately) 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.) > +static long seccomp_pin_architecture(void) > +{ > +#ifdef CONFIG_COMPAT > + u32 arch = syscall_get_arch(current); > + > + /* How did you even get here? */ > + if (current->seccomp.arch && current->seccomp.arch != arch) > + return -EBUSY; > + > + current->seccomp.arch = arch; > +#endif > + return 0; > +} Are you intentionally writing this such that SECCOMP_PIN_ARCHITECTURE only has an effect once you've installed a filter, and propagation to other threads happens when a filter is installed with TSYNC? I guess that is a possible way to design the API, but it seems like something that should at least be pointed out explicitly.