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

Merge tag 'ovl-fixes-5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs

Pull overlayfs fixes from Miklos Szeredi:
"Fix two bugs, both of them corner cases not affecting most users"

* tag 'ovl-fixes-5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
ovl: fix IOCB_DIRECT if underlying fs doesn't support direct IO
ovl: fix missing negative dentry check in ovl_rename()

+21 -4
+7 -3
fs/overlayfs/dir.c
··· 1219 1219 goto out_dput; 1220 1220 } 1221 1221 } else { 1222 - if (!d_is_negative(newdentry) && 1223 - (!new_opaque || !ovl_is_whiteout(newdentry))) 1224 - goto out_dput; 1222 + if (!d_is_negative(newdentry)) { 1223 + if (!new_opaque || !ovl_is_whiteout(newdentry)) 1224 + goto out_dput; 1225 + } else { 1226 + if (flags & RENAME_EXCHANGE) 1227 + goto out_dput; 1228 + } 1225 1229 } 1226 1230 1227 1231 if (olddentry == trap)
+14 -1
fs/overlayfs/file.c
··· 296 296 if (ret) 297 297 return ret; 298 298 299 + ret = -EINVAL; 300 + if (iocb->ki_flags & IOCB_DIRECT && 301 + (!real.file->f_mapping->a_ops || 302 + !real.file->f_mapping->a_ops->direct_IO)) 303 + goto out_fdput; 304 + 299 305 old_cred = ovl_override_creds(file_inode(file)->i_sb); 300 306 if (is_sync_kiocb(iocb)) { 301 307 ret = vfs_iter_read(real.file, iter, &iocb->ki_pos, ··· 326 320 out: 327 321 revert_creds(old_cred); 328 322 ovl_file_accessed(file); 329 - 323 + out_fdput: 330 324 fdput(real); 331 325 332 326 return ret; ··· 354 348 ret = ovl_real_fdget(file, &real); 355 349 if (ret) 356 350 goto out_unlock; 351 + 352 + ret = -EINVAL; 353 + if (iocb->ki_flags & IOCB_DIRECT && 354 + (!real.file->f_mapping->a_ops || 355 + !real.file->f_mapping->a_ops->direct_IO)) 356 + goto out_fdput; 357 357 358 358 if (!ovl_should_sync(OVL_FS(inode->i_sb))) 359 359 ifl &= ~(IOCB_DSYNC | IOCB_SYNC); ··· 396 384 } 397 385 out: 398 386 revert_creds(old_cred); 387 + out_fdput: 399 388 fdput(real); 400 389 401 390 out_unlock: