linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: snijsure@grid-net.com
Cc: mtd <linux-mtd@lists.infradead.org>
Subject: Re: Setting security XATTR on ubifs
Date: Mon, 23 May 2011 17:57:57 +0300	[thread overview]
Message-ID: <1306162677.2785.30.camel@localhost> (raw)
In-Reply-To: <1305934601.10340.12.camel@subodh-desktop>

Hi,

no time now, so very quick answer.

On Fri, 2011-05-20 at 16:36 -0700, Subodh Nijsure wrote:
> we have implemented modifications to UBIFS to add support for SELinux
> labeling. Function that created this XATTR is called
> ubifs_init_security(), shown below.

OK, sounds cool.

> Following example of how JFFS2 does extended attribute labeling, This
> function is being called from 
> ubifs_create(),ubifs_mkdir(), ubifs_mknod(), ubifs_symlink() (in
> fs/ubifs/dir.c)

OK.

> With this modification things work "mostly", I am able to label the file
> system, but sometimes the file system is getting corrupted. I will
> certainly post the patch once things work reliably. 

Hmm... Running tests with all UBIFS extra self-checks turned on is a
good idea, BTW.

> I don't _fully_ understand how ubifs is doing space management, hence
> the immediate questions I have are:

Well, the main complication is budgeting: before doing any I/O you need
to get space budget, which is basically about asking the budgeting
subsystem to reserve certain amount of space for your operation. When
you are done - you release the budget.

> 1. What is the right point to add the XATTR to the UBIFS inode, after
> the ubifs_new_inode() is done?

I guess right after that? But keep in mind that unclean reboots may
result in losing selinux attributes. E.g., you create a new inode for
file XXX and this succeeds, then you start creating the selinux labels
and you have a power cut. When you mount the FS again you'll find out
that XXX does not have any selinux labels.

I do not know selinux well enough so do not know how this is handled:
does selinux handle it from user-space somehow or it assumes that
file/dir/symlink + selinux lables creation is atomic?

>  Should ubifs_budget_space() be updated to
> handle extra space needed by the XATTR.

In _your_ implementation no - ubifs_init_security() calls
'ubifs_setxattr()' which calls 'create_xattr()' which gets the budget.

I mean, in your implementation creating inode and creating selinux
xattrs are 2 separate operations and you use existing "big" building
blocks for this which do the budgeting.

> 2. In function below ui_mutex is being locked/unlocked while XATTR for
> the file is updated. Is that required while updating the extended
> attribute?

You'd deadlock if you did this I think, because 'create_xattr()' takes
the mutex (it is called "host_ui->ui_mutex" there).

HTH.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

  reply	other threads:[~2011-05-23 15:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 23:36 Setting security XATTR on ubifs Subodh Nijsure
2011-05-23 14:57 ` Artem Bityutskiy [this message]
     [not found]   ` <C7A5B00EFC707A46AB67997D02152167010F582C@mx1.grid-net.com>
2011-05-30  9:12     ` Artem Bityutskiy
2011-06-07 11:07       ` Artem Bityutskiy

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=1306162677.2785.30.camel@localhost \
    --to=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=snijsure@grid-net.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).