From: Casey Schaufler <casey@schaufler-ca.com>
To: "David P. Quigley" <dpquigl@tycho.nsa.gov>,
selinux@tycho.nsa.gov, labeled-nfs@linux-nfs.org
Cc: "David P. Quigley" <dpquigl@tycho.nsa.gov>
Subject: Re: [PATCH 7/7] NFSv4: Server implementation of MAC Labeling
Date: Wed, 1 Aug 2007 14:33:58 -0700 (PDT) [thread overview]
Message-ID: <965190.45812.qm@web36613.mail.mud.yahoo.com> (raw)
In-Reply-To: <11859985331897-git-send-email-dpquigl@tycho.nsa.gov>
--- "David P. Quigley" <dpquigl@tycho.nsa.gov> wrote:
> From: David P. Quigley <dpquigl@tycho.nsa.gov>
>
> This patch implements the encoding of a MAC label on the server side to be
> sent
> across the wire to the NFSv4 client. At this time there is no method of
> receiving a label from the client to be set on the server.
Perhaps you should look into how the ACL code deals with attributes
with non-uniform sizes.
> Signed-off-by: David P. Quigley <dpquigl@tycho.nsa.gov>
> ---
> fs/nfsd/nfs4xdr.c | 77
> ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 76 insertions(+), 1 deletions(-)
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 8ef0964..593a0b9 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -58,6 +58,7 @@
> #include <linux/nfs4_acl.h>
> #include <linux/sunrpc/gss_api.h>
> #include <linux/sunrpc/svcauth_gss.h>
> +#include <linux/security.h>
>
> #define NFSDDBG_FACILITY NFSDDBG_XDR
>
> @@ -408,6 +409,20 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32
> *bmval, struct iattr *ia
> goto xdr_error;
> }
> }
> +#ifdef CONFIG_NFSD_V4_MAC
> + if (bmval[1] & FATTR4_WORD1_MAC_LABEL) {
> + READ_BUF(4);
> + len += 4;
> + READ32(dummy32);
> + READ_BUF(dummy32);
> + len += (XDR_QUADLEN(dummy32) << 2);
> + READMEM(buf, dummy32);
> + if (security_secctx_to_secid(&iattr->ia_sid,
> + (char *)buf, dummy32) != 0)
> + goto out_nfserr;
> + iattr->ia_valid |= ATTR_MAC_LABEL;
> + }
> +#endif /* CONFIG_NFSD_V4_MAC */
> if (len != expected_len)
> goto xdr_error;
>
> @@ -1414,6 +1429,34 @@ nfsd4_encode_aclname(struct svc_rqst *rqstp, int
> whotype, uid_t id, int group,
> return nfsd4_encode_name(rqstp, whotype, id, group, p, buflen);
> }
>
> +#ifdef CONFIG_NFSD_V4_MAC
> +static inline __be32
> +nfsd4_encode_mac_label(struct svc_rqst *rqstp,
> + struct dentry *dentry,
> + __be32 **p, int *buflen)
> +{
> + char *context;
> + unsigned len = 0;
> + u32 secid;
> +
> + security_inode_getsecid(dentry->d_inode, &secid);
> + security_secid_to_secctx(secid, &context, &len);
> + if (len < 0)
> + return nfserrno(len);
> + if (*buflen < ((XDR_QUADLEN(len) << 2) + 4)) {
> + kfree(context);
> + return nfserr_resource;
> + }
> +
> + *p = xdr_encode_opaque(*p, context, len);
> + *buflen -= (XDR_QUADLEN(len) << 2) + 4;
> + BUG_ON(*buflen < 0);
> +
> + kfree(context);
> + return 0;
> +}
> +#endif /* CONFIG_NFSD_V4_MAC */
> +
> #define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID
> | \
> FATTR4_WORD0_RDATTR_ERROR)
> #define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID
> @@ -1508,6 +1551,17 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct
> svc_export *exp,
> bmval0 &= ~FATTR4_WORD0_FS_LOCATIONS;
> }
> }
> +#ifdef CONFIG_NFSD_V4_MAC
> + /**
> + * This really isn't a good way to do this. We need the framework to detect
> a
> + * mac implementation and handle this if it doesn't find one.
> + *
> + if (bmval1 & FATTR4_WORD1_MAC_LABEL) {
> + if(!selinux_enabled)
Eh Hm.
> + bmval1 &= ~FATTR_WORD1_MAC_LABEL;
> + }
> + */
> +#endif /* CONFIG_NFSD_V4_MAC */
> if ((buflen -= 16) < 0)
> goto out_resource;
>
> @@ -1518,15 +1572,25 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct
> svc_export *exp,
>
> if (bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
> u32 word0 = NFSD_SUPPORTED_ATTRS_WORD0;
> + u32 word1 = NFSD_SUPPORTED_ATTRS_WORD1;
> if ((buflen -= 12) < 0)
> goto out_resource;
> if (!aclsupport)
> word0 &= ~FATTR4_WORD0_ACL;
> if (!exp->ex_fslocs.locations)
> word0 &= ~FATTR4_WORD0_FS_LOCATIONS;
> + #ifdef CONFIG_NFSD_V4_MAC
> + /* XXX: should also be turned into a check to the framework */
> + /* XXX: turn this on unconditionally for now ...*/
> + if (1 || exp->ex_flags & NFSEXP_MAC_LABEL)
> + word1 |= FATTR4_WORD1_MAC_LABEL;
> + else
> + word1 &= ~FATTR4_WORD1_MAC_LABEL;
> + #endif /* CONFIG_NFSD_V4_MAC */
> +
> WRITE32(2);
> WRITE32(word0);
> - WRITE32(NFSD_SUPPORTED_ATTRS_WORD1);
> + WRITE32(word1);
> }
> if (bmval0 & FATTR4_WORD0_TYPE) {
> if ((buflen -= 4) < 0)
> @@ -1832,6 +1896,17 @@ out_acl:
> } else
> WRITE64((u64) stat.ino);
> }
> +#ifdef CONFIG_NFSD_V4_MAC
> + if (bmval1 & FATTR4_WORD1_MAC_LABEL) {
> + status = nfsd4_encode_mac_label(rqstp, dentry,
> + &p, &buflen);
> + if (status == nfserr_resource)
> + goto out_resource;
> + if (status)
> + goto out;
> + }
> +#endif /* CONFIG_NFSD_V4_MAC */
> +
> *attrlenp = htonl((char *)p - (char *)attrlenp - 4);
> *countp = p - buffer;
> status = nfs_ok;
> --
> 1.5.2.2
>
>
> --
> 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.
>
>
>
Casey Schaufler
casey@schaufler-ca.com
--
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-08-01 21:34 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-01 20:02 [RFC] SENFS: MAC labeling support for NFSv4 David P. Quigley
2007-08-01 20:02 ` [PATCH 1/7] Security: Add inode_{get,set}secid LSM hooks and security helper functions David P. Quigley
2007-08-01 21:01 ` Casey Schaufler
2007-08-02 3:17 ` James Morris
2007-08-01 20:02 ` [PATCH 2/7] VFS: Add sid field to iattr structure for notify_change David P. Quigley
2007-08-01 21:03 ` Casey Schaufler
2007-08-02 3:21 ` James Morris
2007-08-01 20:02 ` [PATCH 3/7] KConfig: Add KConfig entries for MAC labeled NFS David P. Quigley
2007-08-01 21:08 ` Casey Schaufler
2007-08-02 3:24 ` James Morris
2007-08-01 20:02 ` [PATCH 4/7] Security: Add secctx_to_secid LSM hooks and security helper functions David P. Quigley
2007-08-01 21:11 ` Casey Schaufler
2007-08-01 21:41 ` Paul Moore
2007-08-01 22:14 ` Casey Schaufler
2007-08-01 20:02 ` [PATCH 5/7] NFSv4: Add secid recommended attribute and NFSv4 flags David P. Quigley
2007-08-01 21:18 ` Casey Schaufler
2007-08-01 20:02 ` [PATCH 6/7] NFSv4: Client implementation of MAC Labeling David P. Quigley
2007-08-01 21:29 ` Casey Schaufler
2007-08-01 21:34 ` [Labeled-nfs] " Stephen Smalley
2007-08-01 22:06 ` Casey Schaufler
2007-08-02 3:37 ` James Morris
2007-08-02 13:12 ` Stephen Smalley
2007-08-01 20:02 ` [PATCH 7/7] NFSv4: Server " David P. Quigley
2007-08-01 21:33 ` Casey Schaufler [this message]
2007-08-02 13:10 ` Stephen Smalley
2007-08-01 20:55 ` [RFC] SENFS: MAC labeling support for NFSv4 Casey Schaufler
2007-08-01 21:30 ` Stephen Smalley
2007-08-01 21:59 ` Casey Schaufler
2007-08-02 13:19 ` Stephen Smalley
2007-08-02 15:26 ` Casey Schaufler
2007-08-02 15:43 ` Stephen Smalley
2007-08-02 16:36 ` Casey Schaufler
2007-08-02 4:19 ` James Morris
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=965190.45812.qm@web36613.mail.mud.yahoo.com \
--to=casey@schaufler-ca.com \
--cc=dpquigl@tycho.nsa.gov \
--cc=labeled-nfs@linux-nfs.org \
--cc=selinux@tycho.nsa.gov \
/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.