linux-metag.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
  • * [PATCH 4.4 093/103] metag/uaccess: Check access_ok in strncpy_from_user
           [not found] <20170523200856.903752266@linuxfoundation.org>
           [not found] ` <20170523200856.903752266-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
    @ 2017-05-23 20:09 ` Greg Kroah-Hartman
      1 sibling, 0 replies; 2+ messages in thread
    From: Greg Kroah-Hartman @ 2017-05-23 20:09 UTC (permalink / raw)
      To: linux-kernel
      Cc: Greg Kroah-Hartman, stable, Al Viro, James Hogan, linux-metag
    
    4.4-stable review patch.  If anyone has any objections, please let me know.
    
    ------------------
    
    From: James Hogan <james.hogan@imgtec.com>
    
    commit 3a158a62da0673db918b53ac1440845a5b64fd90 upstream.
    
    The metag implementation of strncpy_from_user() doesn't validate the src
    pointer, which could allow reading of arbitrary kernel memory. Add a
    short access_ok() check to prevent that.
    
    Its still possible for it to read across the user/kernel boundary, but
    it will invariably reach a NUL character after only 9 bytes, leaking
    only a static kernel address being loaded into D0Re0 at the beginning of
    __start, which is acceptable for the immediate fix.
    
    Reported-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    
    ---
     arch/metag/include/asm/uaccess.h |    9 +++++++--
     1 file changed, 7 insertions(+), 2 deletions(-)
    
    --- a/arch/metag/include/asm/uaccess.h
    +++ b/arch/metag/include/asm/uaccess.h
    @@ -194,8 +194,13 @@ do {
     extern long __must_check __strncpy_from_user(char *dst, const char __user *src,
     					     long count);
     
    -#define strncpy_from_user(dst, src, count) __strncpy_from_user(dst, src, count)
    -
    +static inline long
    +strncpy_from_user(char *dst, const char __user *src, long count)
    +{
    +	if (!access_ok(VERIFY_READ, src, 1))
    +		return -EFAULT;
    +	return __strncpy_from_user(dst, src, count);
    +}
     /*
      * Return the size of a string (including the ending 0)
      *
    
    
    
    ^ permalink raw reply	[flat|nested] 2+ messages in thread

  • end of thread, other threads:[~2017-05-23 20:09 UTC | newest]
    
    Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <20170523200856.903752266@linuxfoundation.org>
         [not found] ` <20170523200856.903752266-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
    2017-05-23 20:09   ` [PATCH 4.4 092/103] metag/uaccess: Fix access_ok() Greg Kroah-Hartman
    2017-05-23 20:09 ` [PATCH 4.4 093/103] metag/uaccess: Check access_ok in strncpy_from_user Greg Kroah-Hartman
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox;
    as well as URLs for NNTP newsgroup(s).