[PATCH v5 22/42] open: handle idmapped mounts in do_truncate()
Christoph Hellwig
hch at infradead.org
Tue Jan 19 09:37:20 UTC 2021
On Tue, Jan 12, 2021 at 11:01:04PM +0100, Christian Brauner wrote:
> @@ -930,8 +932,12 @@ void dump_truncate(struct coredump_params *cprm)
>
> if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
> offset = file->f_op->llseek(file, 0, SEEK_CUR);
> - if (i_size_read(file->f_mapping->host) < offset)
> - do_truncate(file->f_path.dentry, offset, 0, file);
> + if (i_size_read(file->f_mapping->host) < offset) {
> + struct user_namespace *mnt_userns;
> +
> + mnt_userns = file_user_ns(file);
> + do_truncate(mnt_userns, file->f_path.dentry, offset, 0, file);
> + }
I think we can skip the local variable here. In fact for all callers
of do_truncate except vfs_truncate a little file_truncate helper that
takes a struct file would help readability a lot.
More information about the Linux-security-module-archive
mailing list