From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752154AbcHUAML (ORCPT ); Sat, 20 Aug 2016 20:12:11 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:56482 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751222AbcHUAMK (ORCPT ); Sat, 20 Aug 2016 20:12:10 -0400 Date: Sun, 21 Aug 2016 01:11:44 +0100 From: Al Viro To: Linus Torvalds Cc: Vineet Gupta , "linux-arch@vger.kernel.org" , Linux Kernel Mailing List , "H. Peter Anvin" , Ingo Molnar Subject: Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault Message-ID: <20160821001141.GV2356@ZenIV.linux.org.uk> References: <1471633802-2936-1-git-send-email-vgupta@synopsys.com> <20160819212428.GR2356@ZenIV.linux.org.uk> 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 Sat, Aug 20, 2016 at 04:32:57PM -0700, Linus Torvalds wrote: > Anyway, the asm coming out of gcc looks nasty, because it has all the > ugly section stuiff and fixups for SMAP not existing on some CPU's > etc. So the resulting fs/readdir.s file is hard to read. But if you > look at the disassembly at the object file that hides all that (and > shows what the end result actually is), the actual filldir user > accesses end up looking beautiful, with no extra code anywhere. An > exception just goes to the EFAULT handling directly. > > Sadly, unsafe_get_user() looking as good does require gcc improvements > that aren't imminent. > > This patch is untested, although the earlier original pre-rebased > version of it actually got a fair amount of testing on my machine > (including the filldir use) Interesting... BTW, how's this in the "really vile tricks" department? if (!uaccess_begin()) goto fail; unsafe_... ... uacess_end(); with uaccess_begin() along the lines of p = ¤t_thread_info()->foo; asm .text: STAC *p = 1f res = true; 2:; .fixups: 1:res = false; CLAC jmp 2; if (unlikely(res)) asm clobber everything res; and exception handlers in unsafe_... jumping to the address found in current_thread_info()->foo. AFAICS, it should avoid the problems with asm goto, right? The branch target is tied to the entry into the damn series, so it's not as if it could disappear; and path to a branch cc(1) doesn't see passes through the chunk produced by that asm block in uaccess_begin(), so if it looks unreachable without taking those branches into account, it _is_ unreachable.