]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: sanity check inode mode when creating new dentry
authorAmir Goldstein <amir73il@gmail.com>
Tue, 17 Jan 2017 19:41:44 +0000 (11:41 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 17 Jan 2017 19:42:22 +0000 (11:42 -0800)
commit2de04439961a9fa02ac7a90d74ea4792de5b25d0
treed34fab3b0f9f5793aa599e8f7a63399fadbbc129
parent34583efdce2b68df1a398d7a0775fdbb7c6a1248
xfs: sanity check inode mode when creating new dentry

The helper xfs_dentry_to_name() is used by 2 different
classes of callers: Callers that pass zero mode and don't care
about the returned name.type field and Callers that pass
non zero mode and do care about the name.type field.

Change xfs_dentry_to_name() to not take the mode argument and
change the call sites of the first class to not pass the mode
argument.

Create a new helper xfs_dentry_mode_to_name() which does pass
the mode argument and returns -EFSCORRUPTED if mode is invalid.
Callers that translate non zero mode to on-disk file type now
check the return value and will export the error to user instead
of staging an invalid file type to be written to directory entry.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_iops.c