From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbdBUKfo (ORCPT ); Tue, 21 Feb 2017 05:35:44 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:29683 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbdBUKfi (ORCPT ); Tue, 21 Feb 2017 05:35:38 -0500 Subject: Re: [RFC 4/7] selinux: mark __ro_mostly_after_init for selinux_hooks/selinux_nf_ops To: Hoeun Ryu , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org References: <1487498660-16600-1-git-send-email-hoeun.ryu@gmail.com> <1487498660-16600-4-git-send-email-hoeun.ryu@gmail.com> Cc: Paul Moore , Stephen Smalley , Eric Paris , James Morris , "Serge E. Hallyn" , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org From: Tetsuo Handa Message-ID: Date: Tue, 21 Feb 2017 19:35:21 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <1487498660-16600-4-git-send-email-hoeun.ryu@gmail.com> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/02/19 19:04, Hoeun Ryu wrote: > It would be good that selinux hooks objects are marked as > `__ro_mostly_after_init`. They can not be simply marked as `__ro_after_init' > because they should be writable during selinux_disable procedure. > `__ro_mostly_after_init` section is temporarily read-write during > selinux_disable procedure via set_ro_mostly_after_init_rw/ro pair. Now that > they can be read-only except during the procedure. > > -static struct security_hook_list selinux_hooks[] = { > +static struct security_hook_list selinux_hooks[] __ro_mostly_after_init = { This won't work. This variable is array of "struct list_head". You need to set same attribute to variables pointed by "struct list_head"->next and "struct list_head"->prev . > LSM_HOOK_INIT(binder_set_context_mgr, selinux_binder_set_context_mgr), > LSM_HOOK_INIT(binder_transaction, selinux_binder_transaction), > LSM_HOOK_INIT(binder_transfer_binder, selinux_binder_transfer_binder),