Re: [PATCH v2] Add security.* XATTR support for the UBIFS

From: Subodh Nijsure
Date: Wed Apr 11 2012 - 10:12:47 EST


On Wed, Apr 11, 2012 at 6:10 AM, Stephen Smalley <sds@xxxxxxxxxxxxx> wrote:
> On Wed, 2012-04-11 at 06:00 -0700, Subodh Nijsure wrote:
>> On Tue, Apr 10, 2012 at 5:46 AM, Stephen Smalley <sds@xxxxxxxxxxxxx> wrote:
>> > On Mon, 2012-04-09 at 16:51 -0700, subodh.nijsure@xxxxxxxxx wrote:
>> >> From: Subodh Nijsure <snijsure@xxxxxxxxxxxx>
>> >>
>> >> Also fix couple of bugs in UBIFS extended attribute length calculation.
>> >>
>> >> Changes Since V1:
>> >> Â Â Â Â ÂInstead of just handling security.selinux extended attribute handle
>> >> Â Â Â Â Âall security.* attributes.
>> >>
>> >> TESTING: Tested on ÂMX28 based platforms using Micron MT29F2G08ABAEAH4 NAND
>> >> Â Â Â Â ÂWith these change we are able to label UBIFS filesystem with
>> >> Â Â Â Â Âsecurity.selinux and run system with selinux enabled.
>> >> Â Â Â Â ÂThis change also allows one to set other security.* extended
>> >> Â Â Â Â Âattributesr, such as security.smack security.evm, security.ima
>> >> Â Â Â Â ÂRan integck test on UBI filesystem.
>> >>
>> >> Signed-off-by: Subodh Nijsure <snijsure@xxxxxxxxxxxx>
>> >> ---
>> >> Âfs/ubifs/dir.c   |  Â4 ++
>> >> Âfs/ubifs/file.c  Â|  Â6 ++
>> >> Âfs/ubifs/journal.c | Â 12 +++-
>> >> Âfs/ubifs/super.c  |  Â3 +
>> >> Âfs/ubifs/ubifs.h  |  Â9 +++
>> >> Âfs/ubifs/xattr.c  | Â147 ++++++++++++++++++++++++++++++++++++++++++++++++----
>> >> Â6 files changed, 167 insertions(+), 14 deletions(-)
>> >>
>> >> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
>> >> index ec9f187..f4e06c4 100644
>> >> --- a/fs/ubifs/dir.c
>> >> +++ b/fs/ubifs/dir.c
>> >> @@ -293,6 +293,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
>> >> Â Â Â ubifs_release_budget(c, &req);
>> >> Â Â Â insert_inode_hash(inode);
>> >> Â Â Â d_instantiate(dentry, inode);
>> >> + Â Â ubifs_init_security(dir, inode, &dentry->d_name);
>> >> Â Â Â return 0;
>> >>
>> >> Âout_cancel:
>> >
>> > The ubifs_init_security() should occur before d_instantiate() so that
>> > the inode is not accessible to other threads before its security
>> > attributes have been set. ÂAnd if it fails, you would ideally drop the
>> > inode altogether and return an error to the creating process.
>> >
>>
>> I will look into moving ubifs_init_security() before d_instantiate().
>> Last time I had tried I had run into some issues and had to keep
>> creating inode and then creating xattr as two seperate items. I will
>> look through the UBIFS code that actually creates xattr ubi nodes.
>> Also I will wait for couple of days to send v3 patch with to see if
>> mtd folks have other comments this patch.
>
> I'd favor moving the call to ubifs_init_security() inside of
> ubifs_new_inode() so that it gets done as part of all inode creation.
> To do that, you'll need to pass the &dentry->d_name (const struct qstr
> *) down to ubifs_new_inode(). But you can see that it is done that way
> for ext4_new_inode(), for example.
>
> --

Okay, I will look at that code little bit mode.

UBIFS create_xattr() (fs/ubifs/xattr.c) calls ubifs_new_inode() so it
can get tricky if I want to create xattr in ubifs_new_inode().

Also noticed that UBIFS doesn't d_instantiate() inode entry created to
hold extended attribute, not certain if that would be an issue.

I will look how other fs manage xattrs, I certainly don't want to
modify how UBIFS manages extended attributes.


-Subodh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/