<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/platform/chrome/cros_ec_dev.c, branch linux-4.9.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>platform/chrome: cros_ec_dev - double fetch bug in ioctl</title>
<updated>2016-07-05T21:01:52+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2016-06-21T13:58:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=096cdc6f52225835ff503f987a0d68ef770bb78e'/>
<id>096cdc6f52225835ff503f987a0d68ef770bb78e</id>
<content type='text'>
We verify "u_cmd.outsize" and "u_cmd.insize" but we need to make sure
that those values have not changed between the two copy_from_user()
calls.  Otherwise it could lead to a buffer overflow.

Additionally, cros_ec_cmd_xfer() can set s_cmd-&gt;insize to a lower value.
We should use the new smaller value so we don't copy too much data to
the user.

Reported-by: Pengfei Wang &lt;wpengfeinudt@gmail.com&gt;
Fixes: a841178445bb ('mfd: cros_ec: Use a zero-length array for command data')
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Tested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Cc: &lt;stable@vger.kernel.org&gt; # v4.2+
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We verify "u_cmd.outsize" and "u_cmd.insize" but we need to make sure
that those values have not changed between the two copy_from_user()
calls.  Otherwise it could lead to a buffer overflow.

Additionally, cros_ec_cmd_xfer() can set s_cmd-&gt;insize to a lower value.
We should use the new smaller value so we don't copy too much data to
the user.

Reported-by: Pengfei Wang &lt;wpengfeinudt@gmail.com&gt;
Fixes: a841178445bb ('mfd: cros_ec: Use a zero-length array for command data')
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Tested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Cc: &lt;stable@vger.kernel.org&gt; # v4.2+
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: cros_ec_dev - Populate compat_ioctl</title>
<updated>2016-05-11T18:55:48+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-04-15T02:35:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2521ea3e0d1b285cea371a38772d3eefa0490c71'/>
<id>2521ea3e0d1b285cea371a38772d3eefa0490c71</id>
<content type='text'>
compat_ioctl has to be populated for 32 bit userspace applications to work
with 64 bit kernels.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Tested-by: Brian Norris &lt;briannorris@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
compat_ioctl has to be populated for 32 bit userspace applications to work
with 64 bit kernels.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Tested-by: Brian Norris &lt;briannorris@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: cros_ec_dev - Fix security issue</title>
<updated>2016-05-11T18:55:47+00:00</updated>
<author>
<name>Gwendal Grignou</name>
<email>gwendal@chromium.org</email>
</author>
<published>2016-03-08T17:13:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5d749d0bbe811c10d9048cde6dfebc761713abfd'/>
<id>5d749d0bbe811c10d9048cde6dfebc761713abfd</id>
<content type='text'>
Prevent memory scribble by checking that ioctl buffer size parameters
are sane.
Without this check, on 32 bits system, if .insize = 0xffffffff - 20 and
.outsize the amount to scribble, we would overflow, allocate a small
amounts and be able to write outside of the malloc'ed area.
Adding a hard limit allows argument checking of the ioctl. With the
current EC, it is expected .insize and .outsize to be at around 512 bytes
or less.

Signed-off-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Prevent memory scribble by checking that ioctl buffer size parameters
are sane.
Without this check, on 32 bits system, if .insize = 0xffffffff - 20 and
.outsize the amount to scribble, we would overflow, allocate a small
amounts and be able to write outside of the malloc'ed area.
Adding a hard limit allows argument checking of the ioctl. With the
current EC, it is expected .insize and .outsize to be at around 512 bytes
or less.

Signed-off-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: Support reading/writing the vboot context</title>
<updated>2015-10-07T22:05:53+00:00</updated>
<author>
<name>Emilio López</name>
<email>emilio.lopez@collabora.co.uk</email>
</author>
<published>2015-09-21T13:38:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=18800fc7a04e7df8a345e7ef4fc3064368276f83'/>
<id>18800fc7a04e7df8a345e7ef4fc3064368276f83</id>
<content type='text'>
Some EC implementations include a small nvram space used to store
verified boot context data. This patch offers a way to expose this
data to userspace.

Reviewed-by: Javier Martinez Canillas &lt;javier@osg.samsung.com&gt;
Signed-off-by: Emilio López &lt;emilio.lopez@collabora.co.uk&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Some EC implementations include a small nvram space used to store
verified boot context data. This patch offers a way to expose this
data to userspace.

Reviewed-by: Javier Martinez Canillas &lt;javier@osg.samsung.com&gt;
Signed-off-by: Emilio López &lt;emilio.lopez@collabora.co.uk&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: cros_ec_dev - Add a platform device ID table</title>
<updated>2015-10-07T21:34:26+00:00</updated>
<author>
<name>Javier Martinez Canillas</name>
<email>javier.martinez@collabora.co.uk</email>
</author>
<published>2015-06-22T06:27:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=afbf8ec7c4f90ddd3ee8655c591983fb9d399f43'/>
<id>afbf8ec7c4f90ddd3ee8655c591983fb9d399f43</id>
<content type='text'>
If the cros_ec_dev driver is built as a module, modalias information is
not filled so the module is not autoloaded. Add a platform device table
and use the MODULE_DEVICE_TABLE() macro to export that information in
the module so user-space can match the modalias uevent and autoload it.

Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the cros_ec_dev driver is built as a module, modalias information is
not filled so the module is not autoloaded. Add a platform device table
and use the MODULE_DEVICE_TABLE() macro to export that information in
the module so user-space can match the modalias uevent and autoload it.

Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mfd: cros_ec: Support multiple EC in a system</title>
<updated>2015-06-15T12:18:23+00:00</updated>
<author>
<name>Gwendal Grignou</name>
<email>gwendal@chromium.org</email>
</author>
<published>2015-06-09T11:04:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=57b33ff077beebb68481a2b6b8e5fe58ca998169'/>
<id>57b33ff077beebb68481a2b6b8e5fe58ca998169</id>
<content type='text'>
Chromebooks can have more than one Embedded Controller so the
cros_ec device id has to be incremented for each EC registered.

Add a new structure to represent multiple EC as different char
devices (e.g: /dev/cros_ec, /dev/cros_pd). It connects to
cros_ec_device and allows sysfs inferface for cros_pd.

Also reduce number of allocated objects, make chromeos sysfs
class object a static and add refcounting to prevent object
deletion while command is in progress.

Signed-off-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Reviewed-by: Dmitry Torokhov &lt;dtor@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Heiko Stuebner &lt;heiko@sntech.de&gt;
Acked-by: Lee Jones &lt;lee.jones@linaro.org&gt;
Acked-by: Olof Johansson &lt;olof@lixom.net&gt;
Signed-off-by: Lee Jones &lt;lee.jones@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Chromebooks can have more than one Embedded Controller so the
cros_ec device id has to be incremented for each EC registered.

Add a new structure to represent multiple EC as different char
devices (e.g: /dev/cros_ec, /dev/cros_pd). It connects to
cros_ec_device and allows sysfs inferface for cros_pd.

Also reduce number of allocated objects, make chromeos sysfs
class object a static and add refcounting to prevent object
deletion while command is in progress.

Signed-off-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Reviewed-by: Dmitry Torokhov &lt;dtor@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Heiko Stuebner &lt;heiko@sntech.de&gt;
Acked-by: Lee Jones &lt;lee.jones@linaro.org&gt;
Acked-by: Olof Johansson &lt;olof@lixom.net&gt;
Signed-off-by: Lee Jones &lt;lee.jones@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mfd: cros_ec: Use a zero-length array for command data</title>
<updated>2015-06-15T12:18:19+00:00</updated>
<author>
<name>Javier Martinez Canillas</name>
<email>javier.martinez@collabora.co.uk</email>
</author>
<published>2015-06-09T11:04:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a841178445bb72a3d566b4e6ab9d19e9b002eb47'/>
<id>a841178445bb72a3d566b4e6ab9d19e9b002eb47</id>
<content type='text'>
Commit 1b84f2a4cd4a ("mfd: cros_ec: Use fixed size arrays to transfer
data with the EC") modified the struct cros_ec_command fields to not
use pointers for the input and output buffers and use fixed length
arrays instead.

This change was made because the cros_ec ioctl API uses that struct
cros_ec_command to allow user-space to send commands to the EC and
to get data from the EC. So using pointers made the API not 64-bit
safe. Unfortunately this approach was not flexible enough for all
the use-cases since there may be a need to send larger commands
on newer versions of the EC command protocol.

So to avoid to choose a constant length that it may be too big for
most commands and thus wasting memory and CPU cycles on copy from
and to user-space or having a size that is too small for some big
commands, use a zero-length array that is both 64-bit safe and
flexible. The same buffer is used for both output and input data
so the maximum of these values should be used to allocate it.

Suggested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Heiko Stuebner &lt;heiko@sntech.de&gt;
Acked-by: Lee Jones &lt;lee.jones@linaro.org&gt;
Acked-by: Olof Johansson &lt;olof@lixom.net&gt;
Signed-off-by: Lee Jones &lt;lee.jones@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit 1b84f2a4cd4a ("mfd: cros_ec: Use fixed size arrays to transfer
data with the EC") modified the struct cros_ec_command fields to not
use pointers for the input and output buffers and use fixed length
arrays instead.

This change was made because the cros_ec ioctl API uses that struct
cros_ec_command to allow user-space to send commands to the EC and
to get data from the EC. So using pointers made the API not 64-bit
safe. Unfortunately this approach was not flexible enough for all
the use-cases since there may be a need to send larger commands
on newer versions of the EC command protocol.

So to avoid to choose a constant length that it may be too big for
most commands and thus wasting memory and CPU cycles on copy from
and to user-space or having a size that is too small for some big
commands, use a zero-length array that is both 64-bit safe and
flexible. The same buffer is used for both output and input data
so the maximum of these values should be used to allocate it.

Suggested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Heiko Stuebner &lt;heiko@sntech.de&gt;
Acked-by: Lee Jones &lt;lee.jones@linaro.org&gt;
Acked-by: Olof Johansson &lt;olof@lixom.net&gt;
Signed-off-by: Lee Jones &lt;lee.jones@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: cros_ec_dev - fix Unknown escape '%' warning</title>
<updated>2015-03-04T19:23:10+00:00</updated>
<author>
<name>Olof Johansson</name>
<email>olofj@chromium.org</email>
</author>
<published>2015-03-03T12:22:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ef59c25d1be9539890c03c4915cdd4b868191b6f'/>
<id>ef59c25d1be9539890c03c4915cdd4b868191b6f</id>
<content type='text'>
Fix the following sparse warning:

    drivers/platform/chrome/cros_ec_dev.c:64:45: sparse: Unknown escape '%'

Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Olof Johansson &lt;olofj@chromium.org&gt;
Reviewed-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix the following sparse warning:

    drivers/platform/chrome/cros_ec_dev.c:64:45: sparse: Unknown escape '%'

Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Olof Johansson &lt;olofj@chromium.org&gt;
Reviewed-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: Expose Chrome OS Lightbar to users</title>
<updated>2015-02-26T23:45:16+00:00</updated>
<author>
<name>Bill Richardson</name>
<email>wfrichar@chromium.org</email>
</author>
<published>2015-02-02T11:26:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=f3f837e52b14bf84c2db65f622b5c31cd261100c'/>
<id>f3f837e52b14bf84c2db65f622b5c31cd261100c</id>
<content type='text'>
This adds some sysfs entries to provide userspace control of the
four-element LED "lightbar" on the Chromebook Pixel. This only instantiates
the lightbar controls if the device actually exists.

To prevent DoS attacks, this interface is limited to 20 accesses/second,
although that rate can be adjusted by a privileged user.

On Chromebooks without a lightbar, this should have no effect. On the
Chromebook Pixel, you should be able to do things like this:

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo 0x80 &gt; brightness
    $ echo 255 &gt; brightness
    $
    $ cat sequence
    S0
    $ echo konami &gt; sequence
    $ cat sequence
    KONAMI
    $
    $ cat sequence
    S0

And

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo stop &gt; sequence
    $ echo "4 255 255 255" &gt; led_rgb
    $ echo "0 255 0 0  1 0 255 0  2 0 0 255  3 255 255 0" &gt; led_rgb
    $ echo run  &gt; sequence

Test the DoS prevention with this:

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo 500 &gt; interval_msec
    $ time (cat version version version version version version version)

Signed-off-by: Bill Richardson &lt;wfrichar@chromium.org&gt;
Reviewed-by: Olof Johansson &lt;olofj@chromium.org&gt;
Tested-by: Doug Anderson &lt;dianders@chromium.org&gt;
Reviewed-by: Benson Leung &lt;bleung@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Reviewed-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds some sysfs entries to provide userspace control of the
four-element LED "lightbar" on the Chromebook Pixel. This only instantiates
the lightbar controls if the device actually exists.

To prevent DoS attacks, this interface is limited to 20 accesses/second,
although that rate can be adjusted by a privileged user.

On Chromebooks without a lightbar, this should have no effect. On the
Chromebook Pixel, you should be able to do things like this:

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo 0x80 &gt; brightness
    $ echo 255 &gt; brightness
    $
    $ cat sequence
    S0
    $ echo konami &gt; sequence
    $ cat sequence
    KONAMI
    $
    $ cat sequence
    S0

And

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo stop &gt; sequence
    $ echo "4 255 255 255" &gt; led_rgb
    $ echo "0 255 0 0  1 0 255 0  2 0 0 255  3 255 255 0" &gt; led_rgb
    $ echo run  &gt; sequence

Test the DoS prevention with this:

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo 500 &gt; interval_msec
    $ time (cat version version version version version version version)

Signed-off-by: Bill Richardson &lt;wfrichar@chromium.org&gt;
Reviewed-by: Olof Johansson &lt;olofj@chromium.org&gt;
Tested-by: Doug Anderson &lt;dianders@chromium.org&gt;
Reviewed-by: Benson Leung &lt;bleung@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Reviewed-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>platform/chrome: Create sysfs attributes for the ChromeOS EC</title>
<updated>2015-02-26T23:45:12+00:00</updated>
<author>
<name>Bill Richardson</name>
<email>wfrichar@chromium.org</email>
</author>
<published>2015-02-02T11:26:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=71af4b52cc22a8d0f7b66a51427a804741a045b6'/>
<id>71af4b52cc22a8d0f7b66a51427a804741a045b6</id>
<content type='text'>
This adds the first few sysfs attributes for the Chrome OS EC. These
controls are made available under /sys/devices/virtual/chromeos/cros_ec

    flashinfo   - display current flash info
    reboot      - tell the EC to reboot in various ways
    version     - information about the EC software and hardware

Future changes will build on this to add additional controls.

From a root shell, you should be able to do things like this:

    cd /sys/devices/virtual/chromeos/cros_ec
    cat flashinfo
    cat version
    echo rw &gt; reboot
    cat version
    echo ro &gt; reboot
    cat version
    echo rw &gt; reboot
    cat version
    echo cold &gt; reboot

That last command will reboot the AP too.

Signed-off-by: Bill Richardson &lt;wfrichar@chromium.org&gt;
Reviewed-by: Olof Johansson &lt;olofj@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Reviewed-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds the first few sysfs attributes for the Chrome OS EC. These
controls are made available under /sys/devices/virtual/chromeos/cros_ec

    flashinfo   - display current flash info
    reboot      - tell the EC to reboot in various ways
    version     - information about the EC software and hardware

Future changes will build on this to add additional controls.

From a root shell, you should be able to do things like this:

    cd /sys/devices/virtual/chromeos/cros_ec
    cat flashinfo
    cat version
    echo rw &gt; reboot
    cat version
    echo ro &gt; reboot
    cat version
    echo rw &gt; reboot
    cat version
    echo cold &gt; reboot

That last command will reboot the AP too.

Signed-off-by: Bill Richardson &lt;wfrichar@chromium.org&gt;
Reviewed-by: Olof Johansson &lt;olofj@chromium.org&gt;
Signed-off-by: Javier Martinez Canillas &lt;javier.martinez@collabora.co.uk&gt;
Tested-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Reviewed-by: Gwendal Grignou &lt;gwendal@chromium.org&gt;
Signed-off-by: Olof Johansson &lt;olof@lixom.net&gt;
</pre>
</div>
</content>
</entry>
</feed>
