From: Chao Yu <yuchao0@huawei.com>
To: Joe Perches <joe@perches.com>, Chao Yu <chao@kernel.org>,
<jaegeuk@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] f2fs: fix potential .flags overflow on 32bit architecture
Date: Mon, 23 Mar 2020 09:07:04 +0800 [thread overview]
Message-ID: <c5b8115e-509d-9ace-ed4d-87bc2484d834@huawei.com> (raw)
In-Reply-To: <d88cce8ff37f336087899226668abcbcacd96baa.camel@perches.com>
On 2020/3/22 22:56, Joe Perches wrote:
> On Sun, 2020-03-22 at 21:56 +0800, Chao Yu wrote:
>> From: Chao Yu <yuchao0@huawei.com>
>>
>> f2fs_inode_info.flags is unsigned long variable, it has 32 bits
>> in 32bit architecture, since we introduced FI_MMAP_FILE flag
>> when we support data compression, we may access memory cross
>> the border of .flags field, corrupting .i_sem field, result in
>> below deadlock.
>>
>> To fix this issue, let's expand .flags as an array to grab enough
>> space to store new flags.
> []
>> +static inline void __set_inode_flag(struct inode *inode, int flag)
>> +{
>> + if (!test_bit(flag % BITS_PER_LONG,
>> + &F2FS_I(inode)->flags[BIT_WORD(flag)]))
>> + set_bit(flag % BITS_PER_LONG,
>> + &F2FS_I(inode)->flags[BIT_WORD(flag)]);
>> +}
>
> I believe you don't need to do anything like this
> but just let test_bit and set_bit do the indexing.
>
> if (!test_bit(flg, F2FS_I(inode->flags)))
> set_bit(flag, F2FS_I(inode->flags));
>
> And there already is a function called test_and_set_bit()
Yup, I've cleaned up with test_and_{set,clear}_bit(), thanks for your
reminder.
Thanks,
>
>
> .
>
prev parent reply other threads:[~2020-03-23 1:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-22 13:56 [PATCH v2] f2fs: fix potential .flags overflow on 32bit architecture Chao Yu
2020-03-22 14:56 ` Joe Perches
2020-03-23 1:07 ` Chao Yu [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=c5b8115e-509d-9ace-ed4d-87bc2484d834@huawei.com \
--to=yuchao0@huawei.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=joe@perches.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).