Re: [PATCH v5 5/7] proc: instantiate only pids that we can ptrace on 'limit_pids=1' mount option

2018-05-14 Thread Alexey Gladkov
On Fri, May 11, 2018 at 09:45:33AM -0700, Linus Torvalds wrote: > On Fri, May 11, 2018 at 2:46 AM Alexey Gladkov > wrote: > > > + /* Limit procfs to only ptracable tasks */ > > + if (limit_pids == PROC_LIMIT_PIDS_PTRACE) { > > + cond_resche

Re: [PATCH v5 5/7] proc: instantiate only pids that we can ptrace on 'limit_pids=1' mount option

2018-05-14 Thread Alexey Gladkov
On Fri, May 11, 2018 at 09:09:04AM -0700, Randy Dunlap wrote: > On 05/11/2018 02:36 AM, Alexey Gladkov wrote: > > From: Djalal Harouni > > > > If "limit_pids=1" mount option is set then do not instantiate pids that > > we can not ptrace. "limit_pid

Re: [PATCH v5 7/7] proc: add option to mount only a pids subset

2018-05-14 Thread Alexey Gladkov
On Fri, May 11, 2018 at 03:58:39PM +0200, Jann Horn wrote: > On Fri, May 11, 2018 at 11:37 AM, Alexey Gladkov > wrote: > > This allows to hide all files and directories in the procfs that are not > > related to tasks. > > /proc/$pid/net and /proc/$pid/task/$tid/net

[PATCH v6 1/7] Increase size of ucounts to atomic_long_t

2021-02-15 Thread Alexey Gladkov
RLIMIT_MSGQUEUE and RLIMIT_MEMLOCK use unsigned long to store their counters. As a preparation for moving rlimits based on ucounts, we need to increase the size of the variable to long. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 ++-- kernel/ucount.c

[PATCH v6 2/7] Add a reference to ucounts for each cred

2021-02-15 Thread Alexey Gladkov
-deref in is_ucounts_overlimit() detected by trinity. This error was caused by the fact that cred_alloc_blank() left the ucounts pointer empty. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/exec.c | 4 include/linux/cred.h | 2

[PATCH v6 4/7] Reimplement RLIMIT_MSGQUEUE on top of ucounts

2021-02-15 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- include/linux/sched

[PATCH v6 3/7] Reimplement RLIMIT_NPROC on top of ucounts

2021-02-15 Thread Alexey Gladkov
r the counter. Some rlimits can be overlimited by root or if the user has the appropriate capability. Signed-off-by: Alexey Gladkov --- fs/exec.c | 2 +- fs/io-wq.c | 22 ++-- fs/io-wq.h | 2 +- fs/io_uring.c

[PATCH v6 5/7] Reimplement RLIMIT_SIGPENDING on top of ucounts

2021-02-15 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- fs/proc/array.c

[PATCH v6 0/7] Count rlimits in each user namespace

2021-02-15 Thread Alexey Gladkov
ncreased the size of ucounts to atomic_long_t. * Added ucount_max to avoid the fork bomb. -- Alexey Gladkov (7): Increase size of ucounts to atomic_long_t Add a reference to ucounts for each cred Reimplement RLIMIT_NPROC on top of ucounts Reimplement RLIMIT_MSGQUEUE on top of u

[PATCH v6 7/7] kselftests: Add test to check for rlimit changes in different user namespaces

2021-02-15 Thread Alexey Gladkov
The testcase runs few instances of the program with RLIMIT_NPROC=1 from user uid=6, in different user namespaces. Signed-off-by: Alexey Gladkov --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rlimits/.gitignore| 2 + tools/testing/selftests/rlimits

[PATCH v6 6/7] Reimplement RLIMIT_MEMLOCK on top of ucounts

2021-02-15 Thread Alexey Gladkov
trinity. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c | 16 include/linux/hugetlb.h| 4 ++-- include/linux/mm.h | 4 ++-- include/linux/sched/user.h | 1 - include/linux/shmem_fs.h | 2

[PATCH v7 6/7] Reimplement RLIMIT_MEMLOCK on top of ucounts

2021-02-16 Thread Alexey Gladkov
CONFIG_HUGETLBFS=n. A `const' was missing from one of the arguments. v6: * Fix bug in hugetlb_file_setup() detected by trinity. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c | 16 include/linux/hugetlb.h| 4 ++-- in

[PATCH v10 0/9] Count rlimits in each user namespace

2021-04-07 Thread Alexey Gladkov
re than 1. v1: * After discussion with Eric W. Biederman, I increased the size of ucounts to atomic_long_t. * Added ucount_max to avoid the fork bomb. -- Alexey Gladkov (9): Increase size of ucounts to atomic_long_t Add a reference to ucounts for each cred Use atomic_t for ucounts reference

[PATCH v10 1/9] Increase size of ucounts to atomic_long_t

2021-04-07 Thread Alexey Gladkov
RLIMIT_MSGQUEUE and RLIMIT_MEMLOCK use unsigned long to store their counters. As a preparation for moving rlimits based on ucounts, we need to increase the size of the variable to long. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 ++-- kernel/ucount.c

[PATCH v10 4/9] Reimplement RLIMIT_NPROC on top of ucounts

2021-04-07 Thread Alexey Gladkov
r the counter. Some rlimits can be overlimited by root or if the user has the appropriate capability. Signed-off-by: Alexey Gladkov --- fs/exec.c | 2 +- include/linux/cred.h | 2 ++ include/linux/sched/user.h | 1 - include/linux/user_namespace.h | 13 + k

[PATCH v10 3/9] Use atomic_t for ucounts reference counting

2021-04-07 Thread Alexey Gladkov
o put ucounts in case we cannot increase ucounts->count. This will allow to cover the case when all consumers will return ucounts at once. v9: * Use a negative value to check that the ucounts->count is close to overflow. Signed-off-by: Alexey Gladkov --- include/linux/user_names

[PATCH v10 2/9] Add a reference to ucounts for each cred

2021-04-07 Thread Alexey Gladkov
-deref in is_ucounts_overlimit() detected by trinity. This error was caused by the fact that cred_alloc_blank() left the ucounts pointer empty. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/exec.c | 4 include/linux/cred.h | 2

[PATCH v10 5/9] Reimplement RLIMIT_MSGQUEUE on top of ucounts

2021-04-07 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- include/linux/sched

[PATCH v10 6/9] Reimplement RLIMIT_SIGPENDING on top of ucounts

2021-04-07 Thread Alexey Gladkov
: Alexey Gladkov --- fs/proc/array.c| 2 +- include/linux/sched/user.h | 1 - include/linux/signal_types.h | 4 ++- include/linux/user_namespace.h | 1 + kernel/fork.c | 1 + kernel/signal.c| 58 -- kernel

[PATCH v10 7/9] Reimplement RLIMIT_MEMLOCK on top of ucounts

2021-04-07 Thread Alexey Gladkov
: * Keep only ucounts for RLIMIT_MEMLOCK checks instead of struct cred. v6: * Fix bug in hugetlb_file_setup() detected by trinity. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c | 16 include/linux/hugetlb.h| 4

[PATCH v10 9/9] ucounts: Set ucount_max to the largest positive value the type can hold

2021-04-07 Thread Alexey Gladkov
and RLIMIT_MEMLOCK are limited to 2GiB instead of 4GiB. I don't think anyone cares but it should be mentioned in case someone does. The RLIMIT_NPROC and RLIMIT_SIGPENDING used atomic_t so their maximum hasn't changed. Signed-off-by: Alexey Gladkov --- include/linux/user_name

[PATCH v10 8/9] kselftests: Add test to check for rlimit changes in different user namespaces

2021-04-07 Thread Alexey Gladkov
The testcase runs few instances of the program with RLIMIT_NPROC=1 from user uid=6, in different user namespaces. Signed-off-by: Alexey Gladkov --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rlimits/.gitignore| 2 + tools/testing/selftests/rlimits

Re: 08ed4efad6: stress-ng.sigsegv.ops_per_sec -41.9% regression

2021-04-08 Thread Alexey Gladkov
On Thu, Apr 08, 2021 at 09:22:40AM -0700, Linus Torvalds wrote: > On Thu, Apr 8, 2021 at 1:32 AM kernel test robot > wrote: > > > > FYI, we noticed a -41.9% regression of stress-ng.sigsegv.ops_per_sec due to > > commit > > 08ed4efad684 ("[PATCH v10 6/9] Reimplement RLIMIT_SIGPENDING on top of >

Re: [PATCH v5 1/7] proc: add proc_fs_info struct to store proc information

2018-05-15 Thread Alexey Gladkov
On Fri, May 11, 2018 at 03:49:13PM +0200, Jann Horn wrote: > On Fri, May 11, 2018 at 11:34 AM, Alexey Gladkov > wrote: > > From: Djalal Harouni > > > > This is a preparation patch that adds proc_fs_info to be able to store > > different procfs options and info

[RESEND PATCH v1] moduleparam: Save information about built-in modules in separate file

2019-03-15 Thread Alexey Gladkov
AID framework md_mod.license=GPL md_mod.parmtype=create_on_open:bool md_mod.parmtype=start_dirty_degraded:int ... Co-Developed-by: Gleb Fotengauer-Malinovskiy Signed-off-by: Gleb Fotengauer-Malinovskiy Signed-off-by: Alexey Gladkov --- Makefile| 1 + incl

Re: [RESEND PATCH v1] moduleparam: Save information about built-in modules in separate file

2019-03-26 Thread Alexey Gladkov
On Fri, Mar 22, 2019 at 02:34:12PM +0900, Masahiro Yamada wrote: > Hi. > > (added some people to CC) > > > On Fri, Mar 15, 2019 at 7:10 PM Alexey Gladkov > wrote: > > > > Problem: > > > > When a kernel module is compiled as a separate module, so

Re: [RESEND PATCH v1] moduleparam: Save information about built-in modules in separate file

2019-03-27 Thread Alexey Gladkov
On Wed, Mar 27, 2019 at 04:40:25PM +0100, Jessica Yu wrote: > +++ Alexey Gladkov [26/03/19 18:24 +0100]: > >On Fri, Mar 22, 2019 at 02:34:12PM +0900, Masahiro Yamada wrote: > >> Hi. > >> > >> (added some people to CC) > > (Thanks Masahiro for the CC!) &g

Re: d28296d248: stress-ng.sigsegv.ops_per_sec -82.7% regression

2021-02-24 Thread Alexey Gladkov
484fa11e94dff65e93eb25802a443d47 ("[PATCH v7 5/7] > > Reimplement RLIMIT_SIGPENDING on top of ucounts") > > url: > > https://github.com/0day-ci/linux/commits/Alexey-Gladkov/Count-rlimits-in-each-user-namespace/20210222-175836 > > base: > > https://git.kernel.org/cg

[RESEND PATCH v4 0/3] proc: Relax check of mount visibility

2021-02-17 Thread Alexey Gladkov
: * Add 'const' to struct cred *mounter_cred (fix kernel test robot warning). v2: * cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of procfs. -- Alexey Gladkov (3): proc: Relax check of mount visibility proc: Show /pro

[RESEND PATCH v4 2/3] proc: Show /proc/self/net only for CAP_NET_ADMIN

2021-02-17 Thread Alexey Gladkov
Cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of proc. Show /proc/self/net only if mounter has CAP_NET_ADMIN and if proc is mounted with subset=pid option. Signed-off-by: Alexey Gladkov --- fs/proc/proc_net.c | 8

[RESEND PATCH v4 3/3] proc: Disable cancellation of subset=pid option

2021-02-17 Thread Alexey Gladkov
There is no way to remount procfs mountpoint with subset=pid option without it. This is done in order not to make visible what was hidden since some checks occur during mount. This patch makes this limitation explicit and demonstrates the error. Signed-off-by: Alexey Gladkov --- fs/proc/root.c

[RESEND PATCH v4 1/3] proc: Relax check of mount visibility

2021-02-17 Thread Alexey Gladkov
Allow to mount of procfs with subset=pid option even if the entire procfs is not fully accessible to the user. Signed-off-by: Alexey Gladkov --- fs/namespace.c | 27 --- fs/proc/root.c | 17 ++--- include/linux/fs.h | 1 + 3 files changed, 27

[PATCH v5 2/7] Add a reference to ucounts for each cred

2021-02-01 Thread Alexey Gladkov
user_namespace. Updating ucounts may require memory allocation which may fail. So, we cannot change cred.ucounts in the commit_creds() because this function cannot fail and it should always return 0. For this reason, we modify cred.ucounts before calling the commit_creds(). Signed-off-by: Alexey Gladkov

[PATCH v5 4/7] Reimplement RLIMIT_MSGQUEUE on top of ucounts

2021-02-01 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- include/linux/sched

[PATCH v5 1/7] Increase size of ucounts to atomic_long_t

2021-02-01 Thread Alexey Gladkov
RLIMIT_MSGQUEUE and RLIMIT_MEMLOCK use unsigned long to store their counters. As a preparation for moving rlimits based on ucounts, we need to increase the size of the variable to long. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 ++-- kernel/ucount.c

[PATCH v5 5/7] Reimplement RLIMIT_SIGPENDING on top of ucounts

2021-02-01 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- fs/proc/array.c

[PATCH v5 3/7] Reimplement RLIMIT_NPROC on top of ucounts

2021-02-01 Thread Alexey Gladkov
r the counter. Some rlimits can be overlimited by root or if the user has the appropriate capability. Signed-off-by: Alexey Gladkov --- fs/exec.c | 2 +- fs/io-wq.c | 22 ++--- fs/io-wq.h | 2 +- fs/io_uring.c

[PATCH v5 7/7] kselftests: Add test to check for rlimit changes in different user namespaces

2021-02-01 Thread Alexey Gladkov
The testcase runs few instances of the program with RLIMIT_NPROC=1 from user uid=6, in different user namespaces. Signed-off-by: Alexey Gladkov --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rlimits/.gitignore| 2 + tools/testing/selftests/rlimits

[PATCH v5 6/7] Reimplement RLIMIT_MEMLOCK on top of ucounts

2021-02-01 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c

[PATCH v5 0/7] Count rlimits in each user namespace

2021-02-01 Thread Alexey Gladkov
avoid the fork bomb. -- Alexey Gladkov (7): Increase size of ucounts to atomic_long_t Add a reference to ucounts for each cred Reimplement RLIMIT_NPROC on top of ucounts Reimplement RLIMIT_MSGQUEUE on top of ucounts Reimplement RLIMIT_SIGPENDING on top of ucounts Reimplement RLIM

Re: d28296d248: stress-ng.sigsegv.ops_per_sec -82.7% regression

2021-02-25 Thread Alexey Gladkov
On Wed, Feb 24, 2021 at 12:50:21PM -0600, Eric W. Biederman wrote: > Alexey Gladkov writes: > > > On Wed, Feb 24, 2021 at 10:54:17AM -0600, Eric W. Biederman wrote: > >> kernel test robot writes: > >> > >> > Greeting, > >> >

[PATCH v2 2/2] Show /proc/self/net only for CAP_NET_ADMIN

2020-07-31 Thread Alexey Gladkov
Cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of proc. Show /proc/self/net only if mounter has CAP_NET_ADMIN and if proc is mounted with subset=pid option. Signed-off-by: Alexey Gladkov --- fs/proc/proc_net.c | 8

[PATCH v2 0/2] proc: Relax check of mount visibility

2020-08-19 Thread Alexey Gladkov
If only the dynamic part of procfs is mounted (subset=pid), then there is no need to check if procfs is fully visible to the user in the new user namespace. Alexey Gladkov (2): proc: Relax check of mount visibility Show /proc/self/net only for CAP_NET_ADMIN fs/namespace.c | 27

[PATCH v2 2/2] Show /proc/self/net only for CAP_NET_ADMIN

2020-08-19 Thread Alexey Gladkov
Cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of proc. Show /proc/self/net only if mounter has CAP_NET_ADMIN and if proc is mounted with subset=pid option. Signed-off-by: Alexey Gladkov --- fs/proc/proc_net.c | 8

[PATCH v2 1/2] proc: Relax check of mount visibility

2020-08-19 Thread Alexey Gladkov
Allow to mount of procfs with subset=pid option even if the entire procfs is not fully accessible to the user. Signed-off-by: Alexey Gladkov --- fs/namespace.c | 27 --- fs/proc/root.c | 16 +--- include/linux/fs.h | 1 + 3 files changed, 26

[PATCH v3 2/2] Show /proc/self/net only for CAP_NET_ADMIN

2020-08-20 Thread Alexey Gladkov
Cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of proc. Show /proc/self/net only if mounter has CAP_NET_ADMIN and if proc is mounted with subset=pid option. Signed-off-by: Alexey Gladkov --- fs/proc/proc_net.c | 8

[PATCH v3 0/2] proc: Relax check of mount visibility

2020-08-20 Thread Alexey Gladkov
redentials and make access to the net directories contingent of the permissions of the mounter of procfs. Alexey Gladkov (2): proc: Relax check of mount visibility Show /proc/self/net only for CAP_NET_ADMIN fs/namespace.c | 27 --- fs/proc/proc_net.c

[PATCH v3 1/2] proc: Relax check of mount visibility

2020-08-20 Thread Alexey Gladkov
Allow to mount of procfs with subset=pid option even if the entire procfs is not fully accessible to the user. Signed-off-by: Alexey Gladkov --- fs/namespace.c | 27 --- fs/proc/root.c | 16 +--- include/linux/fs.h | 1 + 3 files changed, 26

[RFC PATCH v2 2/8] Add a reference to ucounts for each user

2021-01-10 Thread Alexey Gladkov
for migrating rlimits to ucounts. Signed-off-by: Alexey Gladkov --- include/linux/cred.h | 1 + include/linux/user_namespace.h | 2 ++ kernel/cred.c | 17 +++-- kernel/ucount.c| 12 +++- kernel/user_namespace.c| 1 + 5 files

[RFC PATCH v2 0/8] Count rlimits in each user namespace

2021-01-10 Thread Alexey Gladkov
discussion with Eric W. Biederman, I increased the size of ucounts to atomic_long_t. * Added ucount_max to avoid the fork bomb. -- Alexey Gladkov (8): Use atomic type for ucounts reference counting Add a reference to ucounts for each user Increase size of ucounts to atomic_long_t Move

[RFC PATCH v2 5/8] Move RLIMIT_MSGQUEUE counter to ucounts

2021-01-10 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- include/linux/sched/user.h | 4 include/linux/user_namespace.h | 8 ipc/mqueue.c | 29 +++-- kernel/fork.c | 1 + kernel/ucount.c| 1 + kernel/user_namespace.c

[RFC PATCH v2 6/8] Move RLIMIT_SIGPENDING counter to ucounts

2021-01-10 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- fs/proc/array.c| 2 +- include/linux/sched/user.h | 1 - include/linux/signal_types.h | 4 ++- include/linux/user_namespace.h | 1 + kernel/fork.c | 1 + kernel/signal.c| 53

[RFC PATCH v2 7/8] Move RLIMIT_MEMLOCK counter to ucounts

2021-01-10 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c | 17 - include/linux/hugetlb.h| 3 +-- include/linux/mm.h | 4 ++-- include/linux/shmem_fs.h | 2 +- include/linux/user_namespace.h | 1 + ipc/shm.c | 31

[RFC PATCH v2 1/8] Use atomic type for ucounts reference counting

2021-01-10 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 2 +- kernel/ucount.c| 10 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 64cf8ebdc4ec..84fefa9247c4 100644 --- a

[RFC PATCH v2 4/8] Move RLIMIT_NPROC counter to ucounts

2021-01-10 Thread Alexey Gladkov
becomes meaningless. We cannot use existing inc_ucounts / dec_ucounts because they do not allow us to exceed the maximum for the counter. Some rlimits can be overlimited if the user has the appropriate capability. Signed-off-by: Alexey Gladkov --- fs/exec.c | 2 +- fs/io

[RFC PATCH v2 3/8] Increase size of ucounts to atomic_long_t

2021-01-10 Thread Alexey Gladkov
This commit is preparation for migrating rlimits counters to ucounts. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 ++-- kernel/ucount.c| 14 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/user_namespace.h b

[RFC PATCH v2 8/8] Move RLIMIT_NPROC check to the place where we increment the counter

2021-01-10 Thread Alexey Gladkov
After calling set_user(), we always have to call commit_creds() to apply new credentials upon the current task. There is no need to separate limit check and counter incrementing. Signed-off-by: Alexey Gladkov --- kernel/cred.c | 22 +- kernel/sys.c | 13 - 2

Re: [RFC PATCH v3 1/8] Use refcount_t for ucounts reference counting

2021-01-18 Thread Alexey Gladkov
On Mon, Jan 18, 2021 at 11:14:48AM -0800, Linus Torvalds wrote: > On Fri, Jan 15, 2021 at 6:59 AM Alexey Gladkov > wrote: > > > > @@ -152,10 +153,7 @@ static struct ucounts *get_ucounts(struct > > user_namespace *ns, kuid_t uid) > >

Re: [RFC PATCH v3 1/8] Use refcount_t for ucounts reference counting

2021-01-18 Thread Alexey Gladkov
On Mon, Jan 18, 2021 at 12:34:29PM -0800, Linus Torvalds wrote: > On Mon, Jan 18, 2021 at 11:46 AM Alexey Gladkov > wrote: > > > > Sorry about that. I thought that this code is not needed when switching > > from int to refcount_t. I was wrong. > > Well, you _may_

[PATCH v9 1/8] Increase size of ucounts to atomic_long_t

2021-03-23 Thread Alexey Gladkov
RLIMIT_MSGQUEUE and RLIMIT_MEMLOCK use unsigned long to store their counters. As a preparation for moving rlimits based on ucounts, we need to increase the size of the variable to long. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 ++-- kernel/ucount.c

[PATCH v9 2/8] Add a reference to ucounts for each cred

2021-03-23 Thread Alexey Gladkov
-deref in is_ucounts_overlimit() detected by trinity. This error was caused by the fact that cred_alloc_blank() left the ucounts pointer empty. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/exec.c | 4 include/linux/cred.h | 2

[PATCH v9 6/8] Reimplement RLIMIT_SIGPENDING on top of ucounts

2021-03-23 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- fs/proc/array.c

[PATCH v9 0/8] Count rlimits in each user namespace

2021-03-23 Thread Alexey Gladkov
ted to ucounts. * Added ucounts for pair uid and user namespace into cred. * Added the ability to increase ucount by more than 1. v1: * After discussion with Eric W. Biederman, I increased the size of ucounts to atomic_long_t. * Added ucount_max to avoid the fork bomb. -- Alexey Gladkov (8): Incr

[PATCH v9 4/8] Reimplement RLIMIT_NPROC on top of ucounts

2021-03-23 Thread Alexey Gladkov
r the counter. Some rlimits can be overlimited by root or if the user has the appropriate capability. Signed-off-by: Alexey Gladkov --- fs/exec.c | 2 +- include/linux/cred.h | 2 ++ include/linux/sched/user.h | 1 - include/linux/user_namespace.h | 13 k

[PATCH v9 3/8] Use atomic_t for ucounts reference counting

2021-03-23 Thread Alexey Gladkov
ue to check that the ucounts->count is close to overflow. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 +-- kernel/ucount.c| 53 -- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/include/linux/user_nam

[PATCH v9 8/8] kselftests: Add test to check for rlimit changes in different user namespaces

2021-03-23 Thread Alexey Gladkov
The testcase runs few instances of the program with RLIMIT_NPROC=1 from user uid=6, in different user namespaces. Signed-off-by: Alexey Gladkov --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rlimits/.gitignore| 2 + tools/testing/selftests/rlimits

[PATCH v9 5/8] Reimplement RLIMIT_MSGQUEUE on top of ucounts

2021-03-23 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- include/linux/sched

[PATCH v9 7/8] Reimplement RLIMIT_MEMLOCK on top of ucounts

2021-03-23 Thread Alexey Gladkov
: * Keep only ucounts for RLIMIT_MEMLOCK checks instead of struct cred. v6: * Fix bug in hugetlb_file_setup() detected by trinity. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c | 16 include/linux/hugetlb.h| 4

Re: [PATCH] proc: test subset=pid

2021-03-20 Thread Alexey Gladkov
; Currently "subset=pid" doesn't return "." and ".." via readdir. > This must be a bug. Ops. Good catch! Looks good to me. Acked-by: Alexey Gladkov > Signed-off-by: Alexey Dobriyan > --- > > tools/testing/selftests/proc/Makefile |

Re: [PATCH] proc: delete redundant subset=pid check

2021-03-20 Thread Alexey Gladkov
then I disabled lookup. Now this is unnecessary. Acked-by: Alexey Gladkov > Signed-off-by: Alexey Dobriyan > --- > > fs/proc/inode.c |4 > 1 file changed, 4 deletions(-) > > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -483,7 +483,6 @@ proc_reg_get_

Re: 08ed4efad6: stress-ng.sigsegv.ops_per_sec -41.9% regression

2021-04-16 Thread Alexey Gladkov
On Thu, Apr 08, 2021 at 01:44:43PM -0500, Eric W. Biederman wrote: > Linus Torvalds writes: > > > On Thu, Apr 8, 2021 at 1:32 AM kernel test robot > > wrote: > >> > >> FYI, we noticed a -41.9% regression of stress-ng.sigsegv.ops_per_sec due > >> to commit > >> 08ed4efad684 ("[PATCH v10 6/9] Re

Re: [PATCH v9 4/8] Reimplement RLIMIT_NPROC on top of ucounts

2021-04-06 Thread Alexey Gladkov
On Mon, Apr 05, 2021 at 11:56:35AM -0500, Eric W. Biederman wrote: > > Also when setting ns->ucount_max[] in create_user_ns because one value > is signed and the other is unsigned. Care should be taken so that > rlimit_infinity is translated into the largest positive value the > type can hold. Yo

[PATCH v7 1/7] Increase size of ucounts to atomic_long_t

2021-02-22 Thread Alexey Gladkov
RLIMIT_MSGQUEUE and RLIMIT_MEMLOCK use unsigned long to store their counters. As a preparation for moving rlimits based on ucounts, we need to increase the size of the variable to long. Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 4 ++-- kernel/ucount.c

[PATCH v7 0/7] Count rlimits in each user namespace

2021-02-22 Thread Alexey Gladkov
to cred. * Added the ability to increase ucount by more than 1. v1: * After discussion with Eric W. Biederman, I increased the size of ucounts to atomic_long_t. * Added ucount_max to avoid the fork bomb. -- Alexey Gladkov (7): Increase size of ucounts to atomic_long_t Add a reference to u

[PATCH v7 3/7] Reimplement RLIMIT_NPROC on top of ucounts

2021-02-22 Thread Alexey Gladkov
r the counter. Some rlimits can be overlimited by root or if the user has the appropriate capability. Signed-off-by: Alexey Gladkov --- fs/exec.c | 2 +- fs/io-wq.c | 22 ++-- fs/io-wq.h | 2 +- fs/io_uring.c

[PATCH v7 4/7] Reimplement RLIMIT_MSGQUEUE on top of ucounts

2021-02-22 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- include/linux/sched

[PATCH v7 2/7] Add a reference to ucounts for each cred

2021-02-22 Thread Alexey Gladkov
-deref in is_ucounts_overlimit() detected by trinity. This error was caused by the fact that cred_alloc_blank() left the ucounts pointer empty. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/exec.c | 4 include/linux/cred.h | 2

[PATCH v7 6/7] Reimplement RLIMIT_MEMLOCK on top of ucounts

2021-02-22 Thread Alexey Gladkov
instead of struct cred. v6: * Fix bug in hugetlb_file_setup() detected by trinity. Reported-by: kernel test robot Signed-off-by: Alexey Gladkov --- fs/hugetlbfs/inode.c | 16 include/linux/hugetlb.h| 4 ++-- include/linux/mm.h | 4 ++-- include

[PATCH v7 5/7] Reimplement RLIMIT_SIGPENDING on top of ucounts

2021-02-22 Thread Alexey Gladkov
The rlimit counter is tied to uid in the user_namespace. This allows rlimit values to be specified in userns even if they are already globally exceeded by the user. However, the value of the previous user_namespaces cannot be exceeded. Signed-off-by: Alexey Gladkov --- fs/proc/array.c

[PATCH v7 7/7] kselftests: Add test to check for rlimit changes in different user namespaces

2021-02-22 Thread Alexey Gladkov
The testcase runs few instances of the program with RLIMIT_NPROC=1 from user uid=6, in different user namespaces. Signed-off-by: Alexey Gladkov --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rlimits/.gitignore| 2 + tools/testing/selftests/rlimits

Re: [PATCH v6 3/7] Reimplement RLIMIT_NPROC on top of ucounts

2021-02-22 Thread Alexey Gladkov
On Sun, Feb 21, 2021 at 04:38:10PM -0700, Jens Axboe wrote: > On 2/15/21 5:41 AM, Alexey Gladkov wrote: > > diff --git a/fs/io-wq.c b/fs/io-wq.c > > index a564f36e260c..5b6940c90c61 100644 > > --- a/fs/io-wq.c > > +++ b/fs/io-wq.c > > @@ -1090,10 +1091,7 @@ st

Re: [PATCH v6 0/7] Count rlimits in each user namespace

2021-02-22 Thread Alexey Gladkov
On Sun, Feb 21, 2021 at 02:20:00PM -0800, Linus Torvalds wrote: > On Mon, Feb 15, 2021 at 4:42 AM Alexey Gladkov > wrote: > > > > These patches are for binding the rlimit counters to a user in user > > namespace. > > So this is now version 6, but I thi

[PATCH v6 0/5] proc: subset=pid: Relax check of mount visibility

2021-03-12 Thread Alexey Gladkov
if subset=pid is canceled during remount. v3: * Add 'const' to struct cred *mounter_cred (fix kernel test robot warning). v2: * cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of procfs. -- Alexey Gladkov (5): docs:

[PATCH v6 3/5] proc: Disable cancellation of subset=pid option

2021-03-12 Thread Alexey Gladkov
When procfs is mounted with subset=pid option, where is no way to remount it with this option removed. This is done in order not to make visible what ever was hidden since some checks occur during mount. This patch makes the limitation explicit and prints an error message. Signed-off-by: Alexey

[PATCH v6 5/5] docs: proc: add documentation about relaxing visibility restrictions

2021-03-12 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- Documentation/filesystems/proc.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 5a1bb0e081fd..9d993aef7f1c 100644 --- a/Documentation/filesystems/proc.rst

[PATCH v6 1/5] docs: proc: add documentation about mount restrictions

2021-03-12 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- Documentation/filesystems/proc.rst | 14 ++ 1 file changed, 14 insertions(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 2fa69f710e2a..5a1bb0e081fd 100644 --- a/Documentation/filesystems/proc.rst +++ b

[PATCH v6 4/5] proc: Relax check of mount visibility

2021-03-12 Thread Alexey Gladkov
Allow to mount procfs with subset=pid option even if the entire procfs is not fully accessible to the user. Signed-off-by: Alexey Gladkov --- fs/namespace.c | 30 ++ fs/proc/root.c | 16 ++-- include/linux/fs.h | 1 + 3 files changed, 29

[PATCH v6 2/5] proc: subset=pid: Show /proc/self/net only for CAP_NET_ADMIN

2021-03-12 Thread Alexey Gladkov
Cache the mounters credentials and allow access to the net directories contingent of the permissions of the mounter of proc. Do not show /proc/self/net when proc is mounted with subset=pid option and the mounter does not have CAP_NET_ADMIN. Signed-off-by: Alexey Gladkov --- fs/proc/proc_net.c

[PATCH v5 0/5] proc: Relax check of mount visibility

2021-03-10 Thread Alexey Gladkov
: * Add 'const' to struct cred *mounter_cred (fix kernel test robot warning). v2: * cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of procfs. -- Alexey Gladkov (5): docs: proc: add documentation about mount restricti

[PATCH v5 1/5] docs: proc: add documentation about mount restrictions

2021-03-10 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- Documentation/filesystems/proc.rst | 16 1 file changed, 16 insertions(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 2fa69f710e2a..3daf0e7d1071 100644 --- a/Documentation/filesystems/proc.rst

[PATCH v5 5/5] docs: proc: add documentation about relaxing visibility restrictions

2021-03-10 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- Documentation/filesystems/proc.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 3daf0e7d1071..9d2985a7aad6 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation

[PATCH v5 4/5] proc: Relax check of mount visibility

2021-03-10 Thread Alexey Gladkov
Allow to mount of procfs with subset=pid option even if the entire procfs is not fully accessible to the user. Signed-off-by: Alexey Gladkov --- fs/namespace.c | 27 --- fs/proc/root.c | 17 ++--- include/linux/fs.h | 1 + 3 files changed, 27

[PATCH v5 3/5] proc: Disable cancellation of subset=pid option

2021-03-10 Thread Alexey Gladkov
There is no way to remount procfs mountpoint with subset=pid option without it. This is done in order not to make visible what was hidden since some checks occur during mount. This patch makes this limitation explicit and demonstrates the error. Signed-off-by: Alexey Gladkov --- fs/proc/root.c

[PATCH v5 2/5] proc: Show /proc/self/net only for CAP_NET_ADMIN

2021-03-10 Thread Alexey Gladkov
Cache the mounters credentials and make access to the net directories contingent of the permissions of the mounter of proc. Show /proc/self/net only if mounter has CAP_NET_ADMIN and if proc is mounted with subset=pid option. Signed-off-by: Alexey Gladkov --- fs/proc/proc_net.c | 8

Re: [RESEND PATCH v4 0/3] proc: Relax check of mount visibility

2021-03-10 Thread Alexey Gladkov
On Mon, Feb 22, 2021 at 09:44:40AM -0600, Eric W. Biederman wrote: > Alexey Gladkov writes: > > > If only the dynamic part of procfs is mounted (subset=pid), then there is no > > need to check if procfs is fully visible to the user in the new user > > namespace. &g

Re: [PATCH v5 0/5] proc: Relax check of mount visibility

2021-03-10 Thread Alexey Gladkov
On Wed, Mar 10, 2021 at 07:19:55PM +0100, Alexey Gladkov wrote: > If only the dynamic part of procfs is mounted (subset=pid), then there is no > need to check if procfs is fully visible to the user in the new user > namespace. I'm sorry about that unfinished patch set. Pl

Re: [RFC PATCH v3 1/8] Use refcount_t for ucounts reference counting

2021-01-21 Thread Alexey Gladkov
On Tue, Jan 19, 2021 at 07:57:36PM -0600, Eric W. Biederman wrote: > Alexey Gladkov writes: > > > On Mon, Jan 18, 2021 at 12:34:29PM -0800, Linus Torvalds wrote: > >> On Mon, Jan 18, 2021 at 11:46 AM Alexey Gladkov > >> wrote: > >> > > >>

Re: [RFC PATCH v3 1/8] Use refcount_t for ucounts reference counting

2021-01-21 Thread Alexey Gladkov
On Thu, Jan 21, 2021 at 09:50:34AM -0600, Eric W. Biederman wrote: > >> The current ucount code does check for overflow and fails the increment > >> in every case. > >> > >> So arguably it will be a regression and inferior error handling behavior > >> if the code switches to the ``better'' refcoun

[PATCH v4 0/7] Count rlimits in each user namespace

2021-01-22 Thread Alexey Gladkov
ucounts for pair uid and user namespace into cred. * Added the ability to increase ucount by more than 1. v1: * After discussion with Eric W. Biederman, I increased the size of ucounts to atomic_long_t. * Added ucount_max to avoid the fork bomb. -- Alexey Gladkov (7): Add a reference to u

[PATCH v4 1/7] Add a reference to ucounts for each cred

2021-01-22 Thread Alexey Gladkov
limit. Signed-off-by: Alexey Gladkov --- include/linux/cred.h | 1 + include/linux/user_namespace.h | 7 -- kernel/cred.c | 20 +-- kernel/ucount.c| 46 ++ kernel/user_namespace.c| 1 + 5 files

  1   2   >