Re: [PATCH 1/4] firmware: add firmware signing

From: Alan Cox
Date: Tue May 30 2017 - 12:09:37 EST


On Fri, 2017-05-26 at 12:06 +0900, AKASHI Takahiro wrote:
> There is one driver data option, DRIVER_DATA_REQ_NO_SIG_CHECK,
> which will skip signature verification check at load time
> even in enforcing mode.
> This option is solely for non security-sensitive data.

It's also for firmware that is already signed and checked by the
hardware. In the x86 world almost all modern era firmware is already
signed and the signature checked by the device.

> +static ssize_t firmware_sig_data_write(struct file *filp, struct
> kobject *kobj,
> + ÂÂÂÂÂÂÂstruct bin_attribute
> *bin_attr,
> + ÂÂÂÂÂÂÂchar *buffer, loff_t offset,
> + ÂÂÂÂÂÂÂsize_t count)
> +{
> + struct device *dev = kobj_to_dev(kobj);
> + struct firmware_priv *fw_priv = to_firmware_priv(dev);
> + struct firmware_buf *buf;
> + void *buf_tmp;
> + size_t new_size;
> + ssize_t ret_count;
> +
> + if (!capable(CAP_SYS_RAWIO))
> + return -EPERM;
> +
> + mutex_lock(&fw_lock);
> + buf = fw_priv->buf;
> + if (!buf || fw_state_is_done(&buf->fw_st)) {
> + ret_count = -ENODEV;
> + goto out;
> + }
> +
> + if (buf->sig_data && (offset + count > buf->sig_size)) {

If I do a ridiculously long amount of I/O what stops offset + count
overflowing ? It's no big deal as its CAP_SYS_RAWIO anyway but I'm just
wondering if there is a test missing ?

Alan