Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xfs: don't validate error tags in the I/O path

We can trust XFS developers enough to not pass random stuff to
XFS_ERROR_TEST/DELAY. Open code the validity check in xfs_errortag_add,
which is the only place that receives unvalidated error tag values from
user space, and drop the now pointless xfs_errortag_enabled helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

authored by

Christoph Hellwig and committed by
Carlos Maiolino
b8862a09 394969e2

+12 -30
+1 -1
fs/xfs/libxfs/xfs_errortag.h
··· 53 53 * Drop-writes support removed because write error handling cannot trash 54 54 * pre-existing delalloc extents in any useful way anymore. We retain the 55 55 * definition so that we can reject it as an invalid value in 56 - * xfs_errortag_valid(). 56 + * xfs_errortag_add(). 57 57 */ 58 58 #define XFS_ERRTAG_DROP_WRITES 28 59 59 #define XFS_ERRTAG_LOG_BAD_CRC 29
+10 -28
fs/xfs/xfs_error.c
··· 125 125 xfs_sysfs_del(&mp->m_errortag_kobj); 126 126 } 127 127 128 - static bool 129 - xfs_errortag_valid( 130 - unsigned int error_tag) 131 - { 132 - if (error_tag >= XFS_ERRTAG_MAX) 133 - return false; 134 - 135 - /* Error out removed injection types */ 136 - if (error_tag == XFS_ERRTAG_DROP_WRITES) 137 - return false; 138 - return true; 139 - } 140 - 141 - bool 142 - xfs_errortag_enabled( 143 - struct xfs_mount *mp, 144 - unsigned int tag) 145 - { 146 - if (!xfs_errortag_valid(tag)) 147 - return false; 148 - 149 - return mp->m_errortag[tag] != 0; 150 - } 151 - 152 128 bool 153 129 xfs_errortag_test( 154 130 struct xfs_mount *mp, ··· 133 157 unsigned int error_tag) 134 158 { 135 159 unsigned int randfactor; 136 - 137 - if (!xfs_errortag_valid(error_tag)) 138 - return false; 139 160 140 161 randfactor = mp->m_errortag[error_tag]; 141 162 if (!randfactor || get_random_u32_below(randfactor)) ··· 151 178 { 152 179 BUILD_BUG_ON(ARRAY_SIZE(xfs_errortag_random_default) != XFS_ERRTAG_MAX); 153 180 154 - if (!xfs_errortag_valid(error_tag)) 181 + if (error_tag >= XFS_ERRTAG_MAX) 155 182 return -EINVAL; 183 + 184 + /* Error out removed injection types */ 185 + switch (error_tag) { 186 + case XFS_ERRTAG_DROP_WRITES: 187 + return -EINVAL; 188 + default: 189 + break; 190 + } 191 + 156 192 mp->m_errortag[error_tag] = xfs_errortag_random_default[error_tag]; 157 193 return 0; 158 194 }
+1 -1
fs/xfs/xfs_error.h
··· 44 44 #define XFS_ERRORTAG_DELAY(mp, tag) \ 45 45 do { \ 46 46 might_sleep(); \ 47 - if (!xfs_errortag_enabled((mp), (tag))) \ 47 + if (!mp->m_errortag[tag]) \ 48 48 break; \ 49 49 xfs_warn_ratelimited((mp), \ 50 50 "Injecting %ums delay at file %s, line %d, on filesystem \"%s\"", \