mirror_zfs/lib
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
..
libavl Fixes for make dist 2020-06-26 14:20:02 -07:00
libefi Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libicp Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libnvpair Use abs_top_builddir when referencing libraries 2020-07-10 14:26:32 -07:00
libshare Fixes for make dist 2020-06-26 14:20:02 -07:00
libspl Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libtpool Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libunicode Fixes for make dist 2020-06-26 14:20:02 -07:00
libuutil Use abs_top_builddir when referencing libraries 2020-07-10 14:26:32 -07:00
libzfs libzfs: Add error message for why creating mountpoint failed 2020-07-11 17:16:13 -07:00
libzfs_core Use abs_top_builddir when referencing libraries 2020-07-10 14:26:32 -07:00
libzpool filesystem_limit/snapshot_limit is incorrectly enforced against root 2020-07-11 17:18:02 -07:00
libzutil Use abs_top_builddir when referencing libraries 2020-07-10 14:26:32 -07:00
Makefile.am Clean up lib dependencies 2020-07-10 14:26:00 -07:00