mirror_zfs/include/os/linux/zfs/sys
Matthew Ahrens e59a377a8f
filesystem_limit/snapshot_limit is incorrectly enforced against root
The filesystem_limit and snapshot_limit properties limit the number of
filesystems or snapshots that can be created below this dataset.
According to the manpage, "The limit is not enforced if the user is
allowed to change the limit."  Two types of users are allowed to change
the limit:

1. Those that have been delegated the `filesystem_limit` or
`snapshot_limit` permission, e.g. with
`zfs allow USER filesystem_limit DATASET`.  This works properly.

2. A user with elevated system privileges (e.g. root).  This does not
work - the root user will incorrectly get an error when trying to create
a snapshot/filesystem, if it exceeds the `_limit` property.

The problem is that `priv_policy_ns()` does not work if the `cred_t` is
not that of the current process.  This happens when
`dsl_enforce_ds_ss_limits()` is called in syncing context (as part of a
sync task's check func) to determine the permissions of the
corresponding user process.

This commit fixes the issue by passing the `task_struct` (typedef'ed as
a `proc_t`) to syncing context, and then using `has_capability()` to
determine if that process is privileged.  Note that we still need to
pass the `cred_t` to syncing context so that we can check if the user
was delegated this permission with `zfs allow`.

This problem only impacts Linux.  Wrappers are added to FreeBSD but it
continues to use `priv_check_cred()`, which works on arbitrary `cred_t`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8226
Closes #10545
2020-07-11 17:18:02 -07:00
..
Makefile.am Drop unnecessary srcdir paths 2020-06-24 18:20:18 -07:00
policy.h filesystem_limit/snapshot_limit is incorrectly enforced against root 2020-07-11 17:18:02 -07:00
sha2.h Move sha2.h to platform code 2019-10-31 15:45:58 -07:00
trace_acl.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_arc.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_common.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_dbgmsg.h Enable use of DTRACE_PROBE* macros in "spl" module 2019-11-01 13:13:43 -07:00
trace_dbuf.h Factor out some dbuf subroutines and add state change tracing 2020-02-18 11:21:37 -08:00
trace_dmu.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_dnode.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_multilist.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_rrwlock.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_txg.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_vdev.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_zfs.h Enable use of DTRACE_PROBE* macros in "spl" module 2019-11-01 13:13:43 -07:00
trace_zil.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_zio.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_zrlock.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
zfs_context_os.h Refactor zfs_context.h to build on FreeBSD 2019-12-04 13:12:57 -08:00
zfs_ctldir.h OpenZFS restructuring - move platform specific headers 2019-09-05 09:34:54 -07:00
zfs_dir.h Eliminate Linux specific inode usage from common code 2019-12-11 11:53:57 -08:00
zfs_vfsops.h Add prototypes 2020-06-18 12:21:32 -07:00
zfs_vnops.h Remove zfs_getattr and convoff dead code 2020-02-24 15:38:22 -08:00
zfs_znode_impl.h Eliminate Linux specific inode usage from common code 2019-12-11 11:53:57 -08:00
zpl.h Linux 5.6 compat: timestamp_truncate() 2020-02-07 11:04:32 -08:00