@@ -127,6 +127,7 @@ xfs_dir2_sf_getdents(
*/
sfep = xfs_dir2_sf_firstentry(sfp);
for (i = 0; i < sfp->count; i++) {
+ char name[sfep->namelen];
__uint8_t filetype;
off = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
@@ -140,7 +141,14 @@ xfs_dir2_sf_getdents(
ino = dp->d_ops->sf_get_ino(sfp, sfep);
filetype = dp->d_ops->sf_get_ftype(sfep);
ctx->pos = off & 0x7fffffff;
- if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
+ /*
+ * Short form directories have the file name stored in
+ * memory that is not directly accessible to copy_to_user.
+ * Bounce buffer the name, instead of potentially making
+ * the other data accessible.
+ */
+ memcpy(name, sfep->name, sfep->namelen);
+ if (!dir_emit(ctx, name, sfep->namelen, ino,
xfs_dir3_get_dtype(dp->i_mount, filetype)))
return 0;
sfep = dp->d_ops->sf_nextentry(sfp, sfep);