svn commit: r344984 - in stable/11: sbin/sysctl sys/dev/evdev

Konstantin Belousov kostikbel at gmail.com
Sun Mar 10 21:22:15 UTC 2019


On Sun, Mar 10, 2019 at 08:58:24PM +0000, Vladimir Kondratyev wrote:
> Author: wulf
> Date: Sun Mar 10 20:58:24 2019
> New Revision: 344984
> URL: https://svnweb.freebsd.org/changeset/base/344984
> 
> Log:
>   MFC r344494,r344495:
>   
>   evdev: export event device properties through sysctl interface
>   
>   A big security advantage of Wayland is not allowing applications to read
>   input devices all the time. Having /dev/input/* accessible to the user
>   account subverts this advantage.
>   
>   libudev-devd was opening the evdev devices to detect their types (mouse,
>   keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible.
>   With the kernel exposing this information as sysctls (kern.evdev.input.*),
>   we can work w/o /dev/input/* access, preserving the Wayland security model.
>   
>   Submitted by:	Greg V <greg at unrelenting.technology>
>   Reviewed by:	wulf, imp
>   Differential Revision:	https://reviews.freebsd.org/D18694
> 
> Modified:
>   stable/11/sbin/sysctl/sysctl.c
>   stable/11/sys/dev/evdev/evdev.c
>   stable/11/sys/dev/evdev/evdev_private.h
> Directory Properties:
>   stable/11/   (props changed)
> 
> Modified: stable/11/sbin/sysctl/sysctl.c
> ==============================================================================
> --- stable/11/sbin/sysctl/sysctl.c	Sun Mar 10 20:43:08 2019	(r344983)
> +++ stable/11/sbin/sysctl/sysctl.c	Sun Mar 10 20:58:24 2019	(r344984)
> @@ -47,6 +47,7 @@ static const char rcsid[] =
>  #include <sys/stat.h>
>  #include <sys/sysctl.h>
>  #include <sys/vmmeter.h>
> +#include <dev/evdev/input.h>
>  
>  #ifdef __amd64__
>  #include <sys/efi.h>
> @@ -678,6 +679,22 @@ S_vmtotal(size_t l2, void *p)
>  	return (0);
>  }
>  
> +static int
> +S_input_id(size_t l2, void *p)
> +{
> +	struct input_id *id = p;
> +
> +	if (l2 != sizeof(*id)) {
> +		warnx("S_input_id %zu != %zu", l2, sizeof(*id));
> +		return (1);
> +	}
> +
> +	printf("{ bustype = 0x%04x, vendor = 0x%04x, "
> +	    "product = 0x%04x, version = 0x%04x }",
> +	    id->bustype, id->vendor, id->product, id->version);
> +	return (0);
> +}
> +
>  #ifdef __amd64__
>  static int
>  S_efi_map(size_t l2, void *p)
> @@ -1097,6 +1114,8 @@ show_var(int *oid, int nlen)
>  			func = S_loadavg;
>  		else if (strcmp(fmt, "S,vmtotal") == 0)
>  			func = S_vmtotal;
> +		else if (strcmp(fmt, "S,input_id") == 0)
> +			func = S_input_id;
>  #ifdef __amd64__
>  		else if (strcmp(fmt, "S,efi_map_header") == 0)
>  			func = S_efi_map;
> 
> Modified: stable/11/sys/dev/evdev/evdev.c
> ==============================================================================
> --- stable/11/sys/dev/evdev/evdev.c	Sun Mar 10 20:43:08 2019	(r344983)
> +++ stable/11/sys/dev/evdev/evdev.c	Sun Mar 10 20:58:24 2019	(r344984)
> @@ -67,14 +67,16 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory");
>  int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX;
>  int evdev_sysmouse_t_axis = 0;
>  
> -#ifdef EVDEV_SUPPORT
>  SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args");
> +#ifdef EVDEV_SUPPORT
>  SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0,
>      "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, "
>      "bit2 - mouse hardware, bit3 - keyboard hardware");
>  SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW,
>      &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm");
>  #endif
> +SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0,
> +    "Evdev input devices");
>  
>  static void evdev_start_repeat(struct evdev_dev *, uint16_t);
>  static void evdev_stop_repeat(struct evdev_dev *);
> @@ -194,6 +196,87 @@ evdev_estimate_report_size(struct evdev_dev *evdev)
>  	return (size);
>  }
>  
> +static void
> +evdev_sysctl_create(struct evdev_dev *evdev)
> +{
> +	struct sysctl_oid *ev_sysctl_tree;
> +	char ev_unit_str[8];
> +
> +	snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit);
> +	sysctl_ctx_init(&evdev->ev_sysctl_ctx);
> +
> +	ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx,
> +	    SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO,
> +	    ev_unit_str, CTLFLAG_RD, NULL, "", "device index");
This change depends on r310051 which was not merged to stable/11.



More information about the svn-src-all mailing list