ext2+ext3 init_security stacking
PATCH 1/1 ext2+ext3 init_security stacking
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 <[email protected]>
--
ext2/xattr_security.c | 30 ++++++++++++++++++++++++++---- ext3/xattr_security.c | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 8 deletions(-)
fs/ext2/xattr_security.c +26 -4
@@ -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;
fs/ext3/xattr_security.c +31 -4
@@ -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, strreturn 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;