Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1091348pxu; Mon, 23 Nov 2020 11:24:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJySBnh5zJmd0QFpBlEP54bFSRqoY5VrSk39/BC0mSkiGJAfXP2SSeLvC13MtneP2wAS6K+B X-Received: by 2002:a17:906:e254:: with SMTP id gq20mr1070825ejb.520.1606159447513; Mon, 23 Nov 2020 11:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606159447; cv=none; d=google.com; s=arc-20160816; b=N8xlVAv8t7EVv89bQuZmD62nGf2yKVXzPtk+90eR4FDhGAhY2x4kG0BWryFDDtnZxq 2C6MRPmIu8A8mAvJ+c9YGV7+CiB5p1FM+R9vxmV117pr8c6PdAJCZAa/kDWJxWH0mwZI ruhwV3i2BePYvl+cGxpyzW0ylWVdJGoXoDqoGNbkLDePksRhsx2C/2kSSgZlWUT1ChJd A/sgO4+DNRV0PjB815M52QLVKa6TE5J4TwEOJ027k6mWLznJTlhDg2Zo2h2KaEPulyIJ FN0z5mCXHvI045fuDEo6/BpMEcGPn9QQkGqWFuuz7L4u8fQdWyMK4ix9nKPaEtzBmG7R D+9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IDXip25iFNJyM0PQT3UUP9BSDp/9JtkjedehC7iQYgI=; b=pwETmmBAD+lkZoYYr0ewaw/jTRhCGvae75hV98ET4zKYaJHTrpZhrEOf+5yzibhgL4 MlzDcbk77M1Hv3bpoPS/OW8lbVNDAUicD7XrDiLJ9/N2618q8mxxk0Vt+1zjSPkDZqB9 y+ypBAdgToeARWCSvi6UUjDaVHZcnyKhf8kAn4TInLSy/zgkp/K5CpC5d1hphIdomx4r 1UpizrdK28dyjQTq4Q0f0Dt5to2BJd/8YUViyT3p7eqArwG90Tk2G2VmBjLQQ0/rQcsp s30W1Y/9y+Lt4tT6tK30mmHomR989T82V1NhwUhXZiSpO00f0dMPjcpSHIi7zl8/dssM HRFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Yw2aQU9x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj22si6932647ejb.513.2020.11.23.11.23.44; Mon, 23 Nov 2020 11:24:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Yw2aQU9x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730636AbgKWTVN (ORCPT + 99 others); Mon, 23 Nov 2020 14:21:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729183AbgKWTVN (ORCPT ); Mon, 23 Nov 2020 14:21:13 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AE78C061A4D for ; Mon, 23 Nov 2020 11:21:11 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id gj5so24945010ejb.8 for ; Mon, 23 Nov 2020 11:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IDXip25iFNJyM0PQT3UUP9BSDp/9JtkjedehC7iQYgI=; b=Yw2aQU9xEKztBeZFpgzdcCIMM0F7lTQYAdM0JHnjP4hY6mpUB8V8tRh5WOa76T2xZn B1D9HaFeGSXAB9IPtUy8gP8yQitPaU5Epa1pIMOyO5nxNi6mRbogZsDTpv9Xhkhfuuvs b8Z1itlSu7vABBV16xIdb7eU1FLhji8NhNjQSxzdcfbvlhMTsd8UqbT1OdabZJyBZbAW Kg75RcoHpXHQJ+ndeWLo8CW6muNIxihUQo+Yrmmixvw+Q0ZLz5L3ZZXM7cXtigdf5XkT Zmps8vvpm9sg4emPXqNaTMqnyULRtHIDz98Qt8GVJP7KqgH6Al67RYpPbOZDRLiVCGPZ PX+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IDXip25iFNJyM0PQT3UUP9BSDp/9JtkjedehC7iQYgI=; b=s8M+EghXN1DeujYh4kxzI89xGvgisB9+KUFMYe04biCtjWOBQTc9dy61eHFAuHTIFO lDmHk0DnZyq3xHmb6YeXuTrDUDiYH/T7YP64lXr14EXd1H1z+St0UkC8Wwp/OlMOYw1S WxrPfW35W4QU2YL/WqeM47yEkpn/Aba/WQEaI90APA5PV+a/as6+p9KHzPy94afIyZHd qx+QH58vegj4KLxmmUcKYxQQOn/fwukE6BcF7MEFfqObHYdviDQwrpvspqJ3/zNf2O+Z nRBtv+H4AAWdopJK9tnAeUOWM8imxwLPWFspFZykasrtSYfi7XCmX/tXdnHdgaMZs65r jtjw== X-Gm-Message-State: AOAM532z1Saz5V6lt+Ke6PKLYc6OGBO/6DOQef8K4UT6aYwshpeNXlyB gGiZw7q7HSBRslMJrprNZrpGtxjjB+fMVLh+4pv9XA== X-Received: by 2002:a17:906:c312:: with SMTP id s18mr1030453ejz.185.1606159269816; Mon, 23 Nov 2020 11:21:09 -0800 (PST) MIME-Version: 1.0 References: <20201106155626.3395468-1-lokeshgidra@google.com> <20201106155626.3395468-4-lokeshgidra@google.com> In-Reply-To: From: Lokesh Gidra Date: Mon, 23 Nov 2020 11:20:58 -0800 Message-ID: Subject: Re: [PATCH v12 3/4] selinux: teach SELinux about anonymous inodes To: Paul Moore Cc: Andrea Arcangeli , Alexander Viro , James Morris , Stephen Smalley , Casey Schaufler , Eric Biggers , "Serge E. Hallyn" , Eric Paris , Daniel Colascione , Kees Cook , "Eric W. Biederman" , KP Singh , David Howells , Thomas Cedeno , Anders Roxell , Sami Tolvanen , Matthew Garrett , Aaron Goidel , Randy Dunlap , "Joel Fernandes (Google)" , YueHaibing , Christian Brauner , Alexei Starovoitov , Alexey Budankov , Adrian Reber , Aleksa Sarai , Linux FS Devel , linux-kernel , LSM List , SElinux list , Kalesh Singh , Calin Juravle , Suren Baghdasaryan , Jeffrey Vander Stoep , "Cc: Android Kernel" , "open list:MEMORY MANAGEMENT" , Andrew Morton , hch@infradead.org, Ondrej Mosnacek Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 22, 2020 at 3:14 PM Paul Moore wrote: > > On Wed, Nov 18, 2020 at 5:39 PM Lokesh Gidra wrote: > > I have created a cuttlefish build and have tested with the attached > > userfaultfd program: > > Thanks, that's a good place to start, a few comments: > > - While we support Android as a distribution, it isn't a platform that > we common use for development and testing. At the moment, Fedora is > probably your best choice for that. > I tried setting up a debian/ubuntu system for testing using the instructions on the selinux-testsuite page, but the system kept freezing after 'setenforce 1'. I'll try with fedora now. > - Your test program should be written in vanilla C for the > selinux-testsuite. Looking at the userfaultfdSimple.cc code that > should be a trivial conversion. > > - I think you have a good start on a test for the selinux-testsuite, > please take a look at the test suite and submit a patch against that > repo. Ondrej (CC'd) currently maintains the test suite and he may > have some additional thoughts. > > * https://github.com/SELinuxProject/selinux-testsuite Thanks a lot for the inputs. I'll start working on this. > > > 1) Without these kernel patches the program executes without any restrictions > > > > vsoc_x86_64:/ $ ./system/bin/userfaultfdSimple > > api: 170 > > features: 511 > > ioctls: 9223372036854775811 > > > > read: Try again > > > > > > 2) With these patches applied but without any policy the 'permission > > denied' is thrown > > > > vsoc_x86_64:/ $ ./system/bin/userfaultfdSimple > > syscall(userfaultfd): Permission denied > > > > with the following logcat message: > > 11-18 14:21:44.041 3130 3130 W userfaultfdSimp: type=1400 > > audit(0.0:107): avc: denied { create } for dev="anon_inodefs" > > ino=45031 scontext=u:r:shell:s0 tcontext=u:object_r:shell:s0 > > tclass=anon_inode permissive=0 > > > > > > 3) With the attached .te policy file in place the following output is > > observed, confirming that the patch is working as intended. > > vsoc_x86_64:/ $ ./vendor/bin/userfaultfdSimple > > UFFDIO_API: Permission denied > > > > with the following logcat message: > > 11-18 14:33:29.142 2028 2028 W userfaultfdSimp: type=1400 > > audit(0.0:104): avc: denied { ioctl } for > > path="anon_inode:[userfaultfd]" dev="anon_inodefs" ino=41169 > > ioctlcmd=0xaa3f scontext=u:r:userfaultfdSimple:s0 > > tcontext=u:object_r:uffd_t:s0 tclass=anon_inode permissive=0 > > -- > paul moore > www.paul-moore.com