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=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 4755AC83000 for ; Tue, 28 Apr 2020 16:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27851206D8 for ; Tue, 28 Apr 2020 16:19:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zv3u9Zv8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbgD1QTR (ORCPT ); Tue, 28 Apr 2020 12:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbgD1QTQ (ORCPT ); Tue, 28 Apr 2020 12:19:16 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09941C03C1AC; Tue, 28 Apr 2020 09:19:16 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id z25so33541971otq.13; Tue, 28 Apr 2020 09:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c1EsjSooPyqCnBO664DNonHfMUSKi8/7rikFXFsVYdo=; b=Zv3u9Zv8TiofchaTvuqN5JwJqvonwFHSTFFbjYh3QeCWjLqyuXW6BryCjmAx0Uxxk0 0gP98On9XwU0NztiNgBQS/dz2UoGE3rYWrhcfH1wUhyKT6/nxhDB2BgJlJDLE3Rdtm6n AJC5dct6VBPTWAc1df/VNdn3j1TdT33vcIIRp/7ldhyqnkApW4iyV74xa+IUxSX2bUPM nyXDNVIp4atlEOcpcPS1vFhzUdHOYkCLBW4VyaoEdh5kD33ukSqxj81qr1JZGwsmeKMm whnoqvpzGCO/KpAHxCkkDsNVU64o7Gy1OXtNsYkZ+0Nzsyj8dXEhNZN+0M66ddIgBn2x OkLg== 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=c1EsjSooPyqCnBO664DNonHfMUSKi8/7rikFXFsVYdo=; b=fUCfKZtWCQBDIoAYs3MEKFxWGfD/4IUUuYgexqIVO/i1m1Nc1Vl2YpVogwJD08msru ZKLUunLEnT1Hz4rOmnuR8anXA+J//IxDZgfwPiMtau5C573EKRmR8K/ygSHbkyrvPiUG U0uDIMDo1MkS/sjbqz8VvlUPLKoD8pNAj+XuG8n6U2rfttxrvPToNnTQU/RjU3M3ATNs tnnrp1Rn02xiuad9XZzRGs7G27APxj3djbuTkz+kjS7MA47YC4+95bt1KtBZ/FRZW5S2 3We1ZNWC3F2muIvWkW5lQ7S7jzvkblbFqYxNVgCKHfXiP784JUUoeA/uB7CiFo0XgAAP JWoA== X-Gm-Message-State: AGi0PuZkzvo8C375MSHQsye0f9khilY9I/xgtIHhab6f+XqMt9j4h/LP aHtBf1KdfG0Po0oSzWEgy+DglhONOhOMSOppDz0v1A== X-Google-Smtp-Source: APiQypKEsLKypKBFMaeTK5Vu/aRzLy34dr52xJcb9/VoDVzJrtdC3yjEMYpVolT91E1KkbeGKxf3ZCu8aozNcyXMnrw= X-Received: by 2002:a9d:6952:: with SMTP id p18mr21913401oto.89.1588090755407; Tue, 28 Apr 2020 09:19:15 -0700 (PDT) MIME-Version: 1.0 References: <924658.1588078484@warthog.procyon.org.uk> <1072935.1588089479@warthog.procyon.org.uk> In-Reply-To: <1072935.1588089479@warthog.procyon.org.uk> From: Stephen Smalley Date: Tue, 28 Apr 2020 12:19:02 -0400 Message-ID: Subject: Re: [PATCH] selinux: Fix use of KEY_NEED_* instead of KEY__* perms [v2] To: David Howells Cc: Paul Moore , keyrings@vger.kernel.org, SElinux list , LSM List Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On Tue, Apr 28, 2020 at 11:58 AM David Howells wrote: > > Stephen Smalley wrote: > > > 1) Are we guaranteed that the caller only ever passes a single > > KEY_NEED_* perm at a time (i.e. hook is never called with a bitmask > > of multiple permissions)? Where is that guarantee enforced? > > Currently it's the case that only one perm is ever used at once. I'm tempted > to enforce this by switching the KEY_NEED_* to an enum rather than a bitmask. > > I'm not sure how I would actually define the meaning of two perms being OR'd > together. Either okay? Both required? Both required is the usual convention in functions like inode_permission() or avc_has_perm(). But if you know that you'll never use combinations, we should just prohibit it up front, e.g. key_task_permission() or whatever can reject them before they reach the hook call. Then the hook code doesn't have to revisit the issue. > > > 2) We had talked about adding a BUILD_BUG_ON() or other build-time > > guard > > That doesn't help you trap unallowed perm combinations, though. I think we want both. > > > to ensure that new KEY_NEED_* permissions > > are not added without updating SELinux. We already have similar > > constructs for catching new capabilities (#if CAP_LAST_CAP > 63 #error > > ...), socket address families (#if PF_MAX > 45 #error ...), RTM_* and > > XFRM_MSG* values. > > David >