Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp665906imm; Thu, 31 May 2018 07:22:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL1h9Yy1dfvh4wkGCe0j4fu2UTjmvrsOmo6dpY8tD3xt417FlLA9FMAIvKUqOiEBPvhwENa X-Received: by 2002:a63:b601:: with SMTP id j1-v6mr5797940pgf.335.1527776526726; Thu, 31 May 2018 07:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527776526; cv=none; d=google.com; s=arc-20160816; b=fkqRRzQqqh1ofkV4ENdhnLJDVz70uNWll1ZF8iXjWT4KsKi68BxUAiQARU1CDojViV WpKrlHuGeeYndmaxQrxZVB3S6h+lprxWhbGKOCljmkjZWp7vI9OLyYktjObOtNp88gOx fCb6TV5KFbvSOPVTJvOKRf5YUGUjv+mbqwpJ3DHcZ+Vplei8UHx0mNQm3BGBmSE8NdRJ uO6FUUxEDgFY4VBTLMPji9C5tKeH3Tf8abHN8S+e9oDMWqp0n9ttQCCit5iumyNFcpmk HkkG/zpMm+85CHotcrGN9gHYNYPlMiPEXjAtn9OUTw25q4/UoRFdJPmH9//sl7YqepD/ I4cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:ironport-phdr :arc-authentication-results; bh=zt2n8UV0b6F52JjTQeOnHmiAM5b1fYQfOq4OpvvFDcw=; b=Dgwiu9UutduQ9mS0gw6Qd/+656XSfHbpmYvSBVPusLmkEFjlE4EMnrlMjjyIOXuN+n 5wQ++WP3Giy54febbUeW88YfUjh//IwXvz1B6rO5Fbi49P1J/5m285OwqoIuv/cLdgRc e0CgF6nL4FErw1pzMzFt2/EiR+DGwkdEO0ilEwDwo5saixxqBYAKnvpBkcJDMeevrGBp PhKfR8cC+MD3lco2Z1V4pie1+yfHuQCzPAtYsFqmX8nELRL/y0of16qz4ASbiVOIMhC5 zx0QepUPFYgAhsP8Zo+GXhRG+84wQDgdPNMeODDOCwprnGoEBeAiQCUGdFPm8r2TVqMt 6D8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x135-v6si1486860pgx.424.2018.05.31.07.21.52; Thu, 31 May 2018 07:22:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755338AbeEaOUI (ORCPT + 99 others); Thu, 31 May 2018 10:20:08 -0400 Received: from uphb19pa11.eemsg.mail.mil ([214.24.26.85]:21268 "EHLO USFB19PA14.eemsg.mail.mil" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755159AbeEaOUD (ORCPT ); Thu, 31 May 2018 10:20:03 -0400 Received: from emsm-gh1-uea11.ncsc.mil ([214.29.60.3]) by USFB19PA14.eemsg.mail.mil with ESMTP/TLS/AES256-SHA; 31 May 2018 14:19:51 +0000 X-IronPort-AV: E=Sophos;i="5.49,463,1520899200"; d="scan'208";a="13987305" IronPort-PHdr: =?us-ascii?q?9a23=3A8pgWER0XFWSInWTHsmDT+DRfVm0co7zxezQtwd?= =?us-ascii?q?8ZsesRK/nxwZ3uMQTl6Ol3ixeRBMOHs68C07KempujcFRI2YyGvnEGfc4EfD?= =?us-ascii?q?4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFA?= =?us-ascii?q?nhOgppPOT1HZPZg9iq2+yo9JDffwVFiCChbb9uMR67sRjfus4KjIV4N60/0A?= =?us-ascii?q?HJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L2?= =?us-ascii?q?81/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QKsqUj?= =?us-ascii?q?q+8ahkVB7oiD8GNzEn9mHXltdwh79frB64uhBz35LYbISTOfVwZKPdec4RS3?= =?us-ascii?q?RHUMhfSidNBpqwY5UTA+YEO+tTsovzqEYUrRamGAeiGu3vxD9LiHH406I13O?= =?us-ascii?q?YuHh3J0gE7A9IDs27ZoMnpOKocU+24yrTDwzXZb/NR3Dfw8JXGcgw/rvGUXb?= =?us-ascii?q?J/b8zRwlQyGQPAlFqQrYjlMC2V1+8QtGWb9PdvVfm0hm47qwB+vjivxsA2ho?= =?us-ascii?q?nPnYIa0ErI9Sp+wIYrPNC1TlNwb928EJZIqi2XOIR7TtkiTm11oio21LILtY?= =?us-ascii?q?ChcCQXzpks2gTRZOadc4eS5xLuTOORITBli317YL+/nBOy8VS4yu37S8m0zE?= =?us-ascii?q?5GripbndnIsXAAzwDT5dKdSvt840ehwiyD1xzT6+5YIUA0krDXK5g9zb4rip?= =?us-ascii?q?Ufq0HDHi7ymEnuja+WcFsr+vSw5uj6bbjrqYWQOo9phg3kLKgjldKzDf4lPg?= =?us-ascii?q?QWWmiU4+W81Lnt/U3jR7VKi+U7krLEv5DBPskbuq64DBNV0oYk8Rq/CSym38?= =?us-ascii?q?4CkXkIK1JFZgqLj5L1NFHWPPD4EfC/jky0kDh12/DJIKfhDo/TIXjFjbjuY6?= =?us-ascii?q?x95FVbyAopwtBS/IlUCrYHIPPzQEP+qNvYDhohOQyu3+nnEMl91p8ZWW+XGq?= =?us-ascii?q?+WKr7SsVuT6+I3OeaMeYsVtC/4K/gi4P7ul2E2lUUBcqmu2JsdcGq4Eeh+I0?= =?us-ascii?q?WFfXrshc8MHnkSvgUkVuzqiUaCXCVLZ3moRaI85yo7CJqiDYjZWo+inqaN3C?= =?us-ascii?q?ChHp1ZfmpGEEyDEW/0d4WYXPcBcCCSIspmkjweT7ihSpQh2AqotADgzrpoMO?= =?us-ascii?q?vU9jcftZL529h///fTmg0q9TxoE8Sd1HmAQHxukWMORj85wqR/oU5mx1eGz6?= =?us-ascii?q?d4h/hYGsZV5/NOXQY2L4LTz+t/C9rqQALOYs+JSEq6QtWhGTw+U9YxzMETbE?= =?us-ascii?q?ZzHNWilA3M0jGwA7ALirOLBIY78r7G03ftIMZ9zm7M1LM9gFk+XstPKWqmi7?= =?us-ascii?q?Z79wjSAY7JjkqYm7+xdasCwCHN6X2DzWuSvEBYSQJwVKLFUm0CZkvSs9v0/V?= =?us-ascii?q?3CT7CwBrQ9KAdBytCNKrFMatL3iVVKXvDjOM7RY2ipgWe/GQ6Ixq+QbIrtY2?= =?us-ascii?q?gd2CTdCE4ZkwEc5HqGNhYxBj2no23ACDxjDkzvY0zy/ulksn+7TVE7zxuMb0?= =?us-ascii?q?J/07q54BkVheaTS/kLxLILpD8hqyloHFa6x9/WEMSPpxBufKpCet494E1I1W?= =?us-ascii?q?bdtw19OJysNbxthlkbcw5vpUPhyw13CplckcgttH4q1BB9Kb+c0FNEazyY3o?= =?us-ascii?q?v9OrnWKmn04RCuZLTa2k/Y0NmI5qcD8vU4pE7mvA2zCkUi9HBngJFp1C6E64?= =?us-ascii?q?nHFkIfV578SEww7Rcy86nXfiQnoY7S2XB2O66uvRfZ3NQ4QuAiz0DkN+9WLa?= =?us-ascii?q?fMMQj1CcBSU9CnNegCg1G0alcBO+dI+eg/OMbwM7Orwq+gdN5phjO9xTBK+I?= =?us-ascii?q?ln01mk7yNmS/XQ258OzrefxATRE3/ehVKsqYjSnppeZCpaSmi6zjL+BZV5YK?= =?us-ascii?q?R3cIdNDn2hdYn/6tx4hpPpE1xF7lGuAUhOjMOgfxufa17V2ABU0U0Rpmzhki?= =?us-ascii?q?y9mXg8vzY0oeK70SDAxP7uPE4LPmNHSm54gX/2LIS0hsxcV0+tOUxhjxah5E?= =?us-ascii?q?Dn14BHta9/KC/VWk4OcC/oaylmU62tpv+ZbsVS8pI0oGBSV+ihZV2yVLHwuV?= =?us-ascii?q?0Z3jnlEm8Ywyo0M3muu5Pkj1l5hXibIXJbsnXUY4dzyA3Z6diaQuRemnJMfy?= =?us-ascii?q?RihjSfKxD6d/mg+dGFkd2L5vuzTW2sfp1adS36y8WLsy7toSUgORSim7ie0p?= =?us-ascii?q?uvNAMZ3Cn92sggHXHQpQv4Z4Lo/6C7N/93OFduCUO66sB/XIp5l91jqosX3C?= =?us-ascii?q?0hmpiN/XcB2Vz2ONFf1LO2OGEBXhYX0tXV507jw0QlIXWXkdGqHk6By9dsMo?= =?us-ascii?q?HpKlgd3TgwuoUTUv+Z?= X-IPAS-Result: =?us-ascii?q?A2AJAwBCAxBb/wHyM5BcGgEBAQEBAgEBAQEIAQEBAYMZK?= =?us-ascii?q?2J/hB+UZkUBAQEBAQEGfymBD5NQgWQ2AYRAAoIEITgUAQIBAQEBAQECAWsog?= =?us-ascii?q?jUkAYJOAQEBAQIBIw8BSwsLGAICJgICVwYBDAgBAYJeQAKBcgUIpxqCHIN4A?= =?us-ascii?q?QFeg2uBaIEKhzWBDIEHgQ8kgmmEN4M8glQCmGgJjloGgTyGV4R/K4cuixQhg?= =?us-ascii?q?VIrCAIYCCEPgn+CHxeNYQFRI4EqAQGMRiqCHQEB?= Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by emsm-gh1-uea11.NCSC.MIL with ESMTP; 31 May 2018 14:19:50 +0000 Received: from moss-pluto.infosec.tycho.ncsc.mil (moss-pluto.infosec.tycho.ncsc.mil [192.168.25.131]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id w4VEJl0f032434; Thu, 31 May 2018 10:19:48 -0400 Subject: Re: [PATCH V3 0/5] selinux:Significant reduce of preempt_disable holds To: peter enderborg , Paul Moore , Eric Paris , James Morris , Daniel Jurgens , Doug Ledford , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Serge E . Hallyn" , "Paul E . McKenney" References: <20180530141104.28569-1-peter.enderborg@sony.com> <8bbb095e-31c3-0062-d17c-662e4832cc17@tycho.nsa.gov> <1cf240b9-57ee-eee3-228f-5ad4a3a39e57@sony.com> <9332801c-6102-2486-ab60-b48bb38ae207@tycho.nsa.gov> <71925d61-743e-76a1-b0dd-1948468e2773@sony.com> From: Stephen Smalley Message-ID: Date: Thu, 31 May 2018 10:21:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <71925d61-743e-76a1-b0dd-1948468e2773@sony.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/31/2018 10:12 AM, peter enderborg wrote: > On 05/31/2018 02:42 PM, Stephen Smalley wrote: >> On 05/31/2018 05:04 AM, peter enderborg wrote: >>> On 05/30/2018 10:34 PM, Stephen Smalley wrote: >>>> On 05/30/2018 10:10 AM, Peter Enderborg wrote: >>>>> The boolean change becomes a lot more heavy with this patch, >>>>> but it is a very rare usage in compare with read only operations. >>>>> The lock held during a policydb_copy is about 1ms on a XEON. >>>> This has a very substantial performance impact on setsebool, e.g. time setsebool httpd_can_sendmail=1. >>>> That's because you are doing a full vmalloc();policydb_write();policydb_read();vfree() sequence on it. >>>> In comparison, KaiGai's old attempt to replace the policy rwlock with RCU only duplicated the conditional policydb state (via a cond_policydb_dup) that he introduced. Is there a reason you couldn't use that approach? >>> That one did not make it, so I went for a other path. Make it simple, using the same serialisation that exist. That also make it easier to maintain. >>> We do not  use the booleans in android since they are not allowed so im not aware of any use case where this administrative function are >>> used in such frequent manner that it would have an impact. And it must be some other large overhead with interprocess communication and >>> a multiple writes to sysfs during a boolean settings?  However my concern is/was memory pressure, setting booleans will generate pressure >>> with lot of atomic allocation and large vmallocs. >> Yes, that is also a concern. I would prefer to only duplicate the conditional policydb state as in KaiGai's patch. >> Keeping temporary setting of booleans lightweight is desirable for other use cases than Android. >> >> I'm also concerned by the implications of switching all of the allocations to atomic. KaiGai's patch did not take that approach either, and it obviously could make policy reload more prone to transient failures. > > On the version 2 of the patchset you pointed out that I did a shallow copy, so I did a "deap" copy. As I see it the KaiGai cond_policydb_dup also do a shallow copy. In your earlier patch set, you just did a memcpy of the policydb and then proceeded to mutate parts of the conditional policydb state, which would have modified the original too. KaiGai was performing a deep copy of the conditional portions of the policydb I believe. > You dont happend to know exactly why KaiGai's patch never was accepted? As I recall, there wasn't anything wrong with the code itself; he just wasn't satisfied that it ended up being a worthwhile tradeoff based on his own performance testing. > >> But my goal is the fast path for real time critical functions such as audio, and it will be a cost for >>> administrative tasks. On the xeon it takes about ~98 ms to run the security_set_bools compared to about ~8 ms without the overhead >>> of copying the policydb.  About ~6 ms is rcu sync and ~8 ms is the same as the original update of selinux statuses, and about ~25 ms >>> is policydb_destroy() of the old copy. >> >> >>