Received: by 2002:ab2:644:0:b0:1ec:cbc4:63fb with SMTP id 4csp1159639lqn; Mon, 26 Feb 2024 09:16:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUT6Led1hUG7W5lGatroqbphzFHJFAGNEloT1P1qr45ry0OwWoiOydi6wRdILew7M39qTzpQaS2BBaWOkK8gGUmctF4p7AQRsTv3ridgQ== X-Google-Smtp-Source: AGHT+IFDMMHmSHfWMvm8xcHV/J2umhBGklmEnGCH3SRMvBNTdJkE/VLtDYDNe6QSwYB0D+gMF9jN X-Received: by 2002:a05:620a:4092:b0:785:4442:c28b with SMTP id f18-20020a05620a409200b007854442c28bmr9680930qko.11.1708967767245; Mon, 26 Feb 2024 09:16:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967767; cv=pass; d=google.com; s=arc-20160816; b=F3ctzkERmUCjrxYoN0BZrCewhEov9Er1r4ihd7zOXPrHpjkQCmjWYSGTOWy4LMcuoQ 4IIF+rDjyJBlu3XpI7F4s8EJO8W6s5IYjfXDddheObCG7E5sZgFD0ioVWQ8GpWE4Bb72 AFaDneHjcdGqaBAL8z/tKIqrtbW00mjL4eDpzi2KSbmD5UjU3TrOPsf0OOW2lsIrCzej 6q/+udcVBr7VX9qLZfk7Pzu5smyzCe3e5dnEJ5uyp8OjY2V4LUbWMGpkNl/7RcqCCV6t 1q2oBLsG+pFBuaBs2tYJ0WgXNwnxwnZMZm/lj9xH4aRLHiu6iDN8bzg4fL3u91Qg1Zta 4B7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PzZUOl2NfuTXXfgT6DSyKG8eClLqvYhMlYr4Y47ACng=; fh=mTfh+GkWlx7uhU1u/wG29YtsYo7Y15Bq+NjtcoFp6pA=; b=uMwcvJ5NYcv5jnP8l+TAsHjVz4T27YNn63EzxPjaSRpytxs88taTqeeC4mTl/87NVw I88TQkcCQg7EV6rjgKb7sfyAVqb40zySr0kgmLYjbKY2ehseba/qL7qWiWWAhpod8ZG5 g/b+/zD38M3UC10OIHk6krZbJdwPNX1+t9OK4kOMV/JqiG0+6aAIHiammJcWSMW/Kh7d b5+STuioig+w0rxULlEsFiO7RFbaX+qj9mtgGTLkWaIFWPvulC1LH1xMQumLWDHvtiox GAlLpWi6b9q6y6OorUGEe3Op3O5Dl6JKyfUcZ2Qw3EVvgYZob8lc5uk4mcyLSVVMJZri oAog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=J5hwbTHq; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-82021-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82021-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j19-20020a05620a0a5300b00783e5c0ae73si5512911qka.180.2024.02.26.09.16.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:16:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82021-linux.lists.archive=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=J5hwbTHq; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-82021-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82021-linux.lists.archive=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 4A8791C2BC41 for ; Mon, 26 Feb 2024 17:15:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0069413664B; Mon, 26 Feb 2024 17:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="J5hwbTHq" 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 3FEFA12F366 for ; Mon, 26 Feb 2024 17:05:49 +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=1708967154; cv=none; b=TMyjAJS0e0BSQrxxNQJn4ZhqsiuN55AASlAZjLTAZFxBRp+Q+wSwPWU5BX/1tZTCwgMGecx0aTI6XYllDEZ9aiDKiK0OMFpPSCuND/5moxNkBZmo8gnpJaj1s9oqyyc/8oQLvrFlwKmo+T5MXI1zgV4mIz/yXoITNBma9CaeKEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708967154; c=relaxed/simple; bh=TEpQO8oVhWg12vbtVS68hwoIFoQZycElKAGrNEzuM9o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fu08EbTRR1f5T5i0TM5ro1EFmohg+DfamccSuBmWYBaGU21Mr9rvQFOSOef4S6Z4YB8NqQA2H92ZBXfxDDiq3P3WDJZzFffak3NEDn+6Vr81yl2WqSiuX6aanUDqRLr7kvcBOowXGVgRDIasu58rl8rYqBRubJtvJ3yXMWXEMuA= 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=J5hwbTHq; 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-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Tk6Sk4MjfzQkL; Mon, 26 Feb 2024 18:05:42 +0100 (CET) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4Tk6Sj5blNz1sr; Mon, 26 Feb 2024 18:05:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1708967142; bh=TEpQO8oVhWg12vbtVS68hwoIFoQZycElKAGrNEzuM9o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J5hwbTHqlvYD7XVRvMUl+1yLrl1IYNrSHFaPd8XOBjVbSlYpYstl5VbR9fB/ZR0zT JMGK2lOQSwEMUYdDl7Dyk0mcgPxC3oA1Jqi097/QPKxFi0rLGPUkh6CUmXtp72Ifs7 JsByWA9GE4IGe2H/Z8jBwKANLAlE0JkMPCdJXydE= Date: Mon, 26 Feb 2024 18:05:33 +0100 From: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= To: =?utf-8?Q?G=C3=BCnther?= Noack Cc: =?utf-8?Q?G=C3=BCnther?= Noack , Paul Moore , "Serge E . Hallyn" , Konstantin Meskhidze , Shervin Oloumi , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] landlock: Warn once if a Landlock action is requested while disabled Message-ID: <20240226.Ceemai4ahxei@digikod.net> References: <20240219191804.2978911-1-mic@digikod.net> <20240221.b8dcd9590c37@gnoack.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240221.b8dcd9590c37@gnoack.org> X-Infomaniak-Routing: alpha On Wed, Feb 21, 2024 at 10:35:50PM +0100, Günther Noack wrote: > Hello! > > I think this is a good idea. > Some minor implementation remarks below. > > On Mon, Feb 19, 2024 at 08:18:04PM +0100, Mickaël Salaün wrote: > > 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: Günther Noack > > Cc: stable@vger.kernel.org > > Fixes: 265885daf3e5 ("landlock: Add syscall implementations") > > Signed-off-by: Mickaël Salaün > > --- > > 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 f0bc50003b46..b5b424819dee 100644 > > --- a/security/landlock/syscalls.c > > +++ b/security/landlock/syscalls.c > > @@ -33,6 +33,18 @@ > > #include "ruleset.h" > > #include "setup.h" > > > > +static bool is_not_initialized(void) > > +{ > > + if (likely(landlock_initialized)) > > + return false; > > Optional stylistic remark; I try to avoid predicate functions which > have a "negated" meaning, because double negations are slightly more > error prone. (We return false here, so Landlock is not not > initialized.) I agree, I was also bothered about this double negation. I'll send a v2 with the same behavior but an is_initialized() helper instead. > > > + > > + pr_warn_once( > > + "Disabled but requested by user space. " > > + "You should enable Landlock at boot time: " > > + "https://docs.kernel.org/userspace-api/landlock.html#kernel-support\n"); > > + return true; > > +} > > + > > /** > > * 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_not_initialized()) > > return -EOPNOTSUPP; > > Technically, any Landlock user needs to go through the > landlock_create_ruleset() system call anyway; it might be enough to > just add it in that place and leave the other system calls as they > were. Then you could also omit the special function. True, but we never know. I prefer to cover all entry points the same way. It makes things more consistent and easier to review. > > Reviewed-by: Günther Noack > > –Günther >