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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 79373C433DF for ; Fri, 29 May 2020 09:35:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5186B207D4 for ; Fri, 29 May 2020 09:35:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5186B207D4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jebPW-0002P1-Vt; Fri, 29 May 2020 09:34:42 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jebPV-0002Os-Hm for xen-devel@lists.xenproject.org; Fri, 29 May 2020 09:34:41 +0000 X-Inumbo-ID: 9ec03c6a-a18f-11ea-a882-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9ec03c6a-a18f-11ea-a882-12813bfff9fa; Fri, 29 May 2020 09:34:40 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 77525AC85; Fri, 29 May 2020 09:34:39 +0000 (UTC) To: "xen-devel@lists.xenproject.org" From: Jan Beulich Subject: [PATCH] xsm: also panic upon "flask=enforcing" when XSM_FLASK=n Message-ID: <8a4c4486-cf27-66a0-5ff9-5329277deccf@suse.com> Date: Fri, 29 May 2020 11:34:40 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Paul Durrant , George Dunlap , Andrew Cooper , Ian Jackson , Daniel de Graaf Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" While the behavior to ignore this option without FLASK support was properly documented, it is still somewhat surprising to someone using this option and then still _not_ getting the assumed security. Add a 2nd handler for the command line option for the XSM_FLASK=n case, and invoke panic() when the option is specified (and not subsequently overridden by "flask=disabled"). Suggested-by: Ian Jackson Signed-off-by: Jan Beulich --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -998,8 +998,9 @@ to use the default. > Default: `enforcing` Specify how the FLASK security server should be configured. This option is only -available if the hypervisor was compiled with FLASK support. This can be -enabled by running either: +available if the hypervisor was compiled with FLASK support, except that +`flask=enforcing` will still keep the hypervisor from successfully booting even +without FLASK support. FLASK support can be enabled by running either: - make -C xen config and enabling XSM and FLASK. - make -C xen menuconfig and enabling 'FLux Advanced Security Kernel support' and 'Xen Security Modules support' --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -211,7 +211,33 @@ int __init register_xsm(struct xsm_opera return 0; } -#endif +#endif /* CONFIG_XSM */ + +#ifndef CONFIG_XSM_FLASK +static bool __initdata _flask_enforcing; + +static int __init parse_flask_param(const char *s) +{ + if ( !strcmp(s, "enforcing") ) + _flask_enforcing = true; + else if ( !strcmp(s, "disabled") ) + _flask_enforcing = false; + else + return -EINVAL; + + return 0; +} +custom_param("flask", parse_flask_param); + +static int __init check_flask_enforcing(void) +{ + if ( _flask_enforcing ) + panic("\"flask=enforcing\" specified without FLASK support\n"); + + return 0; +} +__initcall(check_flask_enforcing); +#endif /* !CONFIG_XSM_FLASK */ long do_xsm_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) {