diff options
author | Jan Kara <jack@suse.cz> | 2017-06-09 12:56:06 +0300 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2017-08-17 23:00:04 +0300 |
commit | 15512377bd971ecc86f2eab40b841b265b5043de (patch) | |
tree | e11553b59233f1e4b836061ec2a39a3610cb1d61 /fs/quota/quota_v1.c | |
parent | f98bbe37ae96873ce93f36f4cdc7b47d85cc4455 (diff) | |
download | linux-15512377bd971ecc86f2eab40b841b265b5043de.tar.xz |
quota: Fix possible corruption of dqi_flags
dqi_flags modifications are protected by dq_data_lock. However the
modifications in vfs_load_quota_inode() and in mark_info_dirty() were
not which could lead to corruption of dqi_flags. Since modifications to
dqi_flags are rare, this is hard to observe in practice but in theory it
could happen. Fix the problem by always using dq_data_lock for
protection.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/quota_v1.c')
-rw-r--r-- | fs/quota/quota_v1.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c index b2d8e04e567a..7ac5298aba70 100644 --- a/fs/quota/quota_v1.c +++ b/fs/quota/quota_v1.c @@ -189,7 +189,6 @@ static int v1_write_file_info(struct super_block *sb, int type) int ret; down_write(&dqopt->dqio_sem); - dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY; ret = sb->s_op->quota_read(sb, type, (char *)&dqblk, sizeof(struct v1_disk_dqblk), v1_dqoff(0)); if (ret != sizeof(struct v1_disk_dqblk)) { @@ -197,8 +196,11 @@ static int v1_write_file_info(struct super_block *sb, int type) ret = -EIO; goto out; } + spin_lock(&dq_data_lock); + dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY; dqblk.dqb_itime = dqopt->info[type].dqi_igrace; dqblk.dqb_btime = dqopt->info[type].dqi_bgrace; + spin_unlock(&dq_data_lock); ret = sb->s_op->quota_write(sb, type, (char *)&dqblk, sizeof(struct v1_disk_dqblk), v1_dqoff(0)); if (ret == sizeof(struct v1_disk_dqblk)) |