Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp25967imm; Fri, 21 Sep 2018 17:20:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60RzF/4nGMDgceszFoWhf+gzR7NMgtwUhORqGveZ2guhXZJ6LrTnX80qXMX8B+gpF4lDBvN X-Received: by 2002:a17:902:7798:: with SMTP id o24-v6mr97004pll.93.1537575602630; Fri, 21 Sep 2018 17:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575602; cv=none; d=google.com; s=arc-20160816; b=BZlSLha96/bPZoA2uKvzn8+imqIoGR0iSIGC/kkyZqM4kY3lrhu7rLdpqfOAxNuq+O pvGKD2iAFU69CquFP4KC0GhpWQWiYRrAVsT85g45umkbB113NC2pELixGvgfGtseu6kl Y+VSMs0sMebLmFIhkTVJU+xax+6jRXVO+szJq3DHbDtl/m8c/mJafrpHgnL+gTvdUyIN camw9NVAyJWJPymiMODCbkpjiyaYTkV15mTeESIdoGjVfOzNnbLL5pqQp2L0EB1fMKB5 89PqXN/e7I70vNjteIKHTGV5LZVR4pw5+fbcIiVS7qo3gJCuEHG0vgrnMNDv3EtZFACr LiRw== 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; bh=lpcJ0LJNJQkOQB1cATo9pTayV1N+KRu1y19vOF1v29s=; b=nOBfaXI6FQnAKP2gNhxzk+Wm/i7VmmPNK/N/yod3+0Ht1d4BY8R3azV6HQQ7dIiiIu weuwgi5yW3taZz4qzE4/y5ca83rFIVZMtxfeTeGZPdwCehtErZOXVp4ZxojOw+BCo/Qg dcyiEx9P/xn+9lBpZZ1lsVH+MC2tWCMSjUJCC7tS6MzYEwyXROp193dCDBO8Ql5uHStL YYpCzd2DWfH07Gl610aXjL5asMc5yUlUszHQECx5rAWaDcCNmByfh86TEE/n/Bd10kHm a8lDk6qvW26p+mLQRaBD93/9aq79lzkDRvI2SPuy+qCsKxaECwKEK2Fr9sn7odH9b7OA Td+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=iXUNPLh0; 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 u129-v6si30102572pfb.247.2018.09.21.17.19.43; Fri, 21 Sep 2018 17:20:02 -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=iXUNPLh0; 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 S2391724AbeIVGKR (ORCPT + 99 others); Sat, 22 Sep 2018 02:10:17 -0400 Received: from sonic306-10.consmr.mail.bf2.yahoo.com ([74.6.132.49]:43367 "EHLO sonic306-10.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391585AbeIVGKQ (ORCPT ); Sat, 22 Sep 2018 02:10:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1537575539; bh=lpcJ0LJNJQkOQB1cATo9pTayV1N+KRu1y19vOF1v29s=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=iXUNPLh0P6caU33tNq6uq6cugVxCUwOUNVneMIgQm6lTVWwlNMdwiVtUUfJcgr2CMhLnNnlnoLobcJBZMKHHpzzFBgOjwHwQt99p1xZHEIIDul1dblymAFqL6EosMQt+YrNxSKzBEyzhy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TyxY7TjlKZJCHkcWl7d0.CkKNIw ZuTV5VgTEaT2EtRkrvI2pC.TvdhmjWAexjfz5G42iGBSqzRam4NnwuA67mqaNkYdzcRROeuYdJQK RYJJdRZFEkXuWU4jSVr9_nhTmRvZ0o21sho4pCP74ozKAZEbuAcPwAa8Z12d1ZPtwww.0Q7RqQ5Y Ph25NF5n.YcHam1PKdYT8GB1XMClYdlqnkrUqkFrehUY- Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.bf2.yahoo.com with HTTP; Sat, 22 Sep 2018 00:18:59 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.102]) ([67.169.65.224]) by smtp410.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 6faf49e772eb78bd00dc72e8b7f62217; Sat, 22 Sep 2018 00:18:54 +0000 (UTC) Subject: [PATCH v4 10/19] Smack: Abstract use of file security blob To: LSM , James Morris , SE Linux , LKLM , John Johansen , Kees Cook , Tetsuo Handa , Paul Moore , Stephen Smalley , "linux-fsdevel@vger.kernel.org" , Alexey Dobriyan , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Salvatore Mesoraca References: From: Casey Schaufler Message-ID: Date: Fri, 21 Sep 2018 17:18:49 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 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 Don't use the file->f_security pointer directly. Provide a helper function that provides the security blob pointer. Signed-off-by: Casey Schaufler --- security/smack/smack.h | 5 +++++ security/smack/smack_lsm.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/security/smack/smack.h b/security/smack/smack.h index 01a922856eba..22ca30379209 100644 --- a/security/smack/smack.h +++ b/security/smack/smack.h @@ -361,6 +361,11 @@ static inline struct task_smack *smack_cred(const struct cred *cred) return cred->security; } +static inline struct smack_known **smack_file(const struct file *file) +{ + return (struct smack_known **)&file->f_security; +} + /* * Is the directory transmuting? */ diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index a06ea8aa89c4..9ec595f0c3f1 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1571,9 +1571,9 @@ static void smack_inode_getsecid(struct inode *inode, u32 *secid) */ static int smack_file_alloc_security(struct file *file) { - struct smack_known *skp = smk_of_current(); + struct smack_known **blob = smack_file(file); - file->f_security = skp; + *blob = smk_of_current(); return 0; } @@ -1813,7 +1813,9 @@ static int smack_mmap_file(struct file *file, */ static void smack_file_set_fowner(struct file *file) { - file->f_security = smk_of_current(); + struct smack_known **blob = smack_file(file); + + *blob = smk_of_current(); } /** @@ -1830,6 +1832,7 @@ static void smack_file_set_fowner(struct file *file) static int smack_file_send_sigiotask(struct task_struct *tsk, struct fown_struct *fown, int signum) { + struct smack_known **blob; struct smack_known *skp; struct smack_known *tkp = smk_of_task(smack_cred(tsk->cred)); struct file *file; @@ -1842,7 +1845,8 @@ static int smack_file_send_sigiotask(struct task_struct *tsk, file = container_of(fown, struct file, f_owner); /* we don't log here as rc can be overriden */ - skp = file->f_security; + blob = smack_file(file); + skp = *blob; rc = smk_access(skp, tkp, MAY_DELIVER, NULL); rc = smk_bu_note("sigiotask", skp, tkp, MAY_DELIVER, rc); if (rc != 0 && has_capability(tsk, CAP_MAC_OVERRIDE)) -- 2.17.1