Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751513AbdFFMNS (ORCPT ); Tue, 6 Jun 2017 08:13:18 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:28084 "EHLO lhrrgout.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbdFFMNR (ORCPT ); Tue, 6 Jun 2017 08:13:17 -0400 Subject: Re: [PATCH 4/5] Make LSM Writable Hooks a command line option To: Tetsuo Handa , , , , CC: , , , , , , References: <71e91de0-7d91-79f4-67f0-be0afb33583c@schaufler-ca.com> <201706060550.HAC69712.OVFOtSFLQJOMFH@I-love.SAKURA.ne.jp> <201706061954.GBH56755.QSOOFMFLtJFVOH@I-love.SAKURA.ne.jp> <6c807793-6a39-82ef-93d9-29ad2546fc4c@huawei.com> <201706062042.GAC86916.FMtHOOFJOSVLFQ@I-love.SAKURA.ne.jp> From: Igor Stoppa Message-ID: <4c3e3b8b-6507-7da5-1537-1e0ce04fcba5@huawei.com> Date: Tue, 6 Jun 2017 15:11:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <201706062042.GAC86916.FMtHOOFJOSVLFQ@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.122.225.51] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0205.59369C52.00FB,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e048bc0892a6220071d75ebe898d630d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1313 Lines: 42 On 06/06/17 14:42, Tetsuo Handa wrote: > Igor Stoppa wrote: >> Who decides when enough is enough, meaning that all the needed modules >> are loaded? >> Should I provide an interface to user-space? A sysfs entry? > > No such interface is needed. Just an API for applying set_memory_rw() > and set_memory_ro() on LSM hooks is enough. > > security_add_hooks() can call set_memory_rw() before adding hooks and > call set_memory_ro() after adding hooks. Ditto for security_delete_hooks() > for SELinux's unregistration. I think this should be considered part of the 2nd phase "write seldom", as we agreed with Kees Cook. Right now the goal was to provide the basic API for: - create pool - get memory from pool - lock the pool - destroy the pool And, behind the scene, verify that a memory range falls into Pmalloc pages. Then would come the "write seldom" part. The reason for this is that a proper implementation of write seldom should, imho, make writable only those pages that really need to be modified. Possibly also add some verification on the call stack about who is requesting the unlocking. Therefore I would feel more comfortable in splitting the work into 2 part. For the case at hand, would it work if there was a non-API call that you could use until the API is properly expanded? -- igor