Commit fee760fc6c79998efc48bd06afeec31824dfb2d4
Committed by
Greg Kroah-Hartman
1 parent
0fb615f9ca
Exists in
smarct4x-processor-sdk-04.01.00.06
and in
1 other branch
ovl: drop CAP_SYS_RESOURCE from saved mounter's credentials
commit 51f8f3c4e22535933ef9aecc00e9a6069e051b57 upstream. If overlay was mounted by root then quota set for upper layer does not work because overlay now always use mounter's credentials for operations. Also overlay might deplete reserved space and inodes in ext4. This patch drops capability SYS_RESOURCE from saved credentials. This affects creation new files, whiteouts, and copy-up operations. Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Fixes: 1175b6b8d963 ("ovl: do operations on underlying file system in mounter's context") Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Cc: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff
fs/overlayfs/super.c
... | ... | @@ -1146,6 +1146,7 @@ |
1146 | 1146 | unsigned int stacklen = 0; |
1147 | 1147 | unsigned int i; |
1148 | 1148 | bool remote = false; |
1149 | + struct cred *cred; | |
1149 | 1150 | int err; |
1150 | 1151 | |
1151 | 1152 | err = -ENOMEM; |
1152 | 1153 | |
... | ... | @@ -1309,9 +1310,12 @@ |
1309 | 1310 | else |
1310 | 1311 | sb->s_d_op = &ovl_dentry_operations; |
1311 | 1312 | |
1312 | - ufs->creator_cred = prepare_creds(); | |
1313 | - if (!ufs->creator_cred) | |
1313 | + ufs->creator_cred = cred = prepare_creds(); | |
1314 | + if (!cred) | |
1314 | 1315 | goto out_put_lower_mnt; |
1316 | + | |
1317 | + /* Never override disk quota limits or use reserved space */ | |
1318 | + cap_lower(cred->cap_effective, CAP_SYS_RESOURCE); | |
1315 | 1319 | |
1316 | 1320 | err = -ENOMEM; |
1317 | 1321 | oe = ovl_alloc_entry(numlower); |