All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>, dedekind1@gmail.com
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH v2] ubifs: make ubifs_[get|set]xattr atomic
Date: Sat, 8 Aug 2015 22:34:03 +0200	[thread overview]
Message-ID: <55C667BB.2040204@nod.at> (raw)
In-Reply-To: <55C444EA.7090305@cn.fujitsu.com>

Am 07.08.2015 um 07:40 schrieb Dongsheng Yang:
> On 08/04/2015 04:27 AM, Richard Weinberger wrote:
>> Am 31.07.2015 um 03:12 schrieb Dongsheng Yang:
>>> This commit make the ubifs_[get|set]xattr protected by ui_mutex.
>>>
>>> Originally, there is a possibility that ubifs_getxattr to get
>>> a wrong value.
>>>
>>>      P1                    P2
>>> ----------            ----------
>>> ubifs_getxattr            ubifs_setxattr
>>>                    - kfree()
>>>     - memcpy()
>>>                    - kmemdup()
>>>
>>> Then ubifs_getxattr() would get a non-sense data. To solve this
>>> problem, this commit make the xattr of ubifs_inode updated in
>>> atomic.
>>
>> so, ui->data needs protection?
>> The comment in fs/ubifs/ubifs.h does not mention ->data.
>> I'm asking because I want to make sure that ui_mutex is the correct lock to take.
> 
> ui->data needs protection for sure, as I show above.
> Without protection, there is a problem to get wrong value.
> 
> And yes, the comment does not mention the ->data. But
> I think ui_mutex is a good choice for it. And not all fields
> which is being protected by ui_mutex are listed in the comment,
> such as xattr_names and xattr_cnt.

Yeah. ;-\
The comment needs an update. In UBI and UBIFS we try hard to document our locking.
Will you do a patch or shall I?

Thanks,
//richard

      parent reply	other threads:[~2015-08-08 20:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30  5:37 [PATCH] ubifs: make ubifs_[get|set]xattr atomic Dongsheng Yang
2015-07-30  8:05 ` Richard Weinberger
2015-07-31  0:04   ` Dongsheng Yang
2015-07-31  1:12     ` [PATCH v2] " Dongsheng Yang
2015-08-03 20:27       ` Richard Weinberger
2015-08-07  5:40         ` Dongsheng Yang
2015-08-07  6:07           ` [PATCH v3] " Dongsheng Yang
2015-08-10  8:05             ` Artem Bityutskiy
2015-08-11  3:32               ` Dongsheng Yang
2015-08-11 12:46                 ` Artem Bityutskiy
2015-08-12  2:37                   ` Dongsheng Yang
2015-08-11 12:57             ` Artem Bityutskiy
2015-08-12  2:37               ` Dongsheng Yang
2015-08-08 20:34           ` Richard Weinberger [this message]

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=55C667BB.2040204@nod.at \
    --to=richard@nod.at \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=yangds.fnst@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.