Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4647129imm; Mon, 14 May 2018 10:29:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/F43DVBrOYVdrIiqUmyO36yb4m8+uY2a8QblLBbWkG/JTbrosuQLk0oXZQsdoGZmgtqB5 X-Received: by 2002:a17:902:264:: with SMTP id 91-v6mr10763714plc.341.1526318998080; Mon, 14 May 2018 10:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318998; cv=none; d=google.com; s=arc-20160816; b=faNevfP3v4glhaIWFZNCBYl6I3lULon3VYKwUaAUC5i2C8ucX2tljN7XY5OpV3u397 NJBQtPmwVaeCIfmV94IQ7ZUKcKI4PZPs8vA27g3TeCpT/4mKjigl7mKSgIPAmnKxba2W Izl53SaWYlZ2OuWDvTYyc2iR2mBHWO1SQle/FxSEi8pNlGlKkdjCgRJ9eRTejnjmaRMz nXvwTngfRaahuB0nr3vlJr0/Tr8kNRaMwNxZ03rc9JUeFnFYHA7XMkMt/uznEq4OEzk5 EpcA6P+6N9i+W+vbDsTVdIB7Dylov3cqwW3ubgvaPFE4/EEzhgC9a2bRYeMbMtj6vh5+ uqGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature :arc-authentication-results; bh=nLQnTyKcQtwzW4OJQw5fG8+r1nceISCcJlikYw3rFvw=; b=Bh48WUXNV2nRGfcfdj1MhOq1HpffHSLTtp1BcMVUn1/ELR9CWqMdtX20KlrfdrcATG /FOtTvN8KE/gdyM5bsTTY/oIMqI6yrSZIdWrd9XpOSYGPkTpaJ79zIHsnep9zQ/mHkpV /8YrbQpKQA2mgp68Nz28nz3rkclbONQn+sEQxwPfaa4s0BUWscA7lVmYTh1H1mU8ZRp4 jm8yHygPVh2ohdYW/s3z0NoJu1nRTSCHL8RNev1/IcPX0OlTHTHYlB0tZya5nnw7X44+ oIJw5az9fzZL+nwYgzymBqcaolhNzhgm+9JGs2ygescsU5qIMRKmKBeMeH+e5/o7hiBo tSuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=kInrvMcs; 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 c9-v6si9565101plz.501.2018.05.14.10.29.43; Mon, 14 May 2018 10:29:58 -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; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=kInrvMcs; 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 S1755136AbeENQcd (ORCPT + 99 others); Mon, 14 May 2018 12:32:33 -0400 Received: from sonic306-27.consmr.mail.ne1.yahoo.com ([66.163.189.89]:33323 "EHLO sonic306-27.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbeENQcb (ORCPT ); Mon, 14 May 2018 12:32:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1526315550; bh=nLQnTyKcQtwzW4OJQw5fG8+r1nceISCcJlikYw3rFvw=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=kInrvMcsPp2YzOFCg44gEY7ypt1TVPog8zvBNEHqj75gSo23pSMF6B2rY0Ta3G0l14KKzz5RgACyV+nJUsJkVjyNnJgXXgRPx4wkID7sT7KCBwbXpxFJWdlZlboS1scBoSgVtnwA2kUqAty5stySuKmMjNvqYbpeTDeT4kVruZiQXvTcxOUwNLIbCMf2hsICabgv1VGLJ/iwl7BxAH+SmbIm3+MwrBE2qw3BVRkjnGHPdnWmv+y21p4zBASJVLfkxoaszKOjeyTpQ1qOTLtb8oI9YDkaf6UcUHutr4ryvMWgdn+gGjI3pkJ3VX7KZveLX3mV2dYpIb0paPDBM3cdVg== X-YMail-OSG: N59QDU8VM1kcYFj0HASCEGEf.3Zem.N0jahV9d6qxAaA8k_jeRkdMBKGWk7zexV MZnyiQ8aYE9nV2jU1zmYFdOL1OLa3NfFa.nheKf1GJBPPfZr5cyBFqiJlrqOTLVUK2tCn0WPGFMP cDYmSG.QBqQg.2Lt4huOexJImKQKOZ2OCoLh90eC8fKadTBTujACg1wbCgKQVvRMuGBjKF9pMISu QMOpzoTKswCxFG8t6zTWbeSy_DlCKEYoJh9F4KIy4fAfbuJ3Cg7WipQlE3iNK47RqdzeigKHe00o .LRdm6Z6yI5.T_x2g7lG8YsAOnexCxAiPgOR82oFqn5wIayGrLVT_XZEAUYGJ6EH3.tkl4BPwOg. cc2QO7KR0IqNdFrif2i1Q_i1pHss119uvnPw8n_F55knRv8rwZMpT0Ve505xTZ6Szh1cf_P6KBNv yBuXaES5luqDj2q85GPPGHHoIrnUHHzzZevtoFP96xQzZAzlE79cK4SRQEYTZqWSf8Uv4S0yQrB0 O1j2Pyma_sPWb7Y1oCjpiDdpWujk9wkeSbIhO_NSLkBE9T8dZd1NOKsUnRJMgsjpLdH4eBOl.NHg N5c4epDRQn18Tfw78Hy.7yhZzha3nux0KfiMjBzNIBUKFAIWLGDio5O19Qq740bNQlUwfcFTl9gd oDyc- Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Mon, 14 May 2018 16:32:30 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp416.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 08ff0dd73faf1af667df11d52ebf221e; Mon, 14 May 2018 16:32:30 +0000 (UTC) Subject: Re: [PATCH 10/23] LSM: Infrastructure management of the inode security To: Stephen Smalley , LSM , LKLM , Paul Moore , SE Linux , "SMACK-discuss@lists.01.org" , John Johansen , Kees Cook , Tetsuo Handa , James Morris References: <7e8702ce-2598-e0a3-31a2-bc29157fb73d@schaufler-ca.com> From: Casey Schaufler Message-ID: <906d5338-0021-740d-36dc-0f32b2c36f55@schaufler-ca.com> Date: Mon, 14 May 2018 09:32:28 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/14/2018 8:04 AM, Stephen Smalley wrote: > On 05/10/2018 08:53 PM, Casey Schaufler wrote: >> From: Casey Schaufler >> Date: Thu, 10 May 2018 14:23:27 -0700 >> Subject: [PATCH 10/23] LSM: Infrastructure management of the inode security >> blob >> >> Move management of the inode->i_security blob out >> of the individual security modules and into the security >> infrastructure. Instead of allocating the blobs from within >> the modules the modules tell the infrastructure how much >> space is required, and the space is allocated there. >> >> Signed-off-by: Casey Schaufler >> --- >> include/linux/lsm_hooks.h | 3 ++ >> security/security.c | 85 +++++++++++++++++++++++++++++++++++++-- >> security/selinux/hooks.c | 32 +-------------- >> security/selinux/include/objsec.h | 5 +-- >> security/smack/smack_lsm.c | 70 +++++--------------------------- >> 5 files changed, 99 insertions(+), 96 deletions(-) >> >> diff --git a/security/security.c b/security/security.c >> index b414186ad45f..02df9b608b7e 100644 >> --- a/security/security.c >> +++ b/security/security.c >> @@ -41,6 +41,7 @@ struct security_hook_heads security_hook_heads __lsm_ro_after_init; >> static ATOMIC_NOTIFIER_HEAD(lsm_notifier_chain); >> >> static struct kmem_cache *lsm_file_cache; >> +static struct kmem_cache *lsm_inode_cache; >> >> char *lsm_names; >> static struct lsm_blob_sizes blob_sizes; >> @@ -98,6 +99,10 @@ int __init security_init(void) >> lsm_file_cache = kmem_cache_create("lsm_file_cache", >> blob_sizes.lbs_file, 0, >> SLAB_PANIC, NULL); >> + if (blob_sizes.lbs_inode) >> + lsm_inode_cache = kmem_cache_create("lsm_inode_cache", >> + blob_sizes.lbs_inode, 0, >> + SLAB_PANIC, NULL); >> /* >> * The second call to a module specific init function >> * adds hooks to the hook lists and does any other early >> @@ -108,8 +113,9 @@ int __init security_init(void) >> #ifdef CONFIG_SECURITY_LSM_DEBUG >> pr_info("LSM: cred blob size = %d\n", blob_sizes.lbs_cred); >> pr_info("LSM: file blob size = %d\n", blob_sizes.lbs_file); >> + pr_info("LSM: inode blob size = %d\n", blob_sizes.lbs_inode); >> pr_info("LSM: task blob size = %d\n", blob_sizes.lbs_task); >> -#endif >> +#endif /* CONFIG_SECURITY_LSM_DEBUG */ >> >> return 0; >> } >> @@ -285,6 +291,13 @@ void __init security_add_blobs(struct lsm_blob_sizes *needed) >> lsm_set_size(&needed->lbs_cred, &blob_sizes.lbs_cred); >> lsm_set_size(&needed->lbs_file, &blob_sizes.lbs_file); >> lsm_set_size(&needed->lbs_task, &blob_sizes.lbs_task); >> + /* >> + * The inode blob gets an rcu_head in addition to >> + * what the modules might need. >> + */ >> + if (needed->lbs_inode && blob_sizes.lbs_inode == 0) >> + blob_sizes.lbs_inode = sizeof(struct rcu_head); >> + lsm_set_size(&needed->lbs_inode, &blob_sizes.lbs_inode); >> } >> >> /** >> @@ -348,6 +361,46 @@ void lsm_early_task(struct task_struct *task) >> panic("%s: Early task alloc failed.\n", __func__); >> } >> >> +/** >> + * lsm_inode_alloc - allocate a composite inode blob >> + * @inode: the inode that needs a blob >> + * >> + * Allocate the inode blob for all the modules >> + * >> + * Returns 0, or -ENOMEM if memory can't be allocated. >> + */ >> +int lsm_inode_alloc(struct inode *inode) >> +{ >> + if (!lsm_inode_cache) { >> + inode->i_security = NULL; >> + return 0; >> + } >> + >> + inode->i_security = kmem_cache_zalloc(lsm_inode_cache, GFP_KERNEL); > Should be GFP_NOFS (and was that way in SELinux and Smack). Yes, you're correct. I'll make the change.