Re: [kernel-hardening] [PATCH v8 3/3] x86/refcount: Implement fast refcount overflow protection

2017-07-25 Thread Kees Cook
On Tue, Jul 25, 2017 at 5:03 AM, Li Kun wrote: > Hi Kees, > > > on 2017/7/25 2:35, Kees Cook wrote: >> >> +static __always_inline __must_check >> +int __refcount_add_unless(refcount_t *r, int a, int u) >> +{ >> + int c, new; >> + >> + c = atomic_read(&(r->refs));

Re: [kernel-hardening] [PATCH v8 3/3] x86/refcount: Implement fast refcount overflow protection

2017-07-25 Thread Kees Cook
On Tue, Jul 25, 2017 at 5:03 AM, Li Kun wrote: > Hi Kees, > > > on 2017/7/25 2:35, Kees Cook wrote: >> >> +static __always_inline __must_check >> +int __refcount_add_unless(refcount_t *r, int a, int u) >> +{ >> + int c, new; >> + >> + c = atomic_read(&(r->refs)); >> + do { >> +

Re: [kernel-hardening] [PATCH v8 3/3] x86/refcount: Implement fast refcount overflow protection

2017-07-25 Thread Li Kun
Hi Kees, on 2017/7/25 2:35, Kees Cook wrote: +static __always_inline __must_check +int __refcount_add_unless(refcount_t *r, int a, int u) +{ + int c, new; + + c = atomic_read(&(r->refs)); + do { + if (unlikely(c == u)) + break; + +

Re: [kernel-hardening] [PATCH v8 3/3] x86/refcount: Implement fast refcount overflow protection

2017-07-25 Thread Li Kun
Hi Kees, on 2017/7/25 2:35, Kees Cook wrote: +static __always_inline __must_check +int __refcount_add_unless(refcount_t *r, int a, int u) +{ + int c, new; + + c = atomic_read(&(r->refs)); + do { + if (unlikely(c == u)) + break; + +