mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-05-05 09:57:21 +02:00
6af36aeb14
Stacked filesystems such as overlayfs do not currently provide the necessary mechanisms for LSMs to properly enforce access controls on the mmap() and mprotect() operations. In order to resolve this gap, a LSM security blob is being added to the backing_file struct and the following new LSM hooks are being created: security_backing_file_alloc() security_backing_file_free() security_mmap_backing_file() The first two hooks are to manage the lifecycle of the LSM security blob in the backing_file struct, while the third provides a new mmap() access control point for the underlying backing file. It is also expected that LSMs will likely want to update their security_file_mprotect() callback to address issues with their mprotect() controls, but that does not require a change to the security_file_mprotect() LSM hook. There are a three other small changes to support these new LSM hooks: * Pass the user file associated with a backing file down to alloc_empty_backing_file() so it can be included in the security_backing_file_alloc() hook. * Add getter and setter functions for the backing_file struct LSM blob as the backing_file struct remains private to fs/file_table.c. * Constify the file struct field in the LSM common_audit_data struct to better support LSMs that need to pass a const file struct pointer into the common LSM audit code. Thanks to Arnd Bergmann for identifying the missing EXPORT_SYMBOL_GPL() and supplying a fixup. Cc: stable@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-unionfs@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Serge Hallyn <serge@hallyn.com> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Paul Moore <paul@paul-moore.com>
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Common helpers for stackable filesystems and backing files.
|
|
*
|
|
* Copyright (C) 2023 CTERA Networks.
|
|
*/
|
|
|
|
#ifndef _LINUX_BACKING_FILE_H
|
|
#define _LINUX_BACKING_FILE_H
|
|
|
|
#include <linux/file.h>
|
|
#include <linux/uio.h>
|
|
#include <linux/fs.h>
|
|
|
|
struct backing_file_ctx {
|
|
const struct cred *cred;
|
|
void (*accessed)(struct file *file);
|
|
void (*end_write)(struct kiocb *iocb, ssize_t);
|
|
};
|
|
|
|
struct file *backing_file_open(const struct file *user_file, int flags,
|
|
const struct path *real_path,
|
|
const struct cred *cred);
|
|
struct file *backing_tmpfile_open(const struct file *user_file, int flags,
|
|
const struct path *real_parentpath,
|
|
umode_t mode, const struct cred *cred);
|
|
ssize_t backing_file_read_iter(struct file *file, struct iov_iter *iter,
|
|
struct kiocb *iocb, int flags,
|
|
struct backing_file_ctx *ctx);
|
|
ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter,
|
|
struct kiocb *iocb, int flags,
|
|
struct backing_file_ctx *ctx);
|
|
ssize_t backing_file_splice_read(struct file *in, struct kiocb *iocb,
|
|
struct pipe_inode_info *pipe, size_t len,
|
|
unsigned int flags,
|
|
struct backing_file_ctx *ctx);
|
|
ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
|
|
struct file *out, struct kiocb *iocb,
|
|
size_t len, unsigned int flags,
|
|
struct backing_file_ctx *ctx);
|
|
int backing_file_mmap(struct file *file, struct vm_area_struct *vma,
|
|
struct backing_file_ctx *ctx);
|
|
|
|
#endif /* _LINUX_BACKING_FILE_H */
|