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 E0BC7C10F14 for ; Thu, 10 Oct 2019 19:55:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB48021835 for ; Thu, 10 Oct 2019 19:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbfJJTzI (ORCPT ); Thu, 10 Oct 2019 15:55:08 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:40740 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbfJJTzI (ORCPT ); Thu, 10 Oct 2019 15:55:08 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iIeWe-00034C-H8; Thu, 10 Oct 2019 19:55:05 +0000 Date: Thu, 10 Oct 2019 20:55:04 +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: <20191010195504.GI26530@ZenIV.linux.org.uk> References: <5f06c138-d59a-d811-c886-9e73ce51924c@roeck-us.net> <20191007012437.GK26530@ZenIV.linux.org.uk> <20191007025046.GL26530@ZenIV.linux.org.uk> <20191008032912.GQ26530@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 Mon, Oct 07, 2019 at 09:24:17PM -0700, Linus Torvalds wrote: > On Mon, Oct 7, 2019 at 9:09 PM Linus Torvalds > wrote: > > > > Try the attached patch, and then count the number of "rorx" > > instructions in the kernel. Hint: not many. On my personal config, > > this triggers 15 times in the whole kernel build (not counting > > modules). > > .. and four of them are in perf_callchain_user(), and are due to those > "__copy_from_user_nmi()" with either 4-byte or 8-byte copies. > > It might as well just use __get_user() instead. > > The point being that the silly code in the header files is just > pointless. We shouldn't do it. FWIW, the one that looks the most potentiall sensitive in that bunch is arch/x86/kvm/paging_tmpl.h:388: if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte)))) in the bowels of KVM page fault handling. I would be very surprised if the rest would be detectable... Anyway, another question you way: what do you think of try/catch approaches to __get_user() blocks, like e.g. restore_sigcontext() is doing? Should that be available outside of arch/*? For that matter, would it be a good idea to convert get_user_ex() users in arch/x86 to unsafe_get_user()?