Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6722648ybp; Tue, 15 Oct 2019 20:38:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXEyHzVWF8+Xe0Uy+6T+fAmTmQ9shfDS10Xr1gjKOidzYDFNF3g0558XTChq4a/1IeTMhX X-Received: by 2002:a17:906:27c5:: with SMTP id k5mr37220893ejc.173.1571197093672; Tue, 15 Oct 2019 20:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571197093; cv=none; d=google.com; s=arc-20160816; b=spbvEo7nSA2j/tXLMiGE77EzR/Kr0tZA6Qij5GTDp0Vt0TY9clfQolX/QpIXgmd/CC ZLvC04JsXbf3FsSMQdoZnabozsh9rs2Bi9qx149u3TqHtk9mWAfalmejC/1v8fit4Ik8 icos2m/80r6C6vfo0KpYO46jMcmQGm/TuSsExhU9CPJzPxD6ccbE4a1Bs5FxSmchrout YclFDTmJ7hu4qcQesQpX0Wd7h3FCplSPuLUl0lHR2bPxfL+Aw8BjkJnBxO+NoDVszxjN ClzrkYw24PQxaySHvrz3Xm0j8v7YTM6VjDv1LorAPksU2FGb8adxDfXMRNtCXIwOm3qu yuyg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ayBq8gEZZnaSFU6Pvo26EkUhiaG/djyKJhV0v7/EsPo=; b=Ib/dAOV/7WaIXmWdakz8ilV+G3jnB2WbtV8toWs6V8qTCVnc0MEsXt3FHK5MVqm0Qg OHOW+u+dF2tEIEw3xKJOdLbSa4g2Aghlr1oJQ8SMUNJ8t5E1JiCN+T8xmTHR4r8jfZ7p gr3KjXNQFsfJ+Mhg6W7OIkuGce8TsxceW/AY4O7au8a8hcrchHodzenCiU8MpTu9rOWu mPfEybU34pCW66poPszOAeKhf4Rj+G3kUb9v74aNPiQe5aAl8s72z5/MW2LSPsTveYXa TkhRcJYSTQE2v+5GUjmrg+h/LI9//fo9lmhBVKuCFdwCTawdKc6nMvpK63bCzUk3V2Yj GKLw== 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 c8si17711335edb.82.2019.10.15.20.37.49; Tue, 15 Oct 2019 20:38:13 -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 S1733016AbfJOUSs (ORCPT + 99 others); Tue, 15 Oct 2019 16:18:48 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:39488 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfJOUSs (ORCPT ); Tue, 15 Oct 2019 16:18:48 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iKTHJ-0003KI-98; Tue, 15 Oct 2019 20:18:45 +0000 Date: Tue, 15 Oct 2019 21:18:45 +0100 From: Al Viro To: Linus Torvalds Cc: Guenter Roeck , Linux Kernel Mailing List , linux-fsdevel , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , linux-arch Subject: Re: [PATCH] Convert filldir[64]() from __put_user() to unsafe_put_user() Message-ID: <20191015201845.GP26530@ZenIV.linux.org.uk> References: <20191011001104.GJ26530@ZenIV.linux.org.uk> <20191013181333.GK26530@ZenIV.linux.org.uk> <20191013191050.GL26530@ZenIV.linux.org.uk> <20191013195949.GM26530@ZenIV.linux.org.uk> <20191015180846.GA31707@ZenIV.linux.org.uk> <20191015194012.GO26530@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191015194012.GO26530@ZenIV.linux.org.uk> 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 Tue, Oct 15, 2019 at 08:40:12PM +0100, Al Viro wrote: > or this > static void ntb_memcpy_tx(struct ntb_queue_entry *entry, void __iomem *offset) > { > #ifdef ARCH_HAS_NOCACHE_UACCESS > /* > * Using non-temporal mov to improve performance on non-cached > * writes, even though we aren't actually copying from user space. > */ > __copy_from_user_inatomic_nocache(offset, entry->buf, entry->len); > #else > memcpy_toio(offset, entry->buf, entry->len); > #endif > > /* Ensure that the data is fully copied out before setting the flags */ > wmb(); > > ntb_tx_copy_callback(entry, NULL); > } > "user" part is bollocks in both cases; moreover, I really wonder about that > ifdef in ntb one - ARCH_HAS_NOCACHE_UACCESS is x86-only *at* *the* *moment* > and it just so happens that ..._toio() doesn't require anything special on > x86. Have e.g. arm grow nocache stuff and the things will suddenly break, > won't they? Incidentally, there are two callers of __copy_from_user_inatomic_nocache() in generic code: lib/iov_iter.c:792: __copy_from_user_inatomic_nocache((to += v.iov_len) - v.iov_len, lib/iov_iter.c:849: if (__copy_from_user_inatomic_nocache((to += v.iov_len) - v.iov_len, Neither is done under under pagefault_disable(), AFAICS. This one drivers/gpu/drm/qxl/qxl_ioctl.c:189: unwritten = __copy_from_user_inatomic_nocache probably is - it has something called qxl_bo_kmap_atomic_page() called just prior, which would seem to imply kmap_atomic() somewhere in it. The same goes for drivers/gpu/drm/i915/i915_gem.c:500: unwritten = __copy_from_user_inatomic_nocache((void __force *)vaddr + offset, So we have?5 callers anywhere. Two are not "inatomic" in any sense; source is in userspace and we want nocache behaviour. Two _are_ done into a page that had been fed through kmap_atomic(); the source is, again, in userland. And the last one is complete BS - it wants memcpy_toio_nocache() and abuses this thing. Incidentally, in case of fault i915 caller ends up unmapping the page, mapping it non-atomic (with kmap?) and doing plain copy_from_user(), nocache be damned. qxl, OTOH, whines and fails all the way to userland...