Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp463428pxu; Sun, 22 Nov 2020 15:18:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCZzGIghX5EH2bHPAsKgYsisUgwZrbr/V1r+g+fE9RJI+V8D7iB8bOE4Wt2rry8kSHpU9T X-Received: by 2002:a17:906:c097:: with SMTP id f23mr3760303ejz.102.1606087124463; Sun, 22 Nov 2020 15:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606087124; cv=none; d=google.com; s=arc-20160816; b=FiTkGh/l+9vwysVRYrZcWlSGNPe3swKC1JZ+9XMDcbz6khx/Sn1ajXlJ4R9vKzPOQK SXzk99A/LHZ9+q4TKTAWnBWR3etILHvklY1+5mdJ04MvFie/28G+KLVqucZ7FpFPhOxZ H9lZUijmplUT7ybdzfpD/5k5R8xtUCqNXHJQwa05a7ZHuYNhrm7He8WUAg/N2uuXEXKJ oUYUE3ZcEymxpBLi6QQoGIsHpjWFATX/zeE4uFgwsve9UiXI6HFodY6YBJM5eHMtDZZT qV3HzVemJfaLhpyMnbqPXsavA3AAi7Q05KTiNLCbu1ssgJ8kR5/FQ97jwFA3kfRMRaf0 FSkw== 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=qrIV9Yoc1RpsJtPIVkFbz+NHNkiiYsOXEJ2yAt4fGM4=; b=xgFdL8vt+iW5iOkNAwevJxBn3zti+nmbVq36nFRzksTUmYKmYkYpGj4SERyVYxJWlo MbG0KbW0fu3gY2/B6woP08YyX6pQk8BRM1ITStQJWT995zYkkIErdeu/LOI3YgPlAjEU AFswGBaHMwYcscpm7brf8xcEtxBKAGdjtP/UZohSaXeJOOG5lBUGaaYBY0vMzlcNJCZD KcpJDF2tA/Od82aTsGvKFORA6+YafpgvcL5wGs9F23m4OXVzArV3uqTn7Aqs6JeCiNEE MDg9b0l7Efg5XvP7wJfRCNpGuqHEfwE+4O8Ws96Am15cibX8frlsH7X1DlqFkHjLLsX/ rX8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=eAEDg4gu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id um17si5535835ejb.701.2020.11.22.15.18.20; Sun, 22 Nov 2020 15:18:44 -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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=eAEDg4gu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbgKVXOw (ORCPT + 99 others); Sun, 22 Nov 2020 18:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgKVXOw (ORCPT ); Sun, 22 Nov 2020 18:14:52 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 557DDC061A4A for ; Sun, 22 Nov 2020 15:14:50 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id lv15so14924638ejb.12 for ; Sun, 22 Nov 2020 15:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qrIV9Yoc1RpsJtPIVkFbz+NHNkiiYsOXEJ2yAt4fGM4=; b=eAEDg4gusJ5cOG8GkLEsF1ZAHwn37356W/f3uiaob29/5FsdO0PDffI2+hWwsDxZNd IoRtJkaNfBfkGTP4NOV0G9+ugO7r3kiZMr8CkVIMb9DdojQ6fOpVEvHw8ghAxUfFidiB 3i/pCAl+sd97icqGYzZ4sxJ4xe78yjP+jYSeQ3D1zKHG4dsYL3FAwtlPvQZReuDHK5jO hHSGXkq/iD6nhrc5hp/rvPgIghfCSCLczJjsoWKaEphQRrTEy/TcIqI104ww2/q8PwKs JWW/9SOxNKFPAqANRS6zH7/zQX6N/KvAvsVuVwldrwARApU7P/vVSrc/s8UgwcofPJqo YyXw== 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=qrIV9Yoc1RpsJtPIVkFbz+NHNkiiYsOXEJ2yAt4fGM4=; b=ARyB8BRfCv0zuPzdhDvA3i+JvOs9Zeh6TWnApjuA1AU12oOF4uwGcHgtNb0t6MhHQN YxFphGT2iGPqUbTHX6g1ylnTJ3EY0uWbKQKFFEcrVrXwfoBJamgF5ejOmLvimkG6akPS pIl9mMMjtIBr+ndxxnz087LqB5Lbwas+V3NzdFPv2f6DbkbXTzcR59JVs6IrRRCTo8E8 9P07MiOZLhGmIwsWboUtinFXgj0lXdKBRCsX2NUtc8iaPbPW1bfz90yzyYnGD59rbHP3 3Aohq/qFbHT5u3659WI/qmHs+DPpY+hLDR3GMyODKpo621RJ2pBza4XDSgwLhUBTbUkr TWPQ== X-Gm-Message-State: AOAM531AYBsvPILKu4jZU2KD/HKJDSE27jBNiG85NoswsE6sQhAWFinI aljnD3PF3jjv7KVCwtaAX6N156Pi2lfNEZGqUb/p X-Received: by 2002:a17:906:c096:: with SMTP id f22mr40380124ejz.488.1606086888699; Sun, 22 Nov 2020 15:14:48 -0800 (PST) MIME-Version: 1.0 References: <20201106155626.3395468-1-lokeshgidra@google.com> <20201106155626.3395468-4-lokeshgidra@google.com> In-Reply-To: From: Paul Moore Date: Sun, 22 Nov 2020 18:14:37 -0500 Message-ID: Subject: Re: [PATCH v12 3/4] selinux: teach SELinux about anonymous inodes To: Lokesh Gidra 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 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. - 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 > 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