From: Paul Moore <paul.moore@hp.com>
To: Yuichi Nakamura <ynakam@hitachisoft.jp>
Cc: selinux@tycho.nsa.gov, Stephen Smalley <sds@tycho.nsa.gov>,
busybox@kaigai.gr.jp, James Morris <jmorris@namei.org>,
Eric Paris <eparis@parisplace.org>,
kaigai@ak.jp.nec.com
Subject: Re: [RFC]Tuning selinux_file_permission
Date: Wed, 5 Sep 2007 10:19:44 -0400 [thread overview]
Message-ID: <200709051019.44607.paul.moore@hp.com> (raw)
In-Reply-To: <20070903170020.D7E4.YNAKAM@hitachisoft.jp>
On Monday, September 3 2007 4:04:46 am Yuichi Nakamura wrote:
> +static int selinux_file_permission(struct file *file, int mask)
> +{
> +
> + struct task_security_struct *tsec = current->security;
> + struct file_security_struct *fsec = file->f_security;
> + int rc;
> + u32 current_sid_serial;
> +
> + if (!mask) {
> + /* No permission to check. Existence test. */
> + return 0;
> + }
> +
> + /*Check FS__USE*/
> + if (tsec->sid != fsec->sid) {
> + struct vfsmount *mnt = file->f_path.mnt;
> + struct dentry *dentry = file->f_path.dentry;
> + struct avc_audit_data ad;
> + AVC_AUDIT_DATA_INIT(&ad, FS);
> + ad.u.fs.mnt = mnt;
> + ad.u.fs.dentry = dentry;
> + rc = avc_has_perm(tsec->sid, fsec->sid,
> + SECCLASS_FD,
> + FD__USE,
> + &ad);
> + if (rc)
> + return rc;
> + }
> +
> + /*Skip permission check
> + when sids are not changed after open*/
> + current_sid_serial = read_sid_serial();
> + if (fsec->sid_serial == current_sid_serial &&
> + !(fsec->force_file_check))
> + return 0;
Instead of simply returning 0 here, you should return the return value from
selinux_netlbl_inode_permission just like you are doing in your
do_selinux_file_permission() function above.
This NetLabel call is required to ensure that the on-the-wire label is set
correctly for connected stream sockets initiated by a remote host. It may be
possible to do away with this call at some point but it requires additional
functionality which we do not have at present.
> + rc = do_selinux_file_permission(file, mask);
> + if (rc)
> + return rc;
> +
> + fsec->sid_serial = current_sid_serial;
> + fsec->force_file_check = 0;
> +
> + return 0;
> +}
--
paul moore
linux security @ hp
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2007-09-05 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-03 8:04 [RFC]Tuning selinux_file_permission Yuichi Nakamura
2007-09-04 13:26 ` Stephen Smalley
2007-09-05 14:43 ` Yuichi Nakamura
2007-09-04 13:41 ` Stephen Smalley
2007-09-05 14:19 ` Paul Moore [this message]
2007-09-05 14:45 ` Yuichi Nakamura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200709051019.44607.paul.moore@hp.com \
--to=paul.moore@hp.com \
--cc=busybox@kaigai.gr.jp \
--cc=eparis@parisplace.org \
--cc=jmorris@namei.org \
--cc=kaigai@ak.jp.nec.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=ynakam@hitachisoft.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.