From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FDE5C4CECE for ; Sun, 13 Oct 2019 18:13:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8456020673 for ; Sun, 13 Oct 2019 18:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728968AbfJMSNi (ORCPT ); Sun, 13 Oct 2019 14:13:38 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:34088 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727141AbfJMSNi (ORCPT ); Sun, 13 Oct 2019 14:13:38 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iJiN3-0006Hg-Cd; Sun, 13 Oct 2019 18:13:33 +0000 Date: Sun, 13 Oct 2019 19:13:33 +0100 From: Al Viro To: Linus Torvalds Cc: Guenter Roeck , Linux Kernel Mailing List , linux-fsdevel Subject: Re: [PATCH] Convert filldir[64]() from __put_user() to unsafe_put_user() Message-ID: <20191013181333.GK26530@ZenIV.linux.org.uk> References: <20191007025046.GL26530@ZenIV.linux.org.uk> <20191008032912.GQ26530@ZenIV.linux.org.uk> <20191010195504.GI26530@ZenIV.linux.org.uk> <20191011001104.GJ26530@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.12.1 (2019-06-15) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Oct 10, 2019 at 05:31:13PM -0700, Linus Torvalds wrote: > So the code actually needs to properly return the error early, or > initialize the segments that didn't get loaded to 0, or something. > > And when I posted that, Luto said "just get rid of the get_user_ex() > entirely, instead of changing semantics of the existing ones to be > sane. > > Which is probably right. There aren't that many. > > I *thought* there were also cases of us doing some questionably things > inside the get_user_try sections, but those seem to have gotten fixed > already independently, so it's really just the "make try/catch really > try/catch" change that needs some editing of our current broken stuff > that depends on it not actually *catching* exceptions, but on just > continuing on to the next one. Umm... TBH, I wonder if we would be better off if restore_sigcontext() (i.e. sigreturn()/rt_sigreturn()) would flat-out copy_from_user() the entire[*] struct sigcontext into a local variable and then copied fields to pt_regs... The thing is small enough for not blowing the stack (256 bytes max. and it's on a shallow stack) and big enough to make "fancy memcpy + let the compiler think how to combine in-kernel copies" potentially better than hardwired sequence of 64bit loads/stores... [*] OK, sans ->reserved part in the very end on 64bit. 192 bytes to copy. Same for do_sys_vm86(), perhaps - we want regs/flags/cpu_type and screen_bitmap there, i.e. the beginning of struct vm86plus_struct and of struct vm86_struct... 24*32bit. IOW, 96-byte memcpy + gcc-visible field-by-field copying vs. hardwired sequence of 32bit loads (with some 16bit ones thrown in, for extra fun) and compiler told not to reorder anything. And these (32bit and 64bit restore_sigcontext() and do_sys_vm86()) are the only get_user_ex() users anywhere...