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.

ovl: relax requirement for uuid=off,index=on

uuid=off,index=on required that all upper/lower directories are on the
same filesystem.

Relax the requirement so that only all the lower directories need to be
on the same filesystem.

Reported-by: André Almeida <andrealmeid@igalia.com>
Link: https://lore.kernel.org/r/20260114-tonyk-get_disk_uuid-v1-3-e6a319e25d57@igalia.com/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>

+24 -20
+3 -3
Documentation/filesystems/overlayfs.rst
··· 753 753 read-write mount and will result in an error. 754 754 755 755 Note: the mount option uuid=off can be used to replace UUID of the underlying 756 - filesystem in file handles with null, and effectively disable UUID checks. This 756 + filesystem in file handles with null, in order to relax the UUID checks. This 757 757 can be useful in case the underlying disk is copied and the UUID of this copy 758 - is changed. This is only applicable if all lower/upper/work directories are on 758 + is changed. This is only applicable if all lower directories are on 759 759 the same filesystem, otherwise it will fallback to normal behaviour. 760 760 761 761 ··· 769 769 UUID of overlayfs is null. fsid is taken from upper most filesystem. 770 770 - "off": 771 771 UUID of overlayfs is null. fsid is taken from upper most filesystem. 772 - UUID of underlying layers is ignored. 772 + UUID of underlying layers is ignored and null used instead. 773 773 - "on": 774 774 UUID of overlayfs is generated and used to report a unique fsid. 775 775 UUID is stored in xattr "trusted.overlay.uuid", making overlayfs fsid
+13 -8
fs/overlayfs/namei.c
··· 158 158 goto out; 159 159 } 160 160 161 + bool ovl_uuid_match(struct ovl_fs *ofs, const struct super_block *sb, 162 + const uuid_t *uuid) 163 + { 164 + /* 165 + * Make sure that the stored uuid matches the uuid of the lower 166 + * layer where file handle will be decoded. 167 + * In case of uuid=off option just make sure that stored uuid is null. 168 + */ 169 + return ovl_origin_uuid(ofs) ? uuid_equal(uuid, &sb->s_uuid) : 170 + uuid_is_null(uuid); 171 + } 172 + 161 173 struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh, 162 174 struct vfsmount *mnt, bool connected) 163 175 { ··· 179 167 if (!capable(CAP_DAC_READ_SEARCH)) 180 168 return NULL; 181 169 182 - /* 183 - * Make sure that the stored uuid matches the uuid of the lower 184 - * layer where file handle will be decoded. 185 - * In case of uuid=off option just make sure that stored uuid is null. 186 - */ 187 - if (ovl_origin_uuid(ofs) ? 188 - !uuid_equal(&fh->fb.uuid, &mnt->mnt_sb->s_uuid) : 189 - !uuid_is_null(&fh->fb.uuid)) 170 + if (!ovl_uuid_match(ofs, mnt->mnt_sb, &fh->fb.uuid)) 190 171 return NULL; 191 172 192 173 bytes = (fh->fb.len - offsetof(struct ovl_fb, fid));
+2
fs/overlayfs/overlayfs.h
··· 710 710 return ovl_check_fb_len(&fh->fb, fh_len - OVL_FH_WIRE_OFFSET); 711 711 } 712 712 713 + bool ovl_uuid_match(struct ovl_fs *ofs, const struct super_block *sb, 714 + const uuid_t *uuid); 713 715 struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh, 714 716 struct vfsmount *mnt, bool connected); 715 717 int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
+6 -9
fs/overlayfs/super.c
··· 940 940 * disable lower file handle decoding on all of them. 941 941 */ 942 942 if (ofs->fs[i].is_lower && 943 - uuid_equal(&ofs->fs[i].sb->s_uuid, uuid)) { 943 + ovl_uuid_match(ofs, ofs->fs[i].sb, uuid)) { 944 944 ofs->fs[i].bad_uuid = true; 945 945 return false; 946 946 } ··· 952 952 static int ovl_get_fsid(struct ovl_fs *ofs, const struct path *path) 953 953 { 954 954 struct super_block *sb = path->mnt->mnt_sb; 955 + const uuid_t *uuid = ovl_origin_uuid(ofs) ? &sb->s_uuid : &uuid_null; 955 956 unsigned int i; 956 957 dev_t dev; 957 958 int err; ··· 964 963 return i; 965 964 } 966 965 967 - if (!ovl_lower_uuid_ok(ofs, &sb->s_uuid)) { 966 + if (!ovl_lower_uuid_ok(ofs, uuid)) { 968 967 bad_uuid = true; 969 968 if (ofs->config.xino == OVL_XINO_AUTO) { 970 969 ofs->config.xino = OVL_XINO_OFF; ··· 976 975 warn = true; 977 976 } 978 977 if (warn) { 979 - pr_warn("%s uuid detected in lower fs '%pd2', falling back to xino=%s,index=off,nfs_export=off.\n", 980 - uuid_is_null(&sb->s_uuid) ? "null" : 981 - "conflicting", 978 + pr_warn("%s uuid in non-single lower fs '%pd2', falling back to xino=%s,index=off,nfs_export=off.\n", 979 + uuid_is_null(uuid) ? "null" : "conflicting", 982 980 path->dentry, ovl_xino_mode(&ofs->config)); 983 981 } 984 982 } ··· 1469 1469 if (!ovl_upper_mnt(ofs)) 1470 1470 sb->s_flags |= SB_RDONLY; 1471 1471 1472 - if (!ovl_origin_uuid(ofs) && ofs->numfs > 1) { 1473 - pr_warn("The uuid=off requires a single fs for lower and upper, falling back to uuid=null.\n"); 1474 - ofs->config.uuid = OVL_UUID_NULL; 1475 - } else if (ovl_has_fsid(ofs) && ovl_upper_mnt(ofs)) { 1472 + if (ovl_has_fsid(ofs) && ovl_upper_mnt(ofs)) { 1476 1473 /* Use per instance persistent uuid/fsid */ 1477 1474 ovl_init_uuid_xattr(sb, ofs, &ctx->upper); 1478 1475 }