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

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

2021-01-21 Thread Eric W. Biederman
Alexey Gladkov writes: > 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: >> >> > >> >> > Sorry about that. I t

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: > >> > > >> > Sorry about that. I thought that this code is not neede

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

2021-01-19 Thread Eric W. Biederman
ebied...@xmission.com (Eric W. Biederman) writes: > 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: >>> > >>> > Sorry about that. I thought that this code is not needed when switching >>> >

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

2021-01-19 Thread Eric W. Biederman
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: >> > >> > Sorry about that. I thought that this code is not needed when switching >> > from int to refcount_t. I was wrong. >> >> Well, you _may_

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

2021-01-18 Thread Kaiwan N Billimoria
(Sorry for the gmail client) My 0.2, HTH: a) AFAIK, refcount_inc() (and similar friends) don't return any value b) they're designed to just WARN() if they saturate or if you're attempting to increment the value 0 (as it's possibly a UAF bug) c) refcount_inc_checked() is documented as "Similar to at

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_ be right. I personally didn't che

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

2021-01-18 Thread Linus Torvalds
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_ be right. I personally didn't check how the return value is used. I only reacted to "it certainly _may_ be use

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) > > ucounts = new; > > } >

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

2021-01-18 Thread Linus Torvalds
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) > ucounts = new; > } > } > - if (ucounts->count == INT_MAX) > - ucounts =

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

2021-01-15 Thread Alexey Gladkov
Signed-off-by: Alexey Gladkov --- include/linux/user_namespace.h | 2 +- kernel/ucount.c| 20 +++- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 64cf8ebdc4ec..f84fc2d9ce20 1006