From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750970AbdL3Vkq (ORCPT ); Sat, 30 Dec 2017 16:40:46 -0500 Received: from s18231873.onlinehome-server.info ([217.160.179.168]:34066 "EHLO godking.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbdL3Vkp (ORCPT ); Sat, 30 Dec 2017 16:40:45 -0500 To: linux-kernel@vger.kernel.org Cc: viro@zeniv.linux.org.uk, torvalds@linuxfoundation.org From: Alexander Kappner Subject: uaccess.h: implement unsafe_copy_{to,from}_user()? Message-ID: <11edd44d-71c5-cf06-65df-1bf67c93f13d@godking.net> Date: Sat, 30 Dec 2017 13:40:40 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 5b24a7a2aa2040c8c50c3b71122901d01661ff78 introduced the unsafe_get_user and unsafe_put_user replacement functions for batched calls to put_user and get_user. I'm trying to make the kernel smaller and reduce stac/clac overhead on x86 by substituting the new functions for such batched calls. But there's no corresponding unsafe_copy_to_user() or unsafe_copy_from_user() functions to copy an arbitrary-sized buffer to and from userspace without calling access_ok and __uaccess_begin/end. I know that the matter of replacing these uaccess functions has been discussed at length (see https://lkml.org/lkml/2017/5/13/134), so before I started hacking away implementing new unsafe_copy_{to,from}_user functions, I wanted to ask if a solution to this is already being worked on or if there's some way of accomplishing this goal without new functions. To illustrate, here's a batched function call (from fs/fat/dir.c): if (put_user(0, d2->d_name) || put_user(0, &d2->d_reclen) || copy_to_user(d1->d_name, name, name_len) || // etc... goto efault; This should read: if (!access_ok(VERIFY_WRITE, d1, 2*sizeof(*infop)) goto efault; user_access_begin(); unsafe_put_user(0, d2->d_name, efault) unsafe_put_user(0, &d2->d_reclen, efault) unsafe_copy_to_user(d1->d_name, name, name_len, efault); // we don't have // this function // etc... user_access_end(); Thanks.