udf: Protect default inode credentials by rwlock
Superblock carries credentials (uid, gid, etc.) which are used as default values in __udf_read_inode() when media does not provide these. These credentials can change during remount so we protect them by a rwlock so that each inode gets a consistent set of credentials. Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
949f4a7c08
commit
c03cad241a
3 changed files with 14 additions and 7 deletions
|
@ -1201,6 +1201,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
|
|||
return;
|
||||
}
|
||||
|
||||
read_lock(&sbi->s_cred_lock);
|
||||
inode->i_uid = le32_to_cpu(fe->uid);
|
||||
if (inode->i_uid == -1 ||
|
||||
UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
|
||||
|
@ -1213,13 +1214,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
|
|||
UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
|
||||
inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
|
||||
|
||||
inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
|
||||
if (!inode->i_nlink)
|
||||
inode->i_nlink = 1;
|
||||
|
||||
inode->i_size = le64_to_cpu(fe->informationLength);
|
||||
iinfo->i_lenExtents = inode->i_size;
|
||||
|
||||
if (fe->icbTag.fileType != ICBTAG_FILE_TYPE_DIRECTORY &&
|
||||
sbi->s_fmode != UDF_INVALID_MODE)
|
||||
inode->i_mode = sbi->s_fmode;
|
||||
|
@ -1229,6 +1223,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
|
|||
else
|
||||
inode->i_mode = udf_convert_permissions(fe);
|
||||
inode->i_mode &= ~sbi->s_umask;
|
||||
read_unlock(&sbi->s_cred_lock);
|
||||
|
||||
inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
|
||||
if (!inode->i_nlink)
|
||||
inode->i_nlink = 1;
|
||||
|
||||
inode->i_size = le64_to_cpu(fe->informationLength);
|
||||
iinfo->i_lenExtents = inode->i_size;
|
||||
|
||||
if (iinfo->i_efe == 0) {
|
||||
inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
|
||||
|
|
|
@ -568,12 +568,14 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
|
|||
return -EINVAL;
|
||||
|
||||
lock_kernel();
|
||||
write_lock(&sbi->s_cred_lock);
|
||||
sbi->s_flags = uopt.flags;
|
||||
sbi->s_uid = uopt.uid;
|
||||
sbi->s_gid = uopt.gid;
|
||||
sbi->s_umask = uopt.umask;
|
||||
sbi->s_fmode = uopt.fmode;
|
||||
sbi->s_dmode = uopt.dmode;
|
||||
write_unlock(&sbi->s_cred_lock);
|
||||
|
||||
if (sbi->s_lvid_bh) {
|
||||
int write_rev = le16_to_cpu(udf_sb_lvidiu(sbi)->minUDFWriteRev);
|
||||
|
@ -1960,6 +1962,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
|
|||
sbi->s_fmode = uopt.fmode;
|
||||
sbi->s_dmode = uopt.dmode;
|
||||
sbi->s_nls_map = uopt.nls_map;
|
||||
rwlock_init(&sbi->s_cred_lock);
|
||||
|
||||
if (uopt.session == 0xFFFFFFFF)
|
||||
sbi->s_session = udf_get_last_session(sb);
|
||||
|
|
|
@ -129,6 +129,8 @@ struct udf_sb_info {
|
|||
uid_t s_uid;
|
||||
mode_t s_fmode;
|
||||
mode_t s_dmode;
|
||||
/* Lock protecting consistency of above permission settings */
|
||||
rwlock_t s_cred_lock;
|
||||
|
||||
/* Root Info */
|
||||
struct timespec s_record_time;
|
||||
|
|
Loading…
Reference in a new issue