mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-mtd@lists.infradead.org
Cc: kernel@pengutronix.de, artem.bityutskiy@linux.intel.com,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH RFC 1/5] UBIFS: xattr: protect ui_size and data_len by ui_mutex
Date: Wed, 13 Feb 2013 11:23:14 +0100	[thread overview]
Message-ID: <1360750998-15191-2-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1360750998-15191-1-git-send-email-mkl@pengutronix.de>

This patch moves the modification of ui->ui_size and ui->data_len in the
create_xattr() and change_xattr() functions, so that they are protected by the
ui_mutex as stated in the documenation of the the struct ubifs_inode.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 fs/ubifs/xattr.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 0f7139b..1395307 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -143,10 +143,10 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 		err = -ENOMEM;
 		goto out_free;
 	}
-	inode->i_size = ui->ui_size = size;
-	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
+	inode->i_size = ui->ui_size = size;
+	ui->data_len = size;
 	host->i_ctime = ubifs_current_time(host);
 	host_ui->xattr_cnt += 1;
 	host_ui->xattr_size += CALC_DENT_SIZE(nm->len);
@@ -208,10 +208,10 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
 		err = -ENOMEM;
 		goto out_free;
 	}
-	inode->i_size = ui->ui_size = size;
-	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
+	inode->i_size = ui->ui_size = size;
+	ui->data_len = size;
 	host->i_ctime = ubifs_current_time(host);
 	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
 	host_ui->xattr_size += CALC_XATTR_BYTES(size);
-- 
1.7.10.4


  reply	other threads:[~2013-02-13 10:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 10:23 [RFC PATCH 0/5] UBIFS: improve xattr and add support for security.* XATTR Marc Kleine-Budde
2013-02-13 10:23 ` Marc Kleine-Budde [this message]
2013-02-14  7:23   ` [PATCH RFC 1/5] UBIFS: xattr: protect ui_size and data_len by ui_mutex Artem Bityutskiy
2013-02-14 11:57     ` Marc Kleine-Budde
2013-02-13 10:23 ` [PATCH RFC 2/5] UBIFS: fix couple bugs in UBIFS extended attribute length calculation Marc Kleine-Budde
2013-02-13 10:23 ` [PATCH RFC 3/5] UBIFS: Add xattr support for symlinks Marc Kleine-Budde
2013-02-13 10:23 ` [PATCH RFC 4/5] UBIFS: Add security.* XATTR support for the UBIFS Marc Kleine-Budde
2013-02-14  7:28   ` Artem Bityutskiy
2013-02-14 12:05     ` Marc Kleine-Budde
2013-02-22  7:10   ` Artem Bityutskiy
2013-02-13 10:23 ` [PATCH RFC 5/5] UBIFS: add ubifs_err() to print error reason Marc Kleine-Budde
2013-02-14  7:29   ` 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=1360750998-15191-2-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-security-module@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®