mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
readdir: require opt-in for d_type flags
Commitc31f91c6af("fuse: don't allow signals to interrupt getdents copying") introduced the use of high bits in d_type as flags. However, overlayfs was not adapted to handle this change. In ovl_cache_entry_new(), the code checks if d_type == DT_CHR to determine if an entry might be a whiteout. When fuse is used as the lower layer and sets high bits in d_type, this comparison fails, causing whiteout files to not be recognized properly and resulting in incorrect overlayfs behavior. Fix this by requiring callers of iterate_dir() to opt-in for getting flag bits in d_type outside of S_DT_MASK. Fixes:c31f91c6af("fuse: don't allow signals to interrupt getdents copying") Link: https://lore.kernel.org/all/20260107034551.439-1-luochunsheng@ustc.edu/ Link: https://github.com/containerd/stargz-snapshotter/issues/2214 Reported-by: Chunsheng Luo <luochunsheng@ustc.edu> Reviewed-by: Chunsheng Luo <luochunsheng@ustc.edu> Tested-by: Chunsheng Luo <luochunsheng@ustc.edu> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://patch.msgid.link/20260108074522.3400998-1-amir73il@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
7d42f2b1cc
commit
c644bce62b
@@ -316,6 +316,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
|
|||||||
struct getdents_callback buf = {
|
struct getdents_callback buf = {
|
||||||
.ctx.actor = filldir,
|
.ctx.actor = filldir,
|
||||||
.ctx.count = count,
|
.ctx.count = count,
|
||||||
|
.ctx.dt_flags_mask = FILLDIR_FLAG_NOINTR,
|
||||||
.current_dir = dirent
|
.current_dir = dirent
|
||||||
};
|
};
|
||||||
int error;
|
int error;
|
||||||
@@ -400,6 +401,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
|
|||||||
struct getdents_callback64 buf = {
|
struct getdents_callback64 buf = {
|
||||||
.ctx.actor = filldir64,
|
.ctx.actor = filldir64,
|
||||||
.ctx.count = count,
|
.ctx.count = count,
|
||||||
|
.ctx.dt_flags_mask = FILLDIR_FLAG_NOINTR,
|
||||||
.current_dir = dirent
|
.current_dir = dirent
|
||||||
};
|
};
|
||||||
int error;
|
int error;
|
||||||
@@ -569,6 +571,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
|
|||||||
struct compat_getdents_callback buf = {
|
struct compat_getdents_callback buf = {
|
||||||
.ctx.actor = compat_filldir,
|
.ctx.actor = compat_filldir,
|
||||||
.ctx.count = count,
|
.ctx.count = count,
|
||||||
|
.ctx.dt_flags_mask = FILLDIR_FLAG_NOINTR,
|
||||||
.current_dir = dirent,
|
.current_dir = dirent,
|
||||||
};
|
};
|
||||||
int error;
|
int error;
|
||||||
|
|||||||
@@ -1855,6 +1855,8 @@ struct dir_context {
|
|||||||
* INT_MAX unlimited
|
* INT_MAX unlimited
|
||||||
*/
|
*/
|
||||||
int count;
|
int count;
|
||||||
|
/* @actor supports these flags in d_type high bits */
|
||||||
|
unsigned int dt_flags_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* If OR-ed with d_type, pending signals are not checked */
|
/* If OR-ed with d_type, pending signals are not checked */
|
||||||
@@ -3524,7 +3526,9 @@ static inline bool dir_emit(struct dir_context *ctx,
|
|||||||
const char *name, int namelen,
|
const char *name, int namelen,
|
||||||
u64 ino, unsigned type)
|
u64 ino, unsigned type)
|
||||||
{
|
{
|
||||||
return ctx->actor(ctx, name, namelen, ctx->pos, ino, type);
|
unsigned int dt_mask = S_DT_MASK | ctx->dt_flags_mask;
|
||||||
|
|
||||||
|
return ctx->actor(ctx, name, namelen, ctx->pos, ino, type & dt_mask);
|
||||||
}
|
}
|
||||||
static inline bool dir_emit_dot(struct file *file, struct dir_context *ctx)
|
static inline bool dir_emit_dot(struct file *file, struct dir_context *ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user