mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Kappner <agk@godking.net>
To: linux-kernel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, torvalds@linuxfoundation.org
Subject: uaccess.h: implement unsafe_copy_{to,from}_user()?
Date: Sat, 30 Dec 2017 13:40:40 -0800	[thread overview]
Message-ID: <11edd44d-71c5-cf06-65df-1bf67c93f13d@godking.net> (raw)

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.

                 reply	other threads:[~2017-12-30 21:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11edd44d-71c5-cf06-65df-1bf67c93f13d@godking.net \
    --to=agk@godking.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linuxfoundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®