FAILED: patch "[PATCH] ovl: do not copy up an xattr value that was never read" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 755b5c5c9277be251a51623d6065abab948c61bc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110419-skeptic-dictation-d90e@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 755b5c5c9277be251a51623d6065abab948c61bc Mon Sep 17 00:00:00 2001
From: Chris Mason <[email protected]>
Date: Wed, 7 Oct 2026 09:45:28 +0000
Subject: [PATCH] ovl: do not copy up an xattr value that was never read
Copy-up stores uninitialized kernel memory in an xattr of the upper file, where the user can read it.
ovl_copy_xattr() may only pass bytes to ovl_do_setxattr() that ovl_do_getxattr() has read. When the read fails with -ERANGE the function asks for the size again, and if the new size fits the buffer it stores the buffer although nothing was read into it. The buffer comes from kvmalloc(), or it still holds the value of the previous xattr.
A FUSE lower layer that answers every sized GETXATTR with -ERANGE made copy-up store 4096 bytes that the server never sent, with a kernel pointer in them, as an xattr of the upper file.
Fix this by failing the copy-up with -EIO when the size that follows -ERANGE fits the buffer.
fs/overlayfs/copy_up.c +5 -1
@@ -131,8 +131,12 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de retry: size =ovl_do_getxattr (oldpath, name, value, value_size); -if (size == -ERANGE ) +if (size == -ERANGE ) { size =ovl_do_getxattr (oldpath, name,NULL ,0 ); +/* Nothing was read into value, so it must not be used */ +if (size >=0 && size <= value_size) + size = -EIO ; + }if (size <0 ) { error = size;
Sasha Levin
maintainerPATCH 1/4 ovl: add ovl_upper_mnt_userns() wrapper
From: Christian Brauner <[email protected]>
[ Upstream commit b65c20acef23cea2989c9f23414930149d38962f ]
Add a tiny wrapper to retrieve the upper mount's idmapping. Have it return the initial idmapping until we have prepared and converted all places to take the relevant idmapping into account. Then we can switch on idmapped layer support by having ovl_upper_mnt_userns() return the upper mount's idmapping.
Stable-dep-of: 755b5c5c9277 ("ovl: do not copy up an xattr value that was never read")
--- fs/overlayfs/ovl_entry.h | 5 +++++ 1 file changed, 5 insertions(+)
fs/overlayfs/ovl_entry.h +5 -0
@@ -99,6 +99,11 @@ static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)return ofs->layers[0 ].mnt; } +static inline struct user_namespace *ovl_upper_mnt_userns (struct ovl_fs *ofs) +{ +return &init_user_ns; +} +static inline struct ovl_fs *OVL_FS (struct super_block *sb) {return (struct ovl_fs *)sb->s_fs_info;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 ovl: pass ofs to setattr operations
From: Christian Brauner <[email protected]>
[ Upstream commit 5272eaf3a5682750f6f26ec542b206f0821fb3cb ]
Pass down struct ovl_fs to setattr operations so we can ultimately retrieve the relevant upper mount and take the mount's idmapping into account when creating new filesystem objects. This is needed to support idmapped base layers with overlay.
Stable-dep-of: 755b5c5c9277 ("ovl: do not copy up an xattr value that was never read")
--- fs/overlayfs/copy_up.c | 19 +++++++++++-------- fs/overlayfs/dir.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-)
fs/overlayfs/copy_up.c +11 -8
@@ -292,7 +292,8 @@ static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old,return error; } -static int ovl_set_size (struct dentry *upperdentry,struct kstat *stat) +static int ovl_set_size (struct ovl_fs *ofs, +struct dentry *upperdentry,struct kstat *stat) {struct iattr attr = { .ia_valid =ATTR_SIZE ,
@@ -302,7 +303,8 @@ static int ovl_set_size(struct dentry *upperdentry, struct kstat *stat)return notify_change (&init_user_ns, upperdentry, &attr,NULL ); } -static int ovl_set_timestamps(struct dentry *upperdentry, struct kstat *stat) +static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry, + struct kstat *stat) { struct iattr attr = { .ia_valid =
@@ -314,7 +316,8 @@ static int ovl_set_timestamps(struct dentry *upperdentry, struct kstat *stat)return notify_change (&init_user_ns, upperdentry, &attr,NULL ); } -int ovl_set_attr (struct dentry *upperdentry,struct kstat *stat) +int ovl_set_attr (struct ovl_fs *ofs,struct dentry *upperdentry, +struct kstat *stat) {int err =0 ;
@@ -334,7 +337,7 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat) err =notify_change (&init_user_ns, upperdentry, &attr,NULL ); }if (!err) -ovl_set_timestamps (upperdentry, stat); +ovl_set_timestamps (ofs, upperdentry, stat);return err; }
@@ -540,7 +543,7 @@ static int ovl_link_up(struct ovl_copy_up_ctx *c)if (!err) {/* Restore timestamps on parent (best effort) */ -ovl_set_timestamps (upperdir, &c->pstat); +ovl_set_timestamps (ofs, upperdir, &c->pstat);ovl_dentry_set_upper_alias (c->dentry);ovl_dentry_update_reval (c->dentry, upper); }
@@ -617,9 +620,9 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)inode_lock (temp->d_inode);if (S_ISREG (c->stat.mode)) - err =ovl_set_size (temp, &c->stat); + err =ovl_set_size (ofs, temp, &c->stat);if (!err) - err =ovl_set_attr (temp, &c->stat); + err =ovl_set_attr (ofs, temp, &c->stat);inode_unlock (temp->d_inode);return err;
@@ -847,7 +850,7 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)/* Restore timestamps on parent (best effort) */ inode_lock (udir); -ovl_set_timestamps (c->destdir, &c->pstat); +ovl_set_timestamps (ofs, c->destdir, &c->pstat);inode_unlock (udir);ovl_dentry_set_upper_alias (c->dentry);
fs/overlayfs/dir.c +1 -1
@@ -407,7 +407,7 @@ static struct dentry *ovl_clear_empty(struct dentry *dentry, goto out_cleanup;inode_lock (opaquedir->d_inode); - err =ovl_set_attr (opaquedir, &stat); + err =ovl_set_attr (ofs, opaquedir, &stat);inode_unlock (opaquedir->d_inode);if (err) goto out_cleanup;
fs/overlayfs/overlayfs.h +1 -1
@@ -618,7 +618,7 @@ int ovl_copy_up_with_data(struct dentry *dentry);int ovl_maybe_copy_up (struct dentry *dentry,int flags);int ovl_copy_xattr (struct super_block *sb,struct dentry *old,struct dentry *new); -int ovl_set_attr (struct dentry *upper,struct kstat *stat); +int ovl_set_attr (struct ovl_fs *ofs,struct dentry *upper,struct kstat *stat);struct ovl_fh *ovl_encode_real_fh (struct ovl_fs *ofs,struct dentry *real,bool is_upper); int ovl_set_origin(struct ovl_fs *ofs, struct dentry *lower,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 ovl: use ovl_path_getxattr() wrapper
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit dad7017a840d8d198074338224cd418d37b8f79d ]
Add a helper that allows to retrieve ovl xattrs from either lower or upper layers. To stop passing mnt and dentry separately everywhere use struct path which more accurately reflects the tight coupling between mount and dentry in this helper. Swich over all places to pass a path argument that can operate on either upper or lower layers. This is needed to support idmapped base layers with overlayfs.
Some helpers are always called with an upper dentry, which is now utilized by these helpers to create the path. Make this usage explicit by renaming the argument to "upperdentry" and by renaming the function as well in some cases. Also add a check in ovl_do_getxattr() to catch misuse of these functions.
Stable-dep-of: 755b5c5c9277 ("ovl: do not copy up an xattr value that was never read")
--- fs/overlayfs/copy_up.c | 21 ++++++----- fs/overlayfs/dir.c | 2 +- fs/overlayfs/inode.c | 10 ++++-- fs/overlayfs/namei.c | 37 ++++++++++++------- fs/overlayfs/overlayfs.h | 77 ++++++++++++++++++++++++++++------------ fs/overlayfs/util.c | 29 ++++++++------- 6 files changed, 111 insertions(+), 65 deletions(-)
fs/overlayfs/copy_up.c +10 -11
@@ -44,9 +44,9 @@ static bool ovl_must_copy_xattr(const char *name) !strncmp (name,XATTR_SECURITY_PREFIX ,XATTR_SECURITY_PREFIX_LEN ); } -int ovl_copy_xattr (struct super_block *sb,struct dentry *old, -struct dentry *new) +int ovl_copy_xattr (struct super_block *sb,struct path *oldpath,struct dentry *new) { +struct dentry *old = oldpath->dentry;ssize_t list_size, size, value_size =0 ;char *buf, *name, *value =NULL ;int error =0 ;
@@ -94,9 +94,9 @@ int ovl_copy_xattr(struct super_block *sb, struct dentry *old,continue ;/* Discard */ } retry: - size =vfs_getxattr (&init_user_ns, old, name, value, value_size); + size =ovl_do_getxattr (oldpath, name, value, value_size);if (size == -ERANGE ) - size =vfs_getxattr (&init_user_ns, old, name,NULL ,0 ); + size =ovl_do_getxattr (oldpath, name,NULL ,0 );if (size <0 ) { error = size;
@@ -583,7 +583,7 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)return err; } - err =ovl_copy_xattr (c->dentry->d_sb, c->lowerpath.dentry, temp); + err =ovl_copy_xattr (c->dentry->d_sb, &c->lowerpath, temp);if (err)return err;
@@ -880,13 +880,12 @@ static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,return true; } -static ssize_t ovl_getxattr_value (struct ovl_fs *ofs,struct dentry *dentry, -char *name,char **value) +static ssize_t ovl_getxattr_value (struct path *path,char *name,char **value) {ssize_t res;char *buf; - res =ovl_do_getxattr (ofs, dentry, name,NULL ,0 ); + res =ovl_do_getxattr (path, name,NULL ,0 );if (res == -ENODATA || res == -EOPNOTSUPP ) res =0 ;
@@ -895,7 +894,7 @@ static ssize_t ovl_getxattr_value(struct ovl_fs *ofs, struct dentry *dentry,if (!buf)return -ENOMEM ; - res =ovl_do_getxattr (ofs, dentry, name, buf, res); + res =ovl_do_getxattr (path, name, buf, res);if (res <0 )kfree (buf);else
@@ -922,8 +921,8 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)return -EIO ;if (c->stat.size) { - err = cap_size =ovl_getxattr_value (ofs, upperpath.dentry, -XATTR_NAME_CAPS , &capability); + err = cap_size =ovl_getxattr_value (&upperpath,XATTR_NAME_CAPS , + &capability);if (cap_size <0 ) goto out; }
fs/overlayfs/dir.c +1 -1
@@ -398,7 +398,7 @@ static struct dentry *ovl_clear_empty(struct dentry *dentry,if (IS_ERR (opaquedir)) goto out_unlock; - err =ovl_copy_xattr (dentry->d_sb, upper, opaquedir); + err =ovl_copy_xattr (dentry->d_sb, &upperpath, opaquedir);if (err) goto out_cleanup;
fs/overlayfs/inode.c +7 -3
@@ -922,8 +922,8 @@ unsigned int ovl_get_nlink(struct ovl_fs *ofs, struct dentry *lowerdentry,if (!indexed &&d_inode (lowerdentry)->i_nlink ==1 )return fallback; - err =ovl_getxattr (ofs, upperdentry,OVL_XATTR_NLINK , - &buf,sizeof (buf) -1 ); + err =ovl_getxattr_upper (ofs, upperdentry,OVL_XATTR_NLINK , + &buf,sizeof (buf) -1 );if (err <0 ) goto fail;
@@ -1127,6 +1127,10 @@ struct inode *ovl_get_inode(struct super_block *sb,struct inode *realinode = upperdentry ?d_inode (upperdentry) :NULL ;struct inode *inode;struct dentry *lowerdentry = lowerpath ? lowerpath->dentry :NULL ; +struct path realpath = { + .dentry = upperdentry ?: lowerdentry, + .mnt = upperdentry ?ovl_upper_mnt (ofs) : lowerpath->layer->mnt, + };bool bylower =ovl_hash_bylower (sb, upperdentry, lowerdentry, oip->index);int fsid = bylower ? lowerpath->layer->fsid :0 ;
@@ -1200,7 +1204,7 @@ struct inode *ovl_get_inode(struct super_block *sb,/* Check for non-merge dir that may have whiteouts */ if (is_dir) {if (((upperdentry && lowerdentry) || oip->numlower >1 ) || -ovl_check_origin_xattr (ofs, upperdentry ?: lowerdentry)) { +ovl_path_check_origin_xattr (ofs, &realpath)) {ovl_set_flag (OVL_WHITEOUTS , inode); } }
fs/overlayfs/namei.c +24 -13
@@ -16,6 +16,7 @@struct ovl_lookup_data {struct super_block *sb; +struct vfsmount *mnt;struct qstr name;bool is_dir;bool opaque;
@@ -25,14 +26,14 @@ struct ovl_lookup_data {bool metacopy; }; -static int ovl_check_redirect (struct dentry *dentry,struct ovl_lookup_data *d, +static int ovl_check_redirect (struct path *path,struct ovl_lookup_data *d,size_t prelen,const char *post) {int res;char *buf;struct ovl_fs *ofs =OVL_FS (d->sb); - buf =ovl_get_redirect_xattr (ofs, dentry, prelen +strlen (post)); + buf =ovl_get_redirect_xattr (ofs, path, prelen +strlen (post));if (IS_ERR_OR_NULL (buf))return PTR_ERR (buf);
@@ -105,13 +106,13 @@ int ovl_check_fb_len(struct ovl_fb *fb, int fb_len)return 0 ; } -static struct ovl_fh *ovl_get_fh (struct ovl_fs *ofs,struct dentry *dentry, +static struct ovl_fh *ovl_get_fh (struct ovl_fs *ofs,struct dentry *upperdentry,enum ovl_xattr ox) {int res, err;struct ovl_fh *fh =NULL ; - res =ovl_getxattr (ofs, dentry, ox,NULL ,0 ); + res =ovl_getxattr_upper (ofs, upperdentry, ox,NULL ,0 );if (res <0 ) {if (res == -ENODATA || res == -EOPNOTSUPP )return NULL ;
@@ -125,7 +126,7 @@ static struct ovl_fh *ovl_get_fh(struct ovl_fs *ofs, struct dentry *dentry,if (!fh)return ERR_PTR (-ENOMEM ); - res =ovl_getxattr (ofs, dentry, ox, fh->buf, res); + res =ovl_getxattr_upper (ofs, upperdentry, ox, fh->buf, res);if (res <0 ) goto fail;
@@ -193,9 +194,9 @@ struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh,return real; } -static bool ovl_is_opaquedir (struct super_block *sb,struct dentry *dentry) +static bool ovl_is_opaquedir (struct ovl_fs *ofs,struct path *path) { -return ovl_check_dir_xattr (sb, dentry,OVL_XATTR_OPAQUE ); +return ovl_path_check_dir_xattr (ofs, path,OVL_XATTR_OPAQUE ); } static struct dentry *ovl_lookup_positive_unlocked(const char *name,
@@ -224,6 +225,7 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, struct dentry **ret, bool drop_negative) {struct dentry *this; +struct path path;int err;bool last_element = !post[0 ];
@@ -253,12 +255,15 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, d->stop = true; goto put_and_out; } + + path.dentry = this; + path.mnt = d->mnt;if (!d_can_lookup (this)) {if (d->is_dir || !last_element) { d->stop = true; goto put_and_out; } - err =ovl_check_metacopy_xattr (OVL_FS (d->sb), this); + err =ovl_check_metacopy_xattr (OVL_FS (d->sb), &path);if (err <0 ) goto out_err;
@@ -278,14 +283,14 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,if (d->last) goto out; -if (ovl_is_opaquedir (d->sb, this)) { +if (ovl_is_opaquedir (OVL_FS (d->sb), &path)) { d->stop = true;if (last_element) d->opaque = true; goto out; } } - err =ovl_check_redirect (this, d, prelen, post); + err =ovl_check_redirect (&path, d, prelen, post);if (err) goto out_err; out:
@@ -856,6 +861,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, old_cred =ovl_override_creds (dentry->d_sb); upperdir =ovl_dentry_upper (dentry->d_parent);if (upperdir) { + d.mnt =ovl_upper_mnt (ofs); err =ovl_lookup_layer (upperdir, &d, &upperdentry, true);if (err) goto out;
@@ -911,6 +917,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,else d.last = lower.layer->idx == roe->numlower; + d.mnt = lower.layer->mnt; err =ovl_lookup_layer (lower.dentry, &d, &this, false);if (err) goto out_put;
@@ -1071,14 +1078,18 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,if (upperdentry)ovl_dentry_set_upper_alias (dentry);else if (index) { - upperdentry =dget (index); - upperredirect =ovl_get_redirect_xattr (ofs, upperdentry,0 ); +struct path upperpath = { + .dentry = upperdentry =dget (index), + .mnt =ovl_upper_mnt (ofs), + }; + + upperredirect =ovl_get_redirect_xattr (ofs, &upperpath,0 );if (IS_ERR (upperredirect)) { err =PTR_ERR (upperredirect); upperredirect =NULL ; goto out_free_oe; } - err =ovl_check_metacopy_xattr (ofs, upperdentry); + err =ovl_check_metacopy_xattr (ofs, &upperpath);if (err <0 ) goto out_free_oe; uppermetacopy = err;
fs/overlayfs/overlayfs.h +55 -22
128 lines not on this page · raw message
fs/overlayfs/util.c +14 -15
@@ -584,11 +584,11 @@ void ovl_copy_up_end(struct dentry *dentry)ovl_inode_unlock (d_inode (dentry)); } -bool ovl_check_origin_xattr (struct ovl_fs *ofs,struct dentry *dentry) +bool ovl_path_check_origin_xattr (struct ovl_fs *ofs,struct path *path) {int res; - res =ovl_getxattr (ofs, dentry,OVL_XATTR_ORIGIN ,NULL ,0 ); + res =ovl_path_getxattr (ofs, path,OVL_XATTR_ORIGIN ,NULL ,0 );/* Zero size value means "copied up but origin unknown" */ if (res >=0 )
@@ -597,16 +597,16 @@ bool ovl_check_origin_xattr(struct ovl_fs *ofs, struct dentry *dentry)return false; } -bool ovl_check_dir_xattr (struct super_block *sb,struct dentry *dentry, -enum ovl_xattr ox) +bool ovl_path_check_dir_xattr (struct ovl_fs *ofs,struct path *path, +enum ovl_xattr ox) {int res;char val; -if (!d_is_dir (dentry)) +if (!d_is_dir (path->dentry))return false; - res =ovl_getxattr (OVL_FS (sb), dentry, ox, &val,1 ); + res =ovl_path_getxattr (ofs, path, ox, &val,1 );if (res ==1 && val =='y' )return true;
@@ -686,8 +686,8 @@ void ovl_check_protattr(struct inode *inode, struct dentry *upper)char buf[OVL_PROTATTR_MAX +1 ];int res, n; - res =ovl_getxattr (ofs, upper,OVL_XATTR_PROTATTR , buf, -OVL_PROTATTR_MAX ); + res =ovl_getxattr_upper (ofs, upper,OVL_XATTR_PROTATTR , buf, +OVL_PROTATTR_MAX );if (res <0 )return ;
@@ -977,15 +977,15 @@ int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir) }/* err < 0, 0 if no metacopy xattr, 1 if metacopy xattr found */ -int ovl_check_metacopy_xattr (struct ovl_fs *ofs,struct dentry *dentry) +int ovl_check_metacopy_xattr (struct ovl_fs *ofs,struct path *path) {int res;/* Only regular files can have metacopy xattr */ -if (!S_ISREG (d_inode (dentry)->i_mode)) +if (!S_ISREG (d_inode (path->dentry)->i_mode))return 0 ; - res =ovl_getxattr (ofs, dentry,OVL_XATTR_METACOPY ,NULL ,0 ); + res =ovl_path_getxattr (ofs, path,OVL_XATTR_METACOPY ,NULL ,0 );if (res <0 ) {if (res == -ENODATA || res == -EOPNOTSUPP )return 0 ;
@@ -1021,13 +1021,12 @@ bool ovl_is_metacopy_dentry(struct dentry *dentry)return (oe->numlower >1 ); } -char *ovl_get_redirect_xattr (struct ovl_fs *ofs,struct dentry *dentry, -int padding) +char *ovl_get_redirect_xattr (struct ovl_fs *ofs,struct path *path,int padding) {int res;char *s, *next, *buf =NULL ; - res =ovl_getxattr (ofs, dentry,OVL_XATTR_REDIRECT ,NULL ,0 ); + res =ovl_path_getxattr (ofs, path,OVL_XATTR_REDIRECT ,NULL ,0 );if (res == -ENODATA || res == -EOPNOTSUPP )return NULL ;if (res <0 )
@@ -1039,7 +1038,7 @@ char *ovl_get_redirect_xattr(struct ovl_fs *ofs, struct dentry *dentry,if (!buf)return ERR_PTR (-ENOMEM ); - res =ovl_getxattr (ofs, dentry,OVL_XATTR_REDIRECT , buf, res); + res =ovl_path_getxattr (ofs, path,OVL_XATTR_REDIRECT , buf, res);if (res <0 ) goto fail;if (res ==0 )
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 ovl: do not copy up an xattr value that was never read
In reply to Sasha LevinFrom: Chris Mason <[email protected]>
[ Upstream commit 755b5c5c9277be251a51623d6065abab948c61bc ]
Copy-up stores uninitialized kernel memory in an xattr of the upper file, where the user can read it.
ovl_copy_xattr() may only pass bytes to ovl_do_setxattr() that ovl_do_getxattr() has read. When the read fails with -ERANGE the function asks for the size again, and if the new size fits the buffer it stores the buffer although nothing was read into it. The buffer comes from kvmalloc(), or it still holds the value of the previous xattr.
A FUSE lower layer that answers every sized GETXATTR with -ERANGE made copy-up store 4096 bytes that the server never sent, with a kernel pointer in them, as an xattr of the upper file.
Fix this by failing the copy-up with -EIO when the size that follows -ERANGE fits the buffer.
--- fs/overlayfs/copy_up.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/overlayfs/copy_up.c +5 -1
@@ -95,8 +95,12 @@ int ovl_copy_xattr(struct super_block *sb, struct path *oldpath, struct dentry * } retry: size =ovl_do_getxattr (oldpath, name, value, value_size); -if (size == -ERANGE ) +if (size == -ERANGE ) { size =ovl_do_getxattr (oldpath, name,NULL ,0 ); +/* Nothing was read into value, so it must not be used */ +if (size >=0 && size <= value_size) + size = -EIO ; + }if (size <0 ) { error = size;
Signature · 1 line
2.53.0