From patchwork Tue Feb 27 11:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= X-Patchwork-Id: 207147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2627159dyb; Tue, 27 Feb 2024 03:16:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3IiobhcblF0mYf8mTWXdYcP953XIU7yzw4txcFBrmxX7LWtGJHF2jnr//mDWIQGzI+O1X57lUvCSDPMFnQEgMyLLgPg== X-Google-Smtp-Source: AGHT+IHinhS5oj6VVoBSGOD6KR+kGOrPBK4d8+qosnNF2GA23urmbBE1Hc55/fnwRxFYYM4Llv0i X-Received: by 2002:a05:6870:4788:b0:21f:7e35:8f4d with SMTP id c8-20020a056870478800b0021f7e358f4dmr12894746oaq.6.1709032567090; Tue, 27 Feb 2024 03:16:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709032567; cv=pass; d=google.com; s=arc-20160816; b=s8VVJoFD91S2tyA5Jwmhl2xJ9yRoRFuiQB50Mls7VNTAMm9QtGjkcuFy6kqGSOJY8O IZZni6MXByE4Cgs9mcE4j1GKaar9PtrQAXu6GBaWHHe6wS4kV1gmp5IKpSXD2zaoz4C0 aQM/hIEb4ni2IQjb0vSWGpCbfQl7Rmus/TmjxG/9q+xY+cunU7FGl5OdX4FpMCaihAf3 fl/mr+N+Pm+ANnEdiQjjrLOiuknPjZuSQSAWipUSio3RuhJieJBE28rBy63muAqd4DRn mvL7WvqjoKD8yuS43MSWI3rHTLmlCgMrBgj5O/u+n67cyAlA9CuQacNB8oj2VYIH6XGd zdpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=SgSqnRpYbVgYt0S/19hmW1v6WHLtJDNmfTSbDD0L5c4=; fh=ud1dX/SGrHvo1WXcqwOp38DoQRnN7o51jyVIPqKONGQ=; b=n/wBP9qVABFp/n4ZQMiTCC/o+MWA7B7KUCZv3w1ISU5LM9wp7LRFaUzQzOAt3ruA7r iFIjDOoTeBNVINJMP+LxawBas0A04UhRDK2dEF35yyP42+jhRqgFb664+PsXtTYAXxUz kjPe8Oug8PYiqa0AAlJXcDKi0EdTrevv6uihbL4yvTLPm+phvyd4sZDvBAUhN7gkx0B0 kJMKgRmLDkMQsxuXmYwKTSvgDl6QRYJKOCJdHj4G9cGVWt65gi3BWdl7E/fSe7StrtJj wlZPc6ZybUG0+bbSySGZWViQpCdCzNp3HMnpkXAyRSQyKq5bbSrIL4OcaT1ktQq20C5M +GgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=aJAgMZqv; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-83111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83111-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j4-20020a05620a0a4400b0078720eb5c48si7282953qka.389.2024.02.27.03.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 03:16:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=aJAgMZqv; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-83111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83111-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EC7461C23DEA for ; Tue, 27 Feb 2024 11:15:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6C2A13A243; Tue, 27 Feb 2024 11:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="aJAgMZqv" Received: from smtp-1908.mail.infomaniak.ch (smtp-1908.mail.infomaniak.ch [185.125.25.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A7BE2E3EB for ; Tue, 27 Feb 2024 11:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709032514; cv=none; b=jnm3rNTzKphm0f3frEhiLZAgAFJt4q8QQn2TnEUiOF/PCxjVVFA3xWmtPtJrH7TyLw09SmP/Co5/CI1Lk/vaB8OI6cRxa5ZqYCZpUc2qDGeQU61y64K1W3bkAtOrpdmw3AFsaYPzA68ZbJIZ7E1KNA1fPrjQrrSKmq8TyR2a5OU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709032514; c=relaxed/simple; bh=fo0e4FRJyzZJ6d6n/7sR3VvkreP3rfZ9EhEu8wKED6Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Zq7JcYG406UgrQtP0KWX4f9J2GA9HxK8A/kNcfxphE7sq5RFFbH6mNXK0q6wk53u2JEitjCLlKm/RIez4o1AanuznDEhqVXrhYQpDSF63bDl1QEJ/xNdmKXyo8ygl4lQ5NIccRQ7Pb/66bqnIEo8l0sg81uId+39/28LljoUQFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=aJAgMZqv; arc=none smtp.client-ip=185.125.25.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-4-0001.mail.infomaniak.ch (unknown [10.7.10.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4TkZRK3mSFzMq5jp; Tue, 27 Feb 2024 12:06:05 +0100 (CET) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4TkZRJ1SGDzDLf; Tue, 27 Feb 2024 12:06:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1709031965; bh=fo0e4FRJyzZJ6d6n/7sR3VvkreP3rfZ9EhEu8wKED6Q=; h=From:To:Cc:Subject:Date:From; b=aJAgMZqvXCuTbBi3QrqQEix+We3BKKkgtSzWSI/iyXVsm+O11Q4WECvzP7XS5p7AK SysOh8oMYi25zAJ5MEnSVlYHTBLoZKpMm1EgyycJhArAgZ+5oaXh/Ej5Es4I7TuWwX 6Vizit1a6SoZwfE3jEmCv42kq4iV/5BZJ2nNfIPM= From: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= To: =?utf-8?q?G=C3=BCnther_Noack?= , Paul Moore , "Serge E . Hallyn" Cc: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Konstantin Meskhidze , Shervin Oloumi , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Kees Cook Subject: [PATCH v2 1/2] landlock: Extend documentation for kernel support Date: Tue, 27 Feb 2024 12:05:49 +0100 Message-ID: <20240227110550.3702236-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Infomaniak-Routing: alpha X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792050532797570273 X-GMAIL-MSGID: 1792050532797570273 Extend the kernel support section with one subsection for build time configuration and another for boot time configuration. Extend the boot time subsection with a concrete example. Update the journalctl command to include the boot option. Cc: Günther Noack Cc: Kees Cook Signed-off-by: Mickaël Salaün Reviewed-by: Günther Noack --- Changes since v1: * New patch, suggested by Kees Cook. --- Documentation/userspace-api/landlock.rst | 57 +++++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) base-commit: b4007fd27206c478a4b76e299bddf4a71787f520 diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst index 2e3822677061..838cc27db232 100644 --- a/Documentation/userspace-api/landlock.rst +++ b/Documentation/userspace-api/landlock.rst @@ -19,11 +19,12 @@ unexpected/malicious behaviors in user space applications. Landlock empowers any process, including unprivileged ones, to securely restrict themselves. We can quickly make sure that Landlock is enabled in the running system by -looking for "landlock: Up and running" in kernel logs (as root): ``dmesg | grep -landlock || journalctl -kg landlock`` . Developers can also easily check for -Landlock support with a :ref:`related system call `. If -Landlock is not currently supported, we need to :ref:`configure the kernel -appropriately `. +looking for "landlock: Up and running" in kernel logs (as root): +``dmesg | grep landlock || journalctl -kb -g landlock`` . +Developers can also easily check for Landlock support with a +:ref:`related system call `. +If Landlock is not currently supported, we need to +:ref:`configure the kernel appropriately `. Landlock rules ============== @@ -499,6 +500,9 @@ access rights. Kernel support ============== +Build time configuration +------------------------ + Landlock was first introduced in Linux 5.13 but it must be configured at build time with ``CONFIG_SECURITY_LANDLOCK=y``. Landlock must also be enabled at boot time as the other security modules. The list of security modules enabled by @@ -507,11 +511,52 @@ contains ``CONFIG_LSM=landlock,[...]`` with ``[...]`` as the list of other potentially useful security modules for the running system (see the ``CONFIG_LSM`` help). +Boot time configuration +----------------------- + If the running kernel does not have ``landlock`` in ``CONFIG_LSM``, then we can -still enable it by adding ``lsm=landlock,[...]`` to +enable Landlock by adding ``lsm=landlock,[...]`` to Documentation/admin-guide/kernel-parameters.rst thanks to the bootloader configuration. +For example, if the current built-in configuration is: + +.. code-block:: console + + $ zgrep -h "^CONFIG_LSM=" "/boot/config-$(uname -r)" /proc/config.gz 2>/dev/null + CONFIG_LSM="lockdown,yama,integrity,apparmor" + +...and if the cmdline doesn't contain ``landlock`` either: + +.. code-block:: console + + $ sed -n 's/.*\(\ X-Patchwork-Id: 207138 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2623066dyb; Tue, 27 Feb 2024 03:06:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVj7LYVdmrpiekdRWuHNFmc3He2BHJbASQGxnVhPuxHR5gx2sZ+j6j3DqTW57hkz7v+w800l82qBhuSZ0K9kXi2M1phXQ== X-Google-Smtp-Source: AGHT+IGgOuPAqGA7M+Fe1AxAEaEC0FLwvxF0xSHtspqONdJoVysT5lI5jyowtwNSzCAMslIb2TcX X-Received: by 2002:a17:906:355b:b0:a3e:c1ec:7bff with SMTP id s27-20020a170906355b00b00a3ec1ec7bffmr6097609eja.68.1709032017505; Tue, 27 Feb 2024 03:06:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709032017; cv=pass; d=google.com; s=arc-20160816; b=z4dpC32ROTbBzcNT7o4mao+uYbuImz2LIsdJ/xLATrS1F9CWHe/3XSHVZSJlrnbvST o97oaBNvDK8TYM2ELCqqYaMHhhHLxf0CU8ffQjPxiLI2FbVSDY1/11xh60zSv2GsMn0g hdImDf8mw3UYrU5wJZMY403qjKny5DePAE+jRnb6vQaFhFokMpG0rttu3F2mCmmvuIcl 0wCLJgSfuDFiD83YPfIYFeB1JCtX4ppX7oe/PiO6wG7Hhn28NvrgekpY9E6mT6E1PqjJ 0qs0d+so/21OpkZ1U88pe8lFaO8inPuINVNXsiYwqCfjd0ZRZ9h+tz5sfBbPHX2LKTtJ ChNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7ypRpZtpArNK6J+/q9HdBvyEwLdUeFYk76lIMLSmZU4=; fh=SdM8AuPHyc7UBevB0e5vFTFJXyucRz4h4ci5G/v3IDU=; b=dgg/k46Dcr+Y4Ld0HwhTAkC4OA9REob/MaFDixoewz1q07R1vrYURkuEM6+4S4gOhP 4JkFeRTZdL5j8droYnEnaCA4PFRy2c1Q+8HpivAMWS4QT9W0TpuSlu8RrbeJTFnR2WOZ T86RwinkyKV2n0y/ZRxcZv8vK920CiNwxwymNqpuPpQwetAy/Ty+2IrZggAOutvEMwZu gK/CN3DW2xVzksdkfN8qc/brYkeCpEInpGaIRo1saA1WmJO5o+JpxMQnscJnmajizEl2 fHw5XP0WVSHKTHMEMBEPKTB36cDPl9jH8n9aS8JrejzOZbmlolyhffnyL4iNVtijwkPW BZ8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="oCw/iF23"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-83095-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83095-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m13-20020a17090607cd00b00a43205596b9si645491ejc.21.2024.02.27.03.06.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 03:06:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83095-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="oCw/iF23"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-83095-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83095-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B9D2F1F237B9 for ; Tue, 27 Feb 2024 11:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EA9F13A252; Tue, 27 Feb 2024 11:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="oCw/iF23" Received: from smtp-8fa9.mail.infomaniak.ch (smtp-8fa9.mail.infomaniak.ch [83.166.143.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D87CD1386CF; Tue, 27 Feb 2024 11:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709031976; cv=none; b=mp0QAo7RMBPQstTb02JEA8qeU3q9272C/3FOPHFLTtxe42LlyVDGyRt9SaEp1SoHOOs4YbfTvQaKywt0GgfaL3EyehOMcRlQzgDGXiKA1YTpNP8MOwsZP/hheafp58EgDNFlNsgVYYJpNnE6GKj+xVTuf4RfzVEx8eseSjKMpH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709031976; c=relaxed/simple; bh=jPUoWxQfL0gN4M9XnMPtb4OVmzxvQ8jhCx4n49IoT7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gWgoNqp/EMPYDlzGfr/dm1v4s3jBOb1/etbsf2ujKFmgnnpOAFKdWQ97Uj0YU+L2tgKbKZ3+bFit66WnaKzmwjE0fXuNExH7nxU5+1Ho7KU2wd7MFYoYrjs4i1VBwSdwezv1yZkFTaUR0bS6L23BSvVI228PepjIchUCXn/V3qY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=oCw/iF23; arc=none smtp.client-ip=83.166.143.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4TkZRL3hQgzfF; Tue, 27 Feb 2024 12:06:06 +0100 (CET) Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4TkZRL0Ngrz3k; Tue, 27 Feb 2024 12:06:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1709031966; bh=jPUoWxQfL0gN4M9XnMPtb4OVmzxvQ8jhCx4n49IoT7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oCw/iF23a34Rv0MBwr2Ia6cQ8m8h0jvHC8OAnyauVIncs0HoaFwNz47dPhVBwgEjw R5yruWwiqbByh+WzDRqxenUS46BMI9ak98EP9PcOxTd4ecJ/LXUlBEDCPa5K9iN5Qt hb3lJFSu+CT4yjc6FlcRhOYLyM3bfinMCILgyBUg= From: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= To: =?utf-8?q?G=C3=BCnther_Noack?= , Paul Moore , "Serge E . Hallyn" Cc: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Konstantin Meskhidze , Shervin Oloumi , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, stable@vger.kernel.org, Kees Cook , =?utf-8?q?G?= =?utf-8?q?=C3=BCnther_Noack?= Subject: [PATCH v2 2/2] landlock: Warn once if a Landlock action is requested while disabled Date: Tue, 27 Feb 2024 12:05:50 +0100 Message-ID: <20240227110550.3702236-2-mic@digikod.net> In-Reply-To: <20240227110550.3702236-1-mic@digikod.net> References: <20240227110550.3702236-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Infomaniak-Routing: alpha X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792049957073047190 X-GMAIL-MSGID: 1792049957073047190 Because sandboxing can be used as an opportunistic security measure, user space may not log unsupported features. Let the system administrator know if an application tries to use Landlock but failed because it isn't enabled at boot time. This may be caused by bootloader configurations with outdated "lsm" kernel's command-line parameter. Cc: stable@vger.kernel.org Fixes: 265885daf3e5 ("landlock: Add syscall implementations") Reviewed-by: Kees Cook Reviewed-by: Günther Noack Signed-off-by: Mickaël Salaün --- Changes since v1: * Add Kees's and Günther's Reviewed-by. * Rename is_not_initialized() to not_initialized() and invert the logic, as suggested by Günther. This is a cosmetic change without global behavioral changed. * Update link to point to a new subsection. --- security/landlock/syscalls.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c index 898358f57fa0..6788e73b6681 100644 --- a/security/landlock/syscalls.c +++ b/security/landlock/syscalls.c @@ -33,6 +33,18 @@ #include "ruleset.h" #include "setup.h" +static bool is_initialized(void) +{ + if (likely(landlock_initialized)) + return true; + + pr_warn_once( + "Disabled but requested by user space. " + "You should enable Landlock at boot time: " + "https://docs.kernel.org/userspace-api/landlock.html#boot-time-configuration\n"); + return false; +} + /** * copy_min_struct_from_user - Safe future-proof argument copying * @@ -173,7 +185,7 @@ SYSCALL_DEFINE3(landlock_create_ruleset, /* Build-time checks. */ build_check_abi(); - if (!landlock_initialized) + if (!is_initialized()) return -EOPNOTSUPP; if (flags) { @@ -398,7 +410,7 @@ SYSCALL_DEFINE4(landlock_add_rule, const int, ruleset_fd, struct landlock_ruleset *ruleset; int err; - if (!landlock_initialized) + if (!is_initialized()) return -EOPNOTSUPP; /* No flag for now. */ @@ -458,7 +470,7 @@ SYSCALL_DEFINE2(landlock_restrict_self, const int, ruleset_fd, const __u32, struct landlock_cred_security *new_llcred; int err; - if (!landlock_initialized) + if (!is_initialized()) return -EOPNOTSUPP; /*