From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752500AbcH3SND (ORCPT ); Tue, 30 Aug 2016 14:13:03 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:36762 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751214AbcH3SNC (ORCPT ); Tue, 30 Aug 2016 14:13:02 -0400 Date: Tue, 30 Aug 2016 19:12:42 +0100 From: Al Viro To: Linus Torvalds Cc: Josh Poimboeuf , Kees Cook , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , the arch/x86 maintainers , Linux Kernel Mailing List , Andy Lutomirski , Steven Rostedt , Brian Gerst , Peter Zijlstra , Frederic Weisbecker , Byungchul Park , Nilay Vaish Subject: Re: [PATCH v3] mm/usercopy: get rid of CONFIG_DEBUG_STRICT_USER_COPY_CHECKS Message-ID: <20160830181242.GK2356@ZenIV.linux.org.uk> References: <20160829170813.l3jwu75ltu7tpryn@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 30, 2016 at 10:02:38AM -0700, Linus Torvalds wrote: > On Tue, Aug 30, 2016 at 6:04 AM, Josh Poimboeuf wrote: > > There are three usercopy warnings which are currently being silenced for > > gcc 4.6 and newer: > > [.. snip snip ..] > > Ok, I'm not entirely happy with the timing, but I think the problem > counts as a regression since it effectively made all the checks go > away in practice for most people, so I'm going to apply this patch. > > I know Al Viro is working on some uaccess cleanups and trying to make > a lot of this be generic, so there's hopefully cleanups coming in the > not too distant future (I say "hopefully", because I worry that > looking at the mess will make Al dig his eyes out), but this seems to > be a clear improvement. > > I still do wish we'd move the x86 __builtin_constant_p(n) check > around, so that x86 wouldn't do the run-time check_object_size() for > the trivially statically correct case, but I guess that's a separate > issue from this patch anyway. > > If somebody has objections to this patch, holler quickly, because it's > about to get applied. 3.. 2.. 1.. The only thing in my pile it conflicts with is this: commit 0983ee6305f551faf29b11e59486679f600f1cd9 Author: Al Viro Date: Sat Aug 20 19:03:37 2016 -0400 parisc: fix copy_from_user() Cc: stable@vger.kernel.org Signed-off-by: Al Viro diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h index 0f59fd9..54cfea9 100644 --- a/arch/parisc/include/asm/uaccess.h +++ b/arch/parisc/include/asm/uaccess.h @@ -221,13 +221,14 @@ static inline unsigned long __must_check copy_from_user(void *to, unsigned long n) { int sz = __compiletime_object_size(to); - int ret = -EFAULT; + unsigned long ret = n; if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n)) ret = __copy_from_user(to, from, n); else copy_from_user_overflow(); - + if (unlikely(ret)) + memset(to + (n - ret), 0, ret); return ret; }