|
Message-ID: <f3ca5fb2-64c6-b525-0f16-5353f1f7eddb@digikod.net> Date: Thu, 14 Jan 2021 19:59:57 +0100 From: Mickaël Salaün <mic@...ikod.net> To: Jann Horn <jannh@...gle.com> Cc: James Morris <jmorris@...ei.org>, "Serge E . Hallyn" <serge@...lyn.com>, Al Viro <viro@...iv.linux.org.uk>, Andy Lutomirski <luto@...capital.net>, Anton Ivanov <anton.ivanov@...bridgegreys.com>, Arnd Bergmann <arnd@...db.de>, Casey Schaufler <casey@...aufler-ca.com>, Jeff Dike <jdike@...toit.com>, Jonathan Corbet <corbet@....net>, Kees Cook <keescook@...omium.org>, Michael Kerrisk <mtk.manpages@...il.com>, Richard Weinberger <richard@....at>, Shuah Khan <shuah@...nel.org>, Vincent Dagonneau <vincent.dagonneau@....gouv.fr>, Kernel Hardening <kernel-hardening@...ts.openwall.com>, Linux API <linux-api@...r.kernel.org>, linux-arch <linux-arch@...r.kernel.org>, "open list:DOCUMENTATION" <linux-doc@...r.kernel.org>, linux-fsdevel <linux-fsdevel@...r.kernel.org>, kernel list <linux-kernel@...r.kernel.org>, "open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>, linux-security-module <linux-security-module@...r.kernel.org>, the arch/x86 maintainers <x86@...nel.org>, Mickaël Salaün <mic@...ux.microsoft.com> Subject: Re: [PATCH v26 11/12] samples/landlock: Add a sandbox manager example On 14/01/2021 04:21, Jann Horn wrote: > On Wed, Dec 9, 2020 at 8:29 PM Mickaël Salaün <mic@...ikod.net> wrote: >> Add a basic sandbox tool to launch a command which can only access a >> whitelist of file hierarchies in a read-only or read-write way. > > I have to admit that I didn't really look at this closely before > because it's just sample code... but I guess I should. You can add > > Reviewed-by: Jann Horn <jannh@...gle.com> > > if you fix the following nits: OK, I will! > > [...] >> diff --git a/samples/Kconfig b/samples/Kconfig > [...] >> +config SAMPLE_LANDLOCK >> + bool "Build Landlock sample code" >> + depends on HEADERS_INSTALL >> + help >> + Build a simple Landlock sandbox manager able to launch a process >> + restricted by a user-defined filesystem access control. > > nit: s/filesystem access control/filesystem access control policy/ > > [...] >> diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c > [...] >> +/* >> + * Simple Landlock sandbox manager able to launch a process restricted by a >> + * user-defined filesystem access control. > > nit: s/filesystem access control/filesystem access control policy/ > > [...] >> +int main(const int argc, char *const argv[], char *const *const envp) >> +{ > [...] >> + if (argc < 2) { > [...] >> + fprintf(stderr, "* %s: list of paths allowed to be used in a read-only way.\n", >> + ENV_FS_RO_NAME); >> + fprintf(stderr, "* %s: list of paths allowed to be used in a read-write way.\n", >> + ENV_FS_RO_NAME); > > s/ENV_FS_RO_NAME/ENV_FS_RW_NAME/ > >> + fprintf(stderr, "\nexample:\n" >> + "%s=\"/bin:/lib:/usr:/proc:/etc:/dev/urandom\" " >> + "%s=\"/dev/null:/dev/full:/dev/zero:/dev/pts:/tmp\" " >> + "%s bash -i\n", >> + ENV_FS_RO_NAME, ENV_FS_RW_NAME, argv[0]); >> + return 1; >> + } >> + >> + ruleset_fd = landlock_create_ruleset(&ruleset_attr, sizeof(ruleset_attr), 0); >> + if (ruleset_fd < 0) { >> + perror("Failed to create a ruleset"); >> + switch (errno) { > > (Just as a note: In theory perror() can change the value of errno, as > far as I know - so AFAIK you'd theoretically have to do something > like: > > int errno_ = errno; > perror("..."); > switch (errno_) { > ... > } Indeed :) > > I'll almost certainly work fine as-is in practice though.) >
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.