Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Kirill Tkhai
В Вт, 28/10/2014 в 21:12 +0100, Oleg Nesterov пишет:
> On 10/28, Oleg Nesterov wrote:
> >
> > On 10/28, Kirill Tkhai wrote:
> > >
> > > Yes, probe_kernel_read() is in [1/3], but it's not the same as
> > > __probe_kernel_read() for blackfin, for example.
> > >
> > > It's defined as
> > >
> > > long __weak probe_kernel_read(void *dst, const void *src, size_t size)
> > > __attribute__((alias("__probe_kernel_read")));
> > >
> > > But blackfin's probe_kernel_read() redefines this __weak function,
> > > isn't it? Didn't get_freepointer_safe() use to call architecture's
> > > probe_kernel_read() before?
> >
> > I _think_ that __probe_kernel_read(slab_ddr) should be fine.
> >
> > Yes, an architecture may want to reimplement probe_kernel_read() to
> > allow to safely access the special areas, or special addresses.
> >
> > But again, in this case we know that this address points to the
> > "normal" kernel memory, __copy_from_user_inatomic() should work fine.
> 
> OTOH, perhaps probe_kernel_address() should use probe_kernel_read(), not
> __probe_kernel_read(). But currently it just calls __copy_inatomic() so
> 1/3 follows this logic.

Ok, thanks for the explanation, Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Oleg Nesterov
On 10/28, Oleg Nesterov wrote:
>
> On 10/28, Kirill Tkhai wrote:
> >
> > Yes, probe_kernel_read() is in [1/3], but it's not the same as
> > __probe_kernel_read() for blackfin, for example.
> >
> > It's defined as
> >
> > long __weak probe_kernel_read(void *dst, const void *src, size_t size)
> > __attribute__((alias("__probe_kernel_read")));
> >
> > But blackfin's probe_kernel_read() redefines this __weak function,
> > isn't it? Didn't get_freepointer_safe() use to call architecture's
> > probe_kernel_read() before?
>
> I _think_ that __probe_kernel_read(slab_ddr) should be fine.
>
> Yes, an architecture may want to reimplement probe_kernel_read() to
> allow to safely access the special areas, or special addresses.
>
> But again, in this case we know that this address points to the
> "normal" kernel memory, __copy_from_user_inatomic() should work fine.

OTOH, perhaps probe_kernel_address() should use probe_kernel_read(), not
__probe_kernel_read(). But currently it just calls __copy_inatomic() so
1/3 follows this logic.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Oleg Nesterov
On 10/28, Kirill Tkhai wrote:
>
> Yes, probe_kernel_read() is in [1/3], but it's not the same as
> __probe_kernel_read() for blackfin, for example.
>
> It's defined as
>
> long __weak probe_kernel_read(void *dst, const void *src, size_t size)
> __attribute__((alias("__probe_kernel_read")));
>
> But blackfin's probe_kernel_read() redefines this __weak function,
> isn't it? Didn't get_freepointer_safe() use to call architecture's
> probe_kernel_read() before?

I _think_ that __probe_kernel_read(slab_ddr) should be fine.

Yes, an architecture may want to reimplement probe_kernel_read() to
allow to safely access the special areas, or special addresses.

But again, in this case we know that this address points to the
"normal" kernel memory, __copy_from_user_inatomic() should work fine.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Kirill Tkhai
On 28.10.2014 20:56, Kirill Tkhai wrote:
> On 28.10.2014 18:01, Peter Zijlstra wrote:
>> On Tue, Oct 28, 2014 at 08:44:51AM +0300, Kirill Tkhai wrote:
>>> В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
>>
 +#define probe_slab_address(addr, retval)  \
 +  probe_kernel_address(addr, retval)
>>>
>>> probe_kernel_read() was arch-dependent on tree platforms:
>>>
>>> arch/blackfin/mm/maccess.c
>>> arch/parisc/lib/memcpy.c
>>> arch/um/kernel/maccess.c
>>>
>>> But now we skip these arch-dependent implementations. Is there no a problem?
>>
>> Nope, see the first patch, it makes probe_kernel_address use
>> __probe_kernel_read().
>>
> 
> Yes, probe_kernel_read() is in [1/3], but it's not the same as
> __probe_kernel_read() for blackfin, for example.

Vise versa, I mean __probe_kernel_read() is in [1/3].

> It's defined as
> 
> long __weak probe_kernel_read(void *dst, const void *src, size_t size)
> __attribute__((alias("__probe_kernel_read")));
> 
> But blackfin's probe_kernel_read() redefines this __weak function,
> isn't it? Didn't get_freepointer_safe() use to call architecture's
> probe_kernel_read() before?
> 
> I don't see how it is called now...
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Kirill Tkhai
On 28.10.2014 18:01, Peter Zijlstra wrote:
> On Tue, Oct 28, 2014 at 08:44:51AM +0300, Kirill Tkhai wrote:
>> В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
> 
>>> +#define probe_slab_address(addr, retval)   \
>>> +   probe_kernel_address(addr, retval)
>>
>> probe_kernel_read() was arch-dependent on tree platforms:
>>
>> arch/blackfin/mm/maccess.c
>> arch/parisc/lib/memcpy.c
>> arch/um/kernel/maccess.c
>>
>> But now we skip these arch-dependent implementations. Is there no a problem?
>
> Nope, see the first patch, it makes probe_kernel_address use
> __probe_kernel_read().
> 

Yes, probe_kernel_read() is in [1/3], but it's not the same as
__probe_kernel_read() for blackfin, for example.

It's defined as

long __weak probe_kernel_read(void *dst, const void *src, size_t size)
__attribute__((alias("__probe_kernel_read")));

But blackfin's probe_kernel_read() redefines this __weak function,
isn't it? Didn't get_freepointer_safe() use to call architecture's
probe_kernel_read() before?

I don't see how it is called now...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Peter Zijlstra
On Tue, Oct 28, 2014 at 08:44:51AM +0300, Kirill Tkhai wrote:
> В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:

> > +#define probe_slab_address(addr, retval)   \
> > +   probe_kernel_address(addr, retval)
> 
> probe_kernel_read() was arch-dependent on tree platforms:
> 
> arch/blackfin/mm/maccess.c
> arch/parisc/lib/memcpy.c
> arch/um/kernel/maccess.c
> 
> But now we skip these arch-dependent implementations. Is there no a problem?

Nope, see the first patch, it makes probe_kernel_address use
__probe_kernel_read().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Peter Zijlstra
On Tue, Oct 28, 2014 at 08:44:51AM +0300, Kirill Tkhai wrote:
 В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:

  +#define probe_slab_address(addr, retval)   \
  +   probe_kernel_address(addr, retval)
 
 probe_kernel_read() was arch-dependent on tree platforms:
 
 arch/blackfin/mm/maccess.c
 arch/parisc/lib/memcpy.c
 arch/um/kernel/maccess.c
 
 But now we skip these arch-dependent implementations. Is there no a problem?

Nope, see the first patch, it makes probe_kernel_address use
__probe_kernel_read().
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Kirill Tkhai
On 28.10.2014 18:01, Peter Zijlstra wrote:
 On Tue, Oct 28, 2014 at 08:44:51AM +0300, Kirill Tkhai wrote:
 В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
 
 +#define probe_slab_address(addr, retval)   \
 +   probe_kernel_address(addr, retval)

 probe_kernel_read() was arch-dependent on tree platforms:

 arch/blackfin/mm/maccess.c
 arch/parisc/lib/memcpy.c
 arch/um/kernel/maccess.c

 But now we skip these arch-dependent implementations. Is there no a problem?

 Nope, see the first patch, it makes probe_kernel_address use
 __probe_kernel_read().
 

Yes, probe_kernel_read() is in [1/3], but it's not the same as
__probe_kernel_read() for blackfin, for example.

It's defined as

long __weak probe_kernel_read(void *dst, const void *src, size_t size)
__attribute__((alias(__probe_kernel_read)));

But blackfin's probe_kernel_read() redefines this __weak function,
isn't it? Didn't get_freepointer_safe() use to call architecture's
probe_kernel_read() before?

I don't see how it is called now...
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Kirill Tkhai
On 28.10.2014 20:56, Kirill Tkhai wrote:
 On 28.10.2014 18:01, Peter Zijlstra wrote:
 On Tue, Oct 28, 2014 at 08:44:51AM +0300, Kirill Tkhai wrote:
 В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:

 +#define probe_slab_address(addr, retval)  \
 +  probe_kernel_address(addr, retval)

 probe_kernel_read() was arch-dependent on tree platforms:

 arch/blackfin/mm/maccess.c
 arch/parisc/lib/memcpy.c
 arch/um/kernel/maccess.c

 But now we skip these arch-dependent implementations. Is there no a problem?

 Nope, see the first patch, it makes probe_kernel_address use
 __probe_kernel_read().

 
 Yes, probe_kernel_read() is in [1/3], but it's not the same as
 __probe_kernel_read() for blackfin, for example.

Vise versa, I mean __probe_kernel_read() is in [1/3].

 It's defined as
 
 long __weak probe_kernel_read(void *dst, const void *src, size_t size)
 __attribute__((alias(__probe_kernel_read)));
 
 But blackfin's probe_kernel_read() redefines this __weak function,
 isn't it? Didn't get_freepointer_safe() use to call architecture's
 probe_kernel_read() before?
 
 I don't see how it is called now...
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Oleg Nesterov
On 10/28, Kirill Tkhai wrote:

 Yes, probe_kernel_read() is in [1/3], but it's not the same as
 __probe_kernel_read() for blackfin, for example.

 It's defined as

 long __weak probe_kernel_read(void *dst, const void *src, size_t size)
 __attribute__((alias(__probe_kernel_read)));

 But blackfin's probe_kernel_read() redefines this __weak function,
 isn't it? Didn't get_freepointer_safe() use to call architecture's
 probe_kernel_read() before?

I _think_ that __probe_kernel_read(slab_ddr) should be fine.

Yes, an architecture may want to reimplement probe_kernel_read() to
allow to safely access the special areas, or special addresses.

But again, in this case we know that this address points to the
normal kernel memory, __copy_from_user_inatomic() should work fine.

Oleg.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Oleg Nesterov
On 10/28, Oleg Nesterov wrote:

 On 10/28, Kirill Tkhai wrote:
 
  Yes, probe_kernel_read() is in [1/3], but it's not the same as
  __probe_kernel_read() for blackfin, for example.
 
  It's defined as
 
  long __weak probe_kernel_read(void *dst, const void *src, size_t size)
  __attribute__((alias(__probe_kernel_read)));
 
  But blackfin's probe_kernel_read() redefines this __weak function,
  isn't it? Didn't get_freepointer_safe() use to call architecture's
  probe_kernel_read() before?

 I _think_ that __probe_kernel_read(slab_ddr) should be fine.

 Yes, an architecture may want to reimplement probe_kernel_read() to
 allow to safely access the special areas, or special addresses.

 But again, in this case we know that this address points to the
 normal kernel memory, __copy_from_user_inatomic() should work fine.

OTOH, perhaps probe_kernel_address() should use probe_kernel_read(), not
__probe_kernel_read(). But currently it just calls __copy_inatomic() so
1/3 follows this logic.

Oleg.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-28 Thread Kirill Tkhai
В Вт, 28/10/2014 в 21:12 +0100, Oleg Nesterov пишет:
 On 10/28, Oleg Nesterov wrote:
 
  On 10/28, Kirill Tkhai wrote:
  
   Yes, probe_kernel_read() is in [1/3], but it's not the same as
   __probe_kernel_read() for blackfin, for example.
  
   It's defined as
  
   long __weak probe_kernel_read(void *dst, const void *src, size_t size)
   __attribute__((alias(__probe_kernel_read)));
  
   But blackfin's probe_kernel_read() redefines this __weak function,
   isn't it? Didn't get_freepointer_safe() use to call architecture's
   probe_kernel_read() before?
 
  I _think_ that __probe_kernel_read(slab_ddr) should be fine.
 
  Yes, an architecture may want to reimplement probe_kernel_read() to
  allow to safely access the special areas, or special addresses.
 
  But again, in this case we know that this address points to the
  normal kernel memory, __copy_from_user_inatomic() should work fine.
 
 OTOH, perhaps probe_kernel_address() should use probe_kernel_read(), not
 __probe_kernel_read(). But currently it just calls __copy_inatomic() so
 1/3 follows this logic.

Ok, thanks for the explanation, Oleg.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Kirill Tkhai
В Вт, 28/10/2014 в 08:44 +0300, Kirill Tkhai пишет:
> В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
> > Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
> > into the new generic helper, probe_slab_address(). The next patch will add
> > another user.
> > 
> > Signed-off-by: Oleg Nesterov 
> > ---
> >  include/linux/uaccess.h |   15 +++
> >  mm/slub.c   |6 +-
> >  2 files changed, 16 insertions(+), 5 deletions(-)
> > 
> > diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
> > index effb637..3367396 100644
> > --- a/include/linux/uaccess.h
> > +++ b/include/linux/uaccess.h
> > @@ -71,6 +71,21 @@ static inline unsigned long 
> > __copy_from_user_nocache(void *to,
> > __probe_kernel_read(&(retval), (__force void *)(addr), sizeof(retval))
> >  
> >  /*
> > + * Same as probe_kernel_address(), but @addr must be the valid pointer
> > + * to a slab object, potentially freed/reused/unmapped.
> > + */
> > +#ifdef CONFIG_DEBUG_PAGEALLOC
> > +#define probe_slab_address(addr, retval)   \
> > +   probe_kernel_address(addr, retval)
> > +#else
> > +#define probe_slab_address(addr, retval)   \
> > +   ({  \
> > +   (retval) = *(typeof(retval) *)(addr);   \
> > +   0;  \
> > +   })
> > +#endif
> > +
> > +/*
> >   * probe_kernel_read(): safely attempt to read from a location
> >   * @dst: pointer to the buffer that shall take the data
> >   * @src: address to read from
> > diff --git a/mm/slub.c b/mm/slub.c
> > index 3e8afcc..0467d22 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -265,11 +265,7 @@ static inline void *get_freepointer_safe(struct 
> > kmem_cache *s, void *object)
> >  {
> > void *p;
> >  
> > -#ifdef CONFIG_DEBUG_PAGEALLOC
> > -   probe_kernel_read(, (void **)(object + s->offset), sizeof(p));
> > -#else
> > -   p = get_freepointer(s, object);
> > -#endif
> > +   probe_slab_address(object + s->offset, p);
> > return p;
> >  }
> >  
> 
> probe_kernel_read() was arch-dependent on tree platforms:

Of course, I mean get_freepointer_safe() used to use arch-dependent
probe_kernel_read() on blackfin, parisc and um.

> arch/blackfin/mm/maccess.c
> arch/parisc/lib/memcpy.c
> arch/um/kernel/maccess.c
> 
> But now we skip these arch-dependent implementations. Is there no a problem?


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Kirill Tkhai
В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
> Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
> into the new generic helper, probe_slab_address(). The next patch will add
> another user.
> 
> Signed-off-by: Oleg Nesterov 
> ---
>  include/linux/uaccess.h |   15 +++
>  mm/slub.c   |6 +-
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
> index effb637..3367396 100644
> --- a/include/linux/uaccess.h
> +++ b/include/linux/uaccess.h
> @@ -71,6 +71,21 @@ static inline unsigned long __copy_from_user_nocache(void 
> *to,
>   __probe_kernel_read(&(retval), (__force void *)(addr), sizeof(retval))
>  
>  /*
> + * Same as probe_kernel_address(), but @addr must be the valid pointer
> + * to a slab object, potentially freed/reused/unmapped.
> + */
> +#ifdef CONFIG_DEBUG_PAGEALLOC
> +#define probe_slab_address(addr, retval) \
> + probe_kernel_address(addr, retval)
> +#else
> +#define probe_slab_address(addr, retval) \
> + ({  \
> + (retval) = *(typeof(retval) *)(addr);   \
> + 0;  \
> + })
> +#endif
> +
> +/*
>   * probe_kernel_read(): safely attempt to read from a location
>   * @dst: pointer to the buffer that shall take the data
>   * @src: address to read from
> diff --git a/mm/slub.c b/mm/slub.c
> index 3e8afcc..0467d22 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -265,11 +265,7 @@ static inline void *get_freepointer_safe(struct 
> kmem_cache *s, void *object)
>  {
>   void *p;
>  
> -#ifdef CONFIG_DEBUG_PAGEALLOC
> - probe_kernel_read(, (void **)(object + s->offset), sizeof(p));
> -#else
> - p = get_freepointer(s, object);
> -#endif
> + probe_slab_address(object + s->offset, p);
>   return p;
>  }
>  

probe_kernel_read() was arch-dependent on tree platforms:

arch/blackfin/mm/maccess.c
arch/parisc/lib/memcpy.c
arch/um/kernel/maccess.c

But now we skip these arch-dependent implementations. Is there no a problem?

Kirill

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Christoph Lameter
On Mon, 27 Oct 2014, Oleg Nesterov wrote:

> Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
> into the new generic helper, probe_slab_address(). The next patch will add
> another user.

Acked-by: Christoph Lameter 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Oleg Nesterov
Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
into the new generic helper, probe_slab_address(). The next patch will add
another user.

Signed-off-by: Oleg Nesterov 
---
 include/linux/uaccess.h |   15 +++
 mm/slub.c   |6 +-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index effb637..3367396 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -71,6 +71,21 @@ static inline unsigned long __copy_from_user_nocache(void 
*to,
__probe_kernel_read(&(retval), (__force void *)(addr), sizeof(retval))
 
 /*
+ * Same as probe_kernel_address(), but @addr must be the valid pointer
+ * to a slab object, potentially freed/reused/unmapped.
+ */
+#ifdef CONFIG_DEBUG_PAGEALLOC
+#define probe_slab_address(addr, retval)   \
+   probe_kernel_address(addr, retval)
+#else
+#define probe_slab_address(addr, retval)   \
+   ({  \
+   (retval) = *(typeof(retval) *)(addr);   \
+   0;  \
+   })
+#endif
+
+/*
  * probe_kernel_read(): safely attempt to read from a location
  * @dst: pointer to the buffer that shall take the data
  * @src: address to read from
diff --git a/mm/slub.c b/mm/slub.c
index 3e8afcc..0467d22 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -265,11 +265,7 @@ static inline void *get_freepointer_safe(struct kmem_cache 
*s, void *object)
 {
void *p;
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-   probe_kernel_read(, (void **)(object + s->offset), sizeof(p));
-#else
-   p = get_freepointer(s, object);
-#endif
+   probe_slab_address(object + s->offset, p);
return p;
 }
 
-- 
1.5.5.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Oleg Nesterov
Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
into the new generic helper, probe_slab_address(). The next patch will add
another user.

Signed-off-by: Oleg Nesterov o...@redhat.com
---
 include/linux/uaccess.h |   15 +++
 mm/slub.c   |6 +-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index effb637..3367396 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -71,6 +71,21 @@ static inline unsigned long __copy_from_user_nocache(void 
*to,
__probe_kernel_read((retval), (__force void *)(addr), sizeof(retval))
 
 /*
+ * Same as probe_kernel_address(), but @addr must be the valid pointer
+ * to a slab object, potentially freed/reused/unmapped.
+ */
+#ifdef CONFIG_DEBUG_PAGEALLOC
+#define probe_slab_address(addr, retval)   \
+   probe_kernel_address(addr, retval)
+#else
+#define probe_slab_address(addr, retval)   \
+   ({  \
+   (retval) = *(typeof(retval) *)(addr);   \
+   0;  \
+   })
+#endif
+
+/*
  * probe_kernel_read(): safely attempt to read from a location
  * @dst: pointer to the buffer that shall take the data
  * @src: address to read from
diff --git a/mm/slub.c b/mm/slub.c
index 3e8afcc..0467d22 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -265,11 +265,7 @@ static inline void *get_freepointer_safe(struct kmem_cache 
*s, void *object)
 {
void *p;
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-   probe_kernel_read(p, (void **)(object + s-offset), sizeof(p));
-#else
-   p = get_freepointer(s, object);
-#endif
+   probe_slab_address(object + s-offset, p);
return p;
 }
 
-- 
1.5.5.1


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Christoph Lameter
On Mon, 27 Oct 2014, Oleg Nesterov wrote:

 Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
 into the new generic helper, probe_slab_address(). The next patch will add
 another user.

Acked-by: Christoph Lameter c...@linux.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Kirill Tkhai
В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
 Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
 into the new generic helper, probe_slab_address(). The next patch will add
 another user.
 
 Signed-off-by: Oleg Nesterov o...@redhat.com
 ---
  include/linux/uaccess.h |   15 +++
  mm/slub.c   |6 +-
  2 files changed, 16 insertions(+), 5 deletions(-)
 
 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
 index effb637..3367396 100644
 --- a/include/linux/uaccess.h
 +++ b/include/linux/uaccess.h
 @@ -71,6 +71,21 @@ static inline unsigned long __copy_from_user_nocache(void 
 *to,
   __probe_kernel_read((retval), (__force void *)(addr), sizeof(retval))
  
  /*
 + * Same as probe_kernel_address(), but @addr must be the valid pointer
 + * to a slab object, potentially freed/reused/unmapped.
 + */
 +#ifdef CONFIG_DEBUG_PAGEALLOC
 +#define probe_slab_address(addr, retval) \
 + probe_kernel_address(addr, retval)
 +#else
 +#define probe_slab_address(addr, retval) \
 + ({  \
 + (retval) = *(typeof(retval) *)(addr);   \
 + 0;  \
 + })
 +#endif
 +
 +/*
   * probe_kernel_read(): safely attempt to read from a location
   * @dst: pointer to the buffer that shall take the data
   * @src: address to read from
 diff --git a/mm/slub.c b/mm/slub.c
 index 3e8afcc..0467d22 100644
 --- a/mm/slub.c
 +++ b/mm/slub.c
 @@ -265,11 +265,7 @@ static inline void *get_freepointer_safe(struct 
 kmem_cache *s, void *object)
  {
   void *p;
  
 -#ifdef CONFIG_DEBUG_PAGEALLOC
 - probe_kernel_read(p, (void **)(object + s-offset), sizeof(p));
 -#else
 - p = get_freepointer(s, object);
 -#endif
 + probe_slab_address(object + s-offset, p);
   return p;
  }
  

probe_kernel_read() was arch-dependent on tree platforms:

arch/blackfin/mm/maccess.c
arch/parisc/lib/memcpy.c
arch/um/kernel/maccess.c

But now we skip these arch-dependent implementations. Is there no a problem?

Kirill

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] introduce probe_slab_address()

2014-10-27 Thread Kirill Tkhai
В Вт, 28/10/2014 в 08:44 +0300, Kirill Tkhai пишет:
 В Пн, 27/10/2014 в 20:54 +0100, Oleg Nesterov пишет:
  Extract the ifdef(CONFIG_DEBUG_PAGEALLOC) code from get_freepointer_safe()
  into the new generic helper, probe_slab_address(). The next patch will add
  another user.
  
  Signed-off-by: Oleg Nesterov o...@redhat.com
  ---
   include/linux/uaccess.h |   15 +++
   mm/slub.c   |6 +-
   2 files changed, 16 insertions(+), 5 deletions(-)
  
  diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
  index effb637..3367396 100644
  --- a/include/linux/uaccess.h
  +++ b/include/linux/uaccess.h
  @@ -71,6 +71,21 @@ static inline unsigned long 
  __copy_from_user_nocache(void *to,
  __probe_kernel_read((retval), (__force void *)(addr), sizeof(retval))
   
   /*
  + * Same as probe_kernel_address(), but @addr must be the valid pointer
  + * to a slab object, potentially freed/reused/unmapped.
  + */
  +#ifdef CONFIG_DEBUG_PAGEALLOC
  +#define probe_slab_address(addr, retval)   \
  +   probe_kernel_address(addr, retval)
  +#else
  +#define probe_slab_address(addr, retval)   \
  +   ({  \
  +   (retval) = *(typeof(retval) *)(addr);   \
  +   0;  \
  +   })
  +#endif
  +
  +/*
* probe_kernel_read(): safely attempt to read from a location
* @dst: pointer to the buffer that shall take the data
* @src: address to read from
  diff --git a/mm/slub.c b/mm/slub.c
  index 3e8afcc..0467d22 100644
  --- a/mm/slub.c
  +++ b/mm/slub.c
  @@ -265,11 +265,7 @@ static inline void *get_freepointer_safe(struct 
  kmem_cache *s, void *object)
   {
  void *p;
   
  -#ifdef CONFIG_DEBUG_PAGEALLOC
  -   probe_kernel_read(p, (void **)(object + s-offset), sizeof(p));
  -#else
  -   p = get_freepointer(s, object);
  -#endif
  +   probe_slab_address(object + s-offset, p);
  return p;
   }
   
 
 probe_kernel_read() was arch-dependent on tree platforms:

Of course, I mean get_freepointer_safe() used to use arch-dependent
probe_kernel_read() on blackfin, parisc and um.

 arch/blackfin/mm/maccess.c
 arch/parisc/lib/memcpy.c
 arch/um/kernel/maccess.c
 
 But now we skip these arch-dependent implementations. Is there no a problem?


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/