[PATCH 1/2] vt: selection: allow functions to be called from inside kernel

Okash Khawaja okash.khawaja at gmail.com
Tue Apr 16 10:54:02 EDT 2019


On Tue, 16 Apr 2019, 12:49 Greg Kroah-Hartman, <gregkh at linuxfoundation.org>
wrote:

> On Thu, Apr 04, 2019 at 08:45:29PM +0100, Okash Khawaja wrote:
> > This patch breaks set_selection() into two functions so that when
> > called from kernel, copy_from_user() can be avoided. It also exports
> > set_selection() and paste_selection().
> >
> > These changes are used the following patch where speakup's selection
> > functionality calls into the above functions, thereby doing away with
> > parallel implementation.
> >
> > Signed-off-by: Okash Khawaja <okash.khawaja at gmail.com>
> > Reviewed-by: Samuel Thibault <samuel.thibault at ens-lyon.org>
> > Tested-by: Gregory Nowak <greg at gregn.net>
> > ---
> >  drivers/tty/vt/selection.c | 37 ++++++++++++++++++++++++-------------
> >  include/linux/selection.h  |  3 +--
> >  2 files changed, 25 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
> > index 07496c711d7d..a43f9cd9bdd6 100644
> > --- a/drivers/tty/vt/selection.c
> > +++ b/drivers/tty/vt/selection.c
> > @@ -80,6 +80,7 @@ void clear_selection(void)
> >               sel_start = -1;
> >       }
> >  }
> > +EXPORT_SYMBOL_GPL(clear_selection);
> >
> >  /*
> >   * User settable table: what characters are to be considered alphabetic?
> > @@ -164,34 +165,42 @@ static int store_utf8(u32 c, char *p)
> >   *    a lot under the lock but its hardly a performance path
> >   */
> >  int set_selection(const struct tiocl_selection __user *sel, struct
> tty_struct *tty)
> > +{
> > +     struct tiocl_selection v;
> > +
> > +     if (copy_from_user(&v, sel, sizeof(*sel)))
> > +             return -EFAULT;
> > +
> > +     return do_set_selection(&v, tty);
> > +}
> > +
> > +int do_set_selection(struct tiocl_selection *v, struct tty_struct *tty)
>
> I have no idea what the difference is between set_selection() and
> do_set_selection() is now.  Naming is hard, I know :(
>
> How about set_selection_kernel()?  set_selection_tiocl()?
>
> Something to show that one takes a userspace pointer, and the other a
> kernel pointer, how about:
>         set_selection_user()
>         set_selection_kernel()
> making it more obvious?
>

Hi,

I see. set_selection_{user,kernel}() seem clearer to me.

Thanks,
Okash


More information about the Speakup mailing list