Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp616492imu; Mon, 26 Nov 2018 15:52:16 -0800 (PST) X-Google-Smtp-Source: AJdET5fnOtJQ4QyDfLHaqi05rQpSzAQOal2Gcy2Pno1G08ZrQ1gcW1jPe/hZEQLU4ruNDhJ9Vpr7 X-Received: by 2002:a62:ca9c:: with SMTP id y28mr30248635pfk.236.1543276336807; Mon, 26 Nov 2018 15:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543276336; cv=none; d=google.com; s=arc-20160816; b=ASFa3tUc4h33O4qUgXhO3jgjgLuW/adW3jfgV8iu28iJzEeiUxCTS7QBaVbM9entAD ql98IJ9/aMSMkpqXk8uY8LX03PF3cnNNjP1ZzjTyKlOB5Mpm++7e/WCvKV1qnrB9i0gH LHgP21dZURkyoIPjWzCAxzrwFks0uhuY2PenInjFj8TPW9DzRYY/cN1pcrd5Ypl79OdX B9UWOX94LfblIwZeqZPqkx3sPoxwWr2hHfESRn8KrKCQdzylW/5WcyuRTf9eTAe4FmJt YaPFDq/DxRjKIIiRSZRoDL6O2Tvq4FIvBDwybE3aRvvbAOE8M6Um8ZZJTdqWQqm8Q7XE 74UQ== 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:cc:to:subject:dkim-signature; bh=lKw+YFFirAcuaGMfYgMV+U5QfYDFlilvNclUnUdmOyY=; b=s5Xg5llj65S/2NiPuh8Rh/sc3bR9eeWbbKXEUc66WexJjkqv60DeXJdzpvRW1UVQaj 8rMjPzpLYmj7ci1cfaeVKSYmp3IS5JmEHsWKUfnEe24PMF44vkyA9/OSgzfD7sPaN1hz Q9MWkQKm/p6P/ne/pUsan6U3Ss0uGDqHASYwyVEHw9L7FT0xaMr1JvQe6nrh5Uhnd1/s nw5FsTCVl0QMrMIGD2vra3C8T9uCKWfUVfOs72adDJnz8AdsNpTG4pc6AdlRty7zo4pE XqwX+pRd5YDCD1UhmVaRqPLNvMkWVlYXb3Y7DmZfOob9HvHk8gaWjogw7DCyUYrr9I5H 3S+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=PUZWDRr8; 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 x23si1692330pln.100.2018.11.26.15.52.02; Mon, 26 Nov 2018 15:52:16 -0800 (PST) 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=PUZWDRr8; 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 S1728068AbeK0KpV (ORCPT + 99 others); Tue, 27 Nov 2018 05:45:21 -0500 Received: from sonic302-28.consmr.mail.ne1.yahoo.com ([66.163.186.154]:36944 "EHLO sonic302-28.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbeK0KpU (ORCPT ); Tue, 27 Nov 2018 05:45:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1543276168; bh=lKw+YFFirAcuaGMfYgMV+U5QfYDFlilvNclUnUdmOyY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=PUZWDRr8EYLlnKnekUjgioCnumfLXNQ04xw1cyuCNWpBgqAZ9garQJFPRpjnjN2VEAPi+2fpWgFKHRs765YX9T4VC22Eb6PNo8fMAUFZ+jbZoWNP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y0LWf6d2k.lHIihuCuNxW5sizCsTLUt_2CoYKtXDCGghRkDqALuNu2jYoWVXfh0R2p0tK4WAK_In 5uN8ZGvq0xEg.XXTmM4lIWHC5D.s1ziyquI.2k08WJ92wURZluTJUtv0h5u0mRa6gjM4dtxCKKhT Auv4x4kY9bSY4CNbP8OUUzjDi3YKk9xFfdIuJnUeGOJpEVu7pcXCe.Un6qtu8GT3.Zj3mTli8NU5 2PTp1vYPFLrcx19hhKZH9T3TfHkkfdnO0n4VicCmw6J47Z3Q3l1rJMRQpueqRYJn50RiVFfV.N1L LUzJDNFFisUC9W9PNewBqrFtDjhTKVHVHWNA03w-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Mon, 26 Nov 2018 23:49:28 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp429.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID d56dcb8ac3e69b0ed5e21632e555d156; Mon, 26 Nov 2018 23:49:26 +0000 (UTC) Subject: [PATCH v5 29/38] Smack: Abstract use of file security blob To: James Morris , LSM , LKLM , SE Linux Cc: John Johansen , Kees Cook , Tetsuo Handa , Paul Moore , "linux-fsdevel@vger.kernel.org" , Stephen Smalley , Alexey Dobriyan , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Salvatore Mesoraca References: <50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com> From: Casey Schaufler Message-ID: Date: Mon, 26 Nov 2018 15:49:23 -0800 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: <50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com> 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 Reviewed-by: Kees Cook Signed-off-by: Kees Cook --- 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 b27eb252e953..50854969a391 100644 --- a/security/smack/smack.h +++ b/security/smack/smack.h @@ -362,6 +362,11 @@ static inline struct task_smack *smack_cred(const struct cred *cred) return cred->security + smack_blob_sizes.lbs_cred; } +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 459f7d523ca6..3e11be8cce7e 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1573,9 +1573,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; } @@ -1815,7 +1815,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(); } /** @@ -1832,6 +1834,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)); const struct cred *tcred; @@ -1845,7 +1848,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); -- 2.14.5