Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2430482imm; Sat, 15 Sep 2018 17:33:23 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdap+NmSennTTUY2L9YqnK5W/IwqQ62d46mowPy15ROd0mZjCwmsb9dQbBtHWSZ+qlveUU2R X-Received: by 2002:a17:902:4d46:: with SMTP id o6-v6mr826535plh.59.1537058003497; Sat, 15 Sep 2018 17:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537058003; cv=none; d=google.com; s=arc-20160816; b=XvpA7c9NZwV8lew+Mt2wpW5EIFgnLGn1UQnjMg4Ke80Cs2fu6bu346UIPVmbW0ZDKY 0GlcDqoreHeIDHpruZSDQwTDHcetY0FBkuwkTy+oKA/N4+wu1kLqgt29NtxL4tlIMBwB cTireB6o2w3QOHURiE+jpHlzf9hdn4fHwRI6CerIJD3PuRzHVjn/+St23Q7B9WiQxlKO JgMDHe5NoVGWp5GdwU5aTqp+GxU7dwbi96OrchJC7WtqtDHDQcHTTWzXPd6wX7Wg+Rr/ HnwZv7jS7690NoonPX9BNdFJOOGRDl2Um9GCruTArpau2+S2fNBxmG3XaHWrJUDFZF7U Y4MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=skFzPzxzOZl4iyQuC6Z8yj0y3sADXmPouVrNkO4jtDo=; b=Wd6oCqQVnxMfBG396UryH6mXU7w60bMZWB2bZJDCQzKg6xIZB74J+QLVocPZS5Qoce 8gyYiJX6T/ZYU/u4RIKJ/QgHtho+ZXWFallZQ3Ollea7zqSkLMcBDwLzYM3dXPH3EfvW i5iicvfn/zpweLyCxdpxcyogX0RG2IttZkee1J2KoSsH6DLR9+hzwEnFG3hbvt/OaRX5 jhubvznbVp0g2c38XSJjgs6GkOy4qmodAYKtvpic5b0esc4Kon0qDfNl6qCjF89jI1tq jaxFljKCbtzh3frnoG6MjOtNF8WhB/pbbInW7ynzR3+d9ODB8jIOwzPZe2nZrOIb5MdA /f1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eTuvNzJn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si11950090plw.81.2018.09.15.17.33.08; Sat, 15 Sep 2018 17:33:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eTuvNzJn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728307AbeIPFwN (ORCPT + 99 others); Sun, 16 Sep 2018 01:52:13 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35363 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728155AbeIPFwN (ORCPT ); Sun, 16 Sep 2018 01:52:13 -0400 Received: by mail-pf1-f195.google.com with SMTP id p12-v6so5932050pfh.2 for ; Sat, 15 Sep 2018 17:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=skFzPzxzOZl4iyQuC6Z8yj0y3sADXmPouVrNkO4jtDo=; b=eTuvNzJn6KqDg8oPBKc/yDGccl+470XP8MInsGrUdrso5dzfm3rh7EwCrZVGO9o59u rfDH04CEdgK60Hj/r29SJzXbanLzEuMbJdrTaHBAz4kcxSeELUHB80W9CDnP6QT1gxuQ 5Vjcz8hkS5JlrJUxsTkJQNk19l/wSz5OMlmr8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=skFzPzxzOZl4iyQuC6Z8yj0y3sADXmPouVrNkO4jtDo=; b=fRS9sAOlXi/26ZDcXovVA3Z8Lg17/pLYrSDjVgEbfxAAIzGv22BLwL8N0P+S76AraG rFoX5wVm5K4NvMMnC3NnUhsBQQ/F8L4xRSf9c7Ca0mUfAvSvcF/g86PCi/L0RgdrsVPS HGMYq/XJOg7XXS0ve8WfKm8FijRDWyRiMlzvot4JjX0zgUlILXecQ4jCj7SZd7ehCbpg T+Oa29cdePbx+szlcj2NCh2DBj9/0mp0Ymm3J4Ee8NGeiPYigLGKMFmDkUV6blS1o3oy kXTZHe4XOiv/O0oIwSEax6AJtdv0iSUcpwPo05sUAilai0Vn7HcB2r6bjIono++fqgf7 A6Bw== X-Gm-Message-State: APzg51Diqx5Xl/dFFlP+807B99JnI7kSLbaR/yxklu2Ayem4FTtzA6Mn Ru67lAh49DkeaWSNht22GdMRqA== X-Received: by 2002:a63:f751:: with SMTP id f17-v6mr17924670pgk.410.1537057876820; Sat, 15 Sep 2018 17:31:16 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id c78-v6sm14842149pfc.188.2018.09.15.17.31.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Sep 2018 17:31:14 -0700 (PDT) From: Kees Cook To: James Morris Cc: Kees Cook , Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , LKLM Subject: [PATCH 12/18] LSM: Introduce ordering details in struct lsm_info Date: Sat, 15 Sep 2018 17:30:53 -0700 Message-Id: <20180916003059.1046-13-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180916003059.1046-1-keescook@chromium.org> References: <20180916003059.1046-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only minor LSMs have any ordering currently, but only capabilities actually need to go first, so provide either "absolutely first" or "mutable" ordering currently. Default order is "mutable". Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 7 +++++++ security/security.c | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 6e71e1c47fa1..89e6ec8eac07 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2044,10 +2044,17 @@ enum lsm_type { LSM_TYPE_MINOR, }; +enum lsm_order { + LSM_ORDER_FIRST = -1, /* This is only for capabilities. */ + LSM_ORDER_MUTABLE = 0, + LSM_ORDER_MAX, +}; + struct lsm_info { const char *name; /* Populated automatically. */ int *enabled; /* Optional: NULL means enabled. */ enum lsm_type type; /* Optional: default is LSM_TYPE_EXCLUSIVE */ + enum lsm_order order; /* Optional: default is LSM_ORDER_MUTABLE */ int (*init)(void); }; diff --git a/security/security.c b/security/security.c index 3fedbee5f3ec..19afd7949426 100644 --- a/security/security.c +++ b/security/security.c @@ -96,10 +96,13 @@ static void __init maybe_enable_lsm(struct lsm_info *lsm) static void __init lsm_init(enum lsm_type type) { struct lsm_info *lsm; + enum lsm_order order; - for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { - if (lsm->type == type) - maybe_enable_lsm(lsm); + for (order = LSM_ORDER_FIRST; order < LSM_ORDER_MAX; order++) { + for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { + if (lsm->type == type && lsm->order == order) + maybe_enable_lsm(lsm); + } } } -- 2.17.1