Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4584436ybp; Mon, 7 Oct 2019 10:35:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlJTlHftPmfOyIDuW/a3Fv7flCSb+gUKFFbdtXjKnphXL9S4T1PU6ReNO2+mk1y/yizrot X-Received: by 2002:a17:906:ecf9:: with SMTP id qt25mr23820597ejb.249.1570469708537; Mon, 07 Oct 2019 10:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570469708; cv=none; d=google.com; s=arc-20160816; b=d5JgMSo4l40/hTylaE2aE9uGqbt4RQauUif9j9PviNzgOkbHSIl/NMjGMY4B0SM7mg cQUM3yIWIrrSKuCpYWlztXdmNoUeqxardsEF0a3gAkKN2I3E4j3ruxTtCedMgt/LTdrX VpQgvJJ0p2tkxvhdtIO0x3s/oIh/nxDIBZ1ioj1IaSZFCm4rJUKgoOALoV4OdddVJu94 +rrFpnXZ5+IeR6yDIuI8NZOkKDCXrP2P/t28UYHMItunzpcE242QJn8xW3Xi78zfcfit KM3XG15L9EX68cUinFh8b6cRXxdBm5/l7NZJS0XbpRHd3FwkUEBhEB+1PgtkhlB2Kpoo MC9Q== 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=+E5UaN/a+PFituBRz/dDKEnbk6D7VxyNrecMxzu4JQg=; b=dfY7025OYrTsEJ34wk2Afph+Tzk9QJUaUSq66giuyTGmE6uuZ61h6xiUqqz86RB64P rBqr/C8Y3BCD0AemHlliWCX26o8HJZtiors+KvOjT+iZ3ru9+e40AUV0zetWTcqbJnOe BRomYiy8mgVLDYPrpB6yCce+Lf7+9aGJIV52UTyoo79bWSADDxBOUUW+7FsFq+leH5s3 9Ykj+dHdKxcY9v+InAXp9ycdwSiUEIJjP0rybeYds7I3e6T81vzAoIaj0DJHZwqdJKKu KZYT4uGCcYnpstkwpNN7xvOKNumaTIxoA9EgJsLOLNljGOU3gAsp/wmYMucgax7bUA5t HnHA== 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 h48si8678581ede.31.2019.10.07.10.34.45; Mon, 07 Oct 2019 10:35:08 -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 S1729032AbfJGRee (ORCPT + 99 others); Mon, 7 Oct 2019 13:34:34 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:43124 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728028AbfJGRee (ORCPT ); Mon, 7 Oct 2019 13:34:34 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHWu0-00027U-DO; Mon, 07 Oct 2019 17:34:32 +0000 Date: Mon, 7 Oct 2019 18:34:32 +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: <20191007173432.GM26530@ZenIV.linux.org.uk> References: <20191006222046.GA18027@roeck-us.net> <5f06c138-d59a-d811-c886-9e73ce51924c@roeck-us.net> <20191007012437.GK26530@ZenIV.linux.org.uk> <20191007025046.GL26530@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 Sun, Oct 06, 2019 at 08:11:42PM -0700, Linus Torvalds wrote: > > So do we want to bother with separation between raw_copy_to_user() and > > unsafe_copy_to_user()? After all, __copy_to_user() also has only few > > callers, most of them in arch/* > > No, you're right. Just switch over. > > > I'll take a look into that tomorrow - half-asleep right now... > > Thanks. No huge hurry. Tangentially related: copy_regster_to_user() and copy_regset_from_user(). That's where we do access_ok(), followed by calls of ->get() and ->set() resp. Those tend to either use user_regset_copy{out,in}(), or open-code those. The former variant tends to lead to few calls of __copy_{to,from}_user(); the latter... On x86 it ends up doing this: static int genregs_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { if (kbuf) { unsigned long *k = kbuf; while (count >= sizeof(*k)) { *k++ = getreg(target, pos); count -= sizeof(*k); pos += sizeof(*k); } } else { unsigned long __user *u = ubuf; while (count >= sizeof(*u)) { if (__put_user(getreg(target, pos), u++)) return -EFAULT; count -= sizeof(*u); pos += sizeof(*u); } } return 0; } Potentially doing arseloads of stac/clac as it goes. OTOH, getreg() (and setreg()) in there are not entirely trivial, so blanket user_access_begin()/user_access_end() over the entire loop might be a bad idea... How hot is that codepath? I know that arch/um used to rely on it (== PTRACE_[GS]ETREGS) quite a bit...