Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3650995ybp; Sun, 13 Oct 2019 11:15:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyI2msylCBCffPnwfrn1xO+n2qN3bCCbyQe28d3smOGN8GDdxPXjlTp+um/YcjEz8SfZJA7 X-Received: by 2002:a05:6402:3c5:: with SMTP id t5mr24096061edw.125.1570990517520; Sun, 13 Oct 2019 11:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570990517; cv=none; d=google.com; s=arc-20160816; b=BluAc6mYfo0lqsXWo2YmYT5+XO2QSYxbw+5/DeMSYhoS6iC02qF+yQw7jXkmIZL9p5 91e+YyNUaKdi2Gt9fgB7J1AP2rqFPwFEUBvDU1TPNlAb4pcTG82TNm3eEvgPUYW80Yr2 BO0ADa0nKiO6D/4fB8cXeNmCLYkeKSmx7XIpR7aCBHa/4oCGxXSpMLtIBu0HLsRGwAsW PeVLV6ityWOJBB0xTaAnISwDY2Ci7aZHOK0C4ZNyN6K+L4t7/TzxDuQAVIe1QZNXHEeF 3Cf8mGDeS7J72gMtL6wMqWRlId21TWRgnJt/Y5K5rmyYRUqBKms1ryOjw+6I7to7ev3J zKbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PWgANr6otZbCxUcVbc9nWJfI6IU2Zw7wd3KIq7ItY9o=; b=WKl8++Ai7ZJtegh9w5fJ899WmSPJtBuWJqinlRItTmKrzKHPhY7lEH+QAYXGS00DXU Qw97qyPl1nB787HeAkZlWe8mtR9gBTuhuRstm7G6Y6PRcw5gSpNZ2LQBnRH9U6nu6AFz 79Z0J4frqNvlxN/IxUsYlCQAgXG6OzIY+n8gokXCjICoXlwFBZ+JTg5UC0LEJvbC52tv mg8Bu68NpIOHqmR4WYk59rwlk2s+WJ4iJnWhmdOJMA1MbSd2NIaM8jAeshlGggO3zRE2 cAm4hm41jgeLs0TNZ1ySUG2qH3iAyJ/Y5U1E4j2On4RJ12T5CJ0+Dpmcuy6z082Obw7t J+gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si10733930edj.220.2019.10.13.11.14.53; Sun, 13 Oct 2019 11:15:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729002AbfJMSNi (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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...