From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE8A8187849 for ; Tue, 9 Jul 2024 21:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720562306; cv=none; b=FsQaIVyTc8DTh5S6C6q6cgHSMKLGKMYTC2erOPg8VUtBwzDEBo87xVKaqJwBSkXrc3Dx1jgG/6powzStxQy2mIGZ0NXCwg72EYzd5J3YzSTBbXZxtqPMy2Z7CRkR1qUW3kqen0iYsFDvypDiu40o27aNFikpLMeuqcRMJhkS/N4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720562306; c=relaxed/simple; bh=/JHQKI6qRGJJpd6MZqEnliPYlq/fkQstnp74/r7RAmA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QQTDaq4z5nlJFlT3KwfdxnPNiaByZnHz2mRoqBlXlfej2Lcs8GFgZrsT07MJw00MgtzqbliKCzoslSAud7+Um5EvdCwn6BEBrk/ceP7icQud6/x7q1LE1wehtEzD7goEZZG79UKvYzoYXVPJUVl+VMT5YKAnwjuG5LEi7ezzW2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=INrTZPd3; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="INrTZPd3" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-447df43324fso42431cf.1 for ; Tue, 09 Jul 2024 14:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720562304; x=1721167104; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8N4RzwbAAmEP/AG2T8Gw592nDB74gw9mJLtjSTvDgE0=; b=INrTZPd3rTNb/Mv747Q3UPOIkhB01oo5WUfN8jay2s72Adoggnal6Q56keC2EeIyRX KaAYv3t5o4/qDGPQFqf/IylTwSH06CsJ+Ys7q9oFObHMqfq+X3yf/LfvDdxY7fiyrQjy mad8reCJ8WTeBjyCx2YilAetrxUmbsHYa8d5GD1leLQPLNEIKilqHVIqt/zhq209upBi V37jcSLeAkIp1i9/04ThRoWIoWrDuOzKP9NE+Yh/vBMjuMK7836ugOrCgIfSEBQh00jQ kDmfJ783zgT8681KEt6yk1aBG5ZtzDQAL3Rav2+zsggij/sKJR1au+Y5tjQFxi/OYo52 sfXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720562304; x=1721167104; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8N4RzwbAAmEP/AG2T8Gw592nDB74gw9mJLtjSTvDgE0=; b=t6cN7BgZ9vm7vAinjR8PCsbogfv4LpaqCeX8csvhwSSN3AuJwQeoRLK86hGXh8WPEx Y0RPv4mCIY3XFCnQQqjLNqay1NxZrblWXgO556QCw2LpH79KcnZFfMA/2pz0NTwTQf4j nk/9ybxvQ0yyueOO0jtCt/DnW3JwT+fQ3Ucj5CD73drxqjaPW0mI+qpcLqA7YzU4EP9E YuU5cAzr+am5IgvxioVPEhbYcINI5ihVA6BWGKTESPlV83sRpjzUtPlamPUkbGXhFHjC sFc70vJUxOmMJSPIF+WpwLh1ehJxt6poYon03pxHkJ/7fexNn56yADz0FHytQUv83Cla 1awQ== X-Forwarded-Encrypted: i=1; AJvYcCXhD30baIg/Y9XesZ/GFvJaEjwjqdIS3j0ZFLlVWSAnjsN0/lXKJd7huKvJGEap0ArH6uDdiCsolNK20+IBj1d7s4opVrJBUtoy X-Gm-Message-State: AOJu0YxDV8nJ/+8eSjjYXB0cdDnrIii8o1oLiQkztpb34vY8AIIOFrT0 AJ5hUckbDQBBR/My96Vs9Qakk7XgieGRzZfESWxRG+BgkPkTEeiE7veRDuFvmOeEyhpMrchvFIu I9M5KEWDYTqVb6Wtk5MORYzjxaJYN6FLgrotq X-Google-Smtp-Source: AGHT+IHU/ulbI1FgR/JVMf8iXIlBgjwo6bpuSXE1LPPT7fla6HjTvbnXEhuRdbGZtTi1CaktDzIEC12PO4kPA95OI0s= X-Received: by 2002:a05:622a:15ce:b0:447:e728:d9b with SMTP id d75a77b69052e-44acc23802bmr1367101cf.26.1720562303300; Tue, 09 Jul 2024 14:58:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240704190137.696169-1-mic@digikod.net> <20240704190137.696169-3-mic@digikod.net> <20240708.quoe8aeSaeRi@digikod.net> <20240709.aech3geeMoh0@digikod.net> In-Reply-To: <20240709.aech3geeMoh0@digikod.net> From: Jeff Xu Date: Tue, 9 Jul 2024 14:57:43 -0700 Message-ID: Subject: Re: [RFC PATCH v19 2/5] security: Add new SHOULD_EXEC_CHECK and SHOULD_EXEC_RESTRICT securebits To: =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= Cc: Steve Dower , Al Viro , Christian Brauner , Kees Cook , Linus Torvalds , Paul Moore , "Theodore Ts'o" , Alejandro Colomar , Aleksa Sarai , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Casey Schaufler , Christian Heimes , Dmitry Vyukov , Eric Biggers , Eric Chiang , Fan Wu , Florian Weimer , Geert Uytterhoeven , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Jordan R Abrahams , Lakshmi Ramasubramanian , Luca Boccassi , Luis Chamberlain , "Madhavan T . Venkataraman" , Matt Bobrowski , Matthew Garrett , Matthew Wilcox , Miklos Szeredi , Mimi Zohar , Nicolas Bouchinet , Scott Shell , Shuah Khan , Stephen Rothwell , Steve Grubb , Thibaut Sautereau , Vincent Strubel , Xiaoming Ni , Yin Fengwei , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jul 9, 2024 at 1:42=E2=80=AFPM Micka=C3=ABl Sala=C3=BCn wrote: > > On Mon, Jul 08, 2024 at 03:07:24PM -0700, Jeff Xu wrote: > > On Mon, Jul 8, 2024 at 2:25=E2=80=AFPM Steve Dower wrote: > > > > > > On 08/07/2024 22:15, Jeff Xu wrote: > > > > IIUC: > > > > CHECK=3D0, RESTRICT=3D0: do nothing, current behavior > > > > CHECK=3D1, RESTRICT=3D0: permissive mode - ignore AT_CHECK results. > > > > CHECK=3D0, RESTRICT=3D1: call AT_CHECK, deny if AT_CHECK failed, no= exception. > > > > CHECK=3D1, RESTRICT=3D1: call AT_CHECK, deny if AT_CHECK failed, ex= cept > > > > those in the "checked-and-allowed" list. > > > > > > I had much the same question for Micka=C3=ABl while working on this. > > > > > > Essentially, "CHECK=3D0, RESTRICT=3D1" means to restrict without chec= king. > > > In the context of a script or macro interpreter, this just means it w= ill > > > never interpret any scripts. Non-binary code execution is fully disab= led > > > in any part of the process that respects these bits. > > > > > I see, so Micka=C3=ABl does mean this will block all scripts. > > That is the initial idea. > > > I guess, in the context of dynamic linker, this means: no more .so > > loading, even "dlopen" is called by an app ? But this will make the > > execve() fail. > > Hmm, I'm not sure this "CHECK=3D0, RESTRICT=3D1" configuration would make > sense for a dynamic linker except maybe if we want to only allow static > binaries? > > The CHECK and RESTRICT securebits are designed to make it possible a > "permissive mode" and an enforcement mode with the related locked > securebits. This is why this "CHECK=3D0, RESTRICT=3D1" combination looks= a > bit weird. We can replace these securebits with others but I didn't > find a better (and simple) option. I don't think this is an issue > because with any security policy we can create unusable combinations. > The three other combinations makes a lot of sense though. > If we need only handle 3 combinations, I would think something like below is easier to understand, and don't have wield state like CHECK=3D0, RESTRICT=3D1 XX_RESTRICT: when true: Perform the AT_CHECK, and deny the executable after AT_CHECK fails. XX_RESTRICT_PERMISSIVE: take effect when XX_RESTRICT is true. True means Ignoring the AT_CHECK result. Or XX_CHECK: when true: Perform the AT_CHECK. XX_CHECK_ENFORCE takes effect only when XX_CHECK is true. True means restrict the executable when AT_CHECK failed; false means ignore the AT_CHECK failure. Of course, we can replace XX_CHECK_ENFORCE with XX_RESTRICT. Personally I think having _CHECK_ in the name implies the XX_CHECK needs to be true as a prerequisite for this flag , but that is my opinion only. As long as the semantics are clear as part of the comments of definition in code, it is fine. Thanks -Jeff > > > > > "CHECK=3D1, RESTRICT=3D1" means to restrict unless AT_CHECK passes. T= his > > > case is the allow list (or whatever mechanism is being used to determ= ine > > > the result of an AT_CHECK check). The actual mechanism isn't the > > > business of the script interpreter at all, it just has to refuse to > > > execute anything that doesn't pass the check. So a generic interprete= r > > > can implement a generic mechanism and leave the specifics to whoever > > > configures the machine. > > > > > In the context of dynamic linker. this means: > > if .so passed the AT_CHECK, ldopen() can still load it. > > If .so fails the AT_CHECK, ldopen() will fail too. > > Correct > > > > > Thanks > > -Jeff > > > > > The other two case are more obvious. "CHECK=3D0, RESTRICT=3D0" is the > > > zero-overhead case, while "CHECK=3D1, RESTRICT=3D0" might log, warn, = or > > > otherwise audit the result of the check, but it won't restrict execut= ion. > > > > > > Cheers, > > > Steve