* [PATCH] [LSM - stacker] ext2+ext3 init_security stacking
@ 2005-08-11 21:24 serue
0 siblings, 0 replies; only message in thread
From: serue @ 2005-08-11 21:24 UTC (permalink / raw)
To: lkml; +Cc: Stephen Smalley, James Morris, Chris Wright
This patch redies ext2 and ext3 for stacking inode_init_security. It
mainly needs to check for multiple name/value pairs, and call xattr_set
for each pair.
thanks,
-serge
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
--
ext2/xattr_security.c | 30 ++++++++++++++++++++++++++----
ext3/xattr_security.c | 35 +++++++++++++++++++++++++++++++----
2 files changed, 57 insertions(+), 8 deletions(-)
Index: linux-2.6.13-rc5-mm1/fs/ext2/xattr_security.c
===================================================================
--- linux-2.6.13-rc5-mm1.orig/fs/ext2/xattr_security.c 2005-08-11 18:55:45.000000000 -0500
+++ linux-2.6.13-rc5-mm1/fs/ext2/xattr_security.c 2005-08-11 19:08:18.000000000 -0500
@@ -50,9 +50,10 @@ int
ext2_init_security(struct inode *inode, struct inode *dir)
{
int err;
- size_t len;
+ size_t len, runlen;
void *value;
- char *name;
+ char *vfirst, *vstart, *vend;
+ char *name, *nstart, *nend;
err = security_inode_init_security(inode, dir, &name, &value, &len);
if (err) {
@@ -60,8 +61,29 @@ ext2_init_security(struct inode *inode,
return 0;
return err;
}
- err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY,
- name, value, len, 0);
+ runlen = 0;
+ vstart = vfirst = value;
+ nstart = name;
+ do {
+ size_t tmplen = 0;
+
+ vend = vstart;
+ while (*vend && runlen+tmplen<len)
+ vend++;
+ while (!*nstart)
+ nstart++;
+ nend = nstart;
+ while (*nend)
+ nend++;
+
+ err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY,
+ nstart, vstart, tmplen, 0);
+ vstart = vend;
+ while (!(*vstart) && vstart-vfirst<len)
+ vstart++;
+ nstart = nend;
+ } while (vstart-vfirst < len);
+
kfree(name);
kfree(value);
return err;
Index: linux-2.6.13-rc5-mm1/fs/ext3/xattr_security.c
===================================================================
--- linux-2.6.13-rc5-mm1.orig/fs/ext3/xattr_security.c 2005-08-11 18:55:45.000000000 -0500
+++ linux-2.6.13-rc5-mm1/fs/ext3/xattr_security.c 2005-08-11 19:09:49.000000000 -0500
@@ -52,9 +52,10 @@ int
ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir)
{
int err;
- size_t len;
+ size_t len, runlen;
void *value;
- char *name;
+ char *vfirst, *vstart, *vend;
+ char *name, *nstart, *nend;
err = security_inode_init_security(inode, dir, &name, &value, &len);
if (err) {
@@ -62,8 +63,34 @@ ext3_init_security(handle_t *handle, str
return 0;
return err;
}
- err = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_SECURITY,
- name, value, len, 0);
+ runlen = 0;
+ vstart = vfirst = value;
+ nstart = name;
+ do {
+ size_t tmplen = 0;
+
+ vend = vstart;
+ while (*vend && runlen+tmplen<len)
+ vend++;
+ while (!*nstart)
+ nstart++;
+ nend = nstart;
+ while (*nend)
+ nend++;
+
+ if (err) {
+ if (err == -EOPNOTSUPP)
+ return 0;
+ return err;
+ }
+ err = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_SECURITY,
+ nstart, vstart, tmplen, 0);
+ vstart = vend;
+ while (!(*vstart) && vstart-vfirst<len)
+ vstart++;
+ nstart = nend;
+ } while (vstart-vfirst < len);
+
kfree(name);
kfree(value);
return err;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-08-11 21:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-11 21:24 [PATCH] [LSM - stacker] ext2+ext3 init_security stacking serue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox