Skip to content

Commit f469cf9

Browse files
committed
Merge tag 'char-misc-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char / misc driver fixes from Greg KH: "Here are some small remaining driver fixes for 6.10-final that have all been in linux-next for a while and resolve reported issues. Included in here are: - mei driver fixes (and a spelling fix at the end just to be clean) - iio driver fixes for reported problems - fastrpc bugfixes - nvmem small fixes" * tag 'char-misc-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: mei: vsc: Fix spelling error mei: vsc: Enhance SPI transfer of IVSC ROM mei: vsc: Utilize the appropriate byte order swap function mei: vsc: Prevent timeout error with added delay post-firmware download mei: vsc: Enhance IVSC chipset stability during warm reboot nvmem: core: limit cell sysfs permissions to main attribute ones nvmem: core: only change name to fram for current attribute nvmem: meson-efuse: Fix return value of nvmem callbacks nvmem: rmem: Fix return value of rmem_read() misc: microchip: pci1xxxx: Fix return value of nvmem callbacks hpet: Support 32-bit userspace misc: fastrpc: Restrict untrusted app to attach to privileged PD misc: fastrpc: Fix ownership reassignment of remote heap misc: fastrpc: Fix memory leak in audio daemon attach operation misc: fastrpc: Avoid updating PD type for capability request misc: fastrpc: Copy the complete capability structure to user misc: fastrpc: Fix DSP capabilities request iio: light: apds9306: Fix error handing iio: trigger: Fix condition for own trigger
2 parents 1cb67bc + 389637d commit f469cf9

File tree

12 files changed

+103
-35
lines changed

12 files changed

+103
-35
lines changed

drivers/char/hpet.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,13 @@ hpet_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
269269
if (!devp->hd_ireqfreq)
270270
return -EIO;
271271

272-
if (count < sizeof(unsigned long))
273-
return -EINVAL;
272+
if (in_compat_syscall()) {
273+
if (count < sizeof(compat_ulong_t))
274+
return -EINVAL;
275+
} else {
276+
if (count < sizeof(unsigned long))
277+
return -EINVAL;
278+
}
274279

275280
add_wait_queue(&devp->hd_waitqueue, &wait);
276281

@@ -294,9 +299,16 @@ hpet_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
294299
schedule();
295300
}
296301

297-
retval = put_user(data, (unsigned long __user *)buf);
298-
if (!retval)
299-
retval = sizeof(unsigned long);
302+
if (in_compat_syscall()) {
303+
retval = put_user(data, (compat_ulong_t __user *)buf);
304+
if (!retval)
305+
retval = sizeof(compat_ulong_t);
306+
} else {
307+
retval = put_user(data, (unsigned long __user *)buf);
308+
if (!retval)
309+
retval = sizeof(unsigned long);
310+
}
311+
300312
out:
301313
__set_current_state(TASK_RUNNING);
302314
remove_wait_queue(&devp->hd_waitqueue, &wait);
@@ -651,12 +663,24 @@ struct compat_hpet_info {
651663
unsigned short hi_timer;
652664
};
653665

666+
/* 32-bit types would lead to different command codes which should be
667+
* translated into 64-bit ones before passed to hpet_ioctl_common
668+
*/
669+
#define COMPAT_HPET_INFO _IOR('h', 0x03, struct compat_hpet_info)
670+
#define COMPAT_HPET_IRQFREQ _IOW('h', 0x6, compat_ulong_t)
671+
654672
static long
655673
hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
656674
{
657675
struct hpet_info info;
658676
int err;
659677

678+
if (cmd == COMPAT_HPET_INFO)
679+
cmd = HPET_INFO;
680+
681+
if (cmd == COMPAT_HPET_IRQFREQ)
682+
cmd = HPET_IRQFREQ;
683+
660684
mutex_lock(&hpet_mutex);
661685
err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
662686
mutex_unlock(&hpet_mutex);

drivers/iio/industrialio-trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
315315
* this is the case if the IIO device and the trigger device share the
316316
* same parent device.
317317
*/
318-
if (iio_validate_own_trigger(pf->indio_dev, trig))
318+
if (!iio_validate_own_trigger(pf->indio_dev, trig))
319319
trig->attached_own_device = true;
320320

321321
return ret;

drivers/iio/light/apds9306.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ static int apds9306_intg_time_set(struct apds9306_data *data, int val2)
583583
return ret;
584584

585585
intg_old = iio_gts_find_int_time_by_sel(&data->gts, intg_time_idx);
586-
if (ret < 0)
587-
return ret;
586+
if (intg_old < 0)
587+
return intg_old;
588588

589589
if (intg_old == val2)
590590
return 0;

drivers/misc/fastrpc.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
12381238
struct fastrpc_phy_page pages[1];
12391239
char *name;
12401240
int err;
1241+
bool scm_done = false;
12411242
struct {
12421243
int pgid;
12431244
u32 namelen;
@@ -1289,6 +1290,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
12891290
fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err);
12901291
goto err_map;
12911292
}
1293+
scm_done = true;
12921294
}
12931295
}
12941296

@@ -1320,10 +1322,11 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
13201322
goto err_invoke;
13211323

13221324
kfree(args);
1325+
kfree(name);
13231326

13241327
return 0;
13251328
err_invoke:
1326-
if (fl->cctx->vmcount) {
1329+
if (fl->cctx->vmcount && scm_done) {
13271330
u64 src_perms = 0;
13281331
struct qcom_scm_vmperm dst_perms;
13291332
u32 i;
@@ -1693,16 +1696,20 @@ static int fastrpc_get_info_from_dsp(struct fastrpc_user *fl, uint32_t *dsp_attr
16931696
{
16941697
struct fastrpc_invoke_args args[2] = { 0 };
16951698

1696-
/* Capability filled in userspace */
1699+
/*
1700+
* Capability filled in userspace. This carries the information
1701+
* about the remoteproc support which is fetched from the remoteproc
1702+
* sysfs node by userspace.
1703+
*/
16971704
dsp_attr_buf[0] = 0;
1705+
dsp_attr_buf_len -= 1;
16981706

16991707
args[0].ptr = (u64)(uintptr_t)&dsp_attr_buf_len;
17001708
args[0].length = sizeof(dsp_attr_buf_len);
17011709
args[0].fd = -1;
17021710
args[1].ptr = (u64)(uintptr_t)&dsp_attr_buf[1];
1703-
args[1].length = dsp_attr_buf_len;
1711+
args[1].length = dsp_attr_buf_len * sizeof(u32);
17041712
args[1].fd = -1;
1705-
fl->pd = USER_PD;
17061713

17071714
return fastrpc_internal_invoke(fl, true, FASTRPC_DSP_UTILITIES_HANDLE,
17081715
FASTRPC_SCALARS(0, 1, 1), args);
@@ -1730,7 +1737,7 @@ static int fastrpc_get_info_from_kernel(struct fastrpc_ioctl_capability *cap,
17301737
if (!dsp_attributes)
17311738
return -ENOMEM;
17321739

1733-
err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES_LEN);
1740+
err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES);
17341741
if (err == DSP_UNSUPPORTED_API) {
17351742
dev_info(&cctx->rpdev->dev,
17361743
"Warning: DSP capabilities not supported on domain: %d\n", domain);
@@ -1783,7 +1790,7 @@ static int fastrpc_get_dsp_info(struct fastrpc_user *fl, char __user *argp)
17831790
if (err)
17841791
return err;
17851792

1786-
if (copy_to_user(argp, &cap.capability, sizeof(cap.capability)))
1793+
if (copy_to_user(argp, &cap, sizeof(cap)))
17871794
return -EFAULT;
17881795

17891796
return 0;
@@ -2080,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
20802087
return err;
20812088
}
20822089

2090+
static int is_attach_rejected(struct fastrpc_user *fl)
2091+
{
2092+
/* Check if the device node is non-secure */
2093+
if (!fl->is_secure_dev) {
2094+
dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
2095+
return -EACCES;
2096+
}
2097+
return 0;
2098+
}
2099+
20832100
static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
20842101
unsigned long arg)
20852102
{
@@ -2092,13 +2109,19 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
20922109
err = fastrpc_invoke(fl, argp);
20932110
break;
20942111
case FASTRPC_IOCTL_INIT_ATTACH:
2095-
err = fastrpc_init_attach(fl, ROOT_PD);
2112+
err = is_attach_rejected(fl);
2113+
if (!err)
2114+
err = fastrpc_init_attach(fl, ROOT_PD);
20962115
break;
20972116
case FASTRPC_IOCTL_INIT_ATTACH_SNS:
2098-
err = fastrpc_init_attach(fl, SENSORS_PD);
2117+
err = is_attach_rejected(fl);
2118+
if (!err)
2119+
err = fastrpc_init_attach(fl, SENSORS_PD);
20992120
break;
21002121
case FASTRPC_IOCTL_INIT_CREATE_STATIC:
2101-
err = fastrpc_init_create_static_process(fl, argp);
2122+
err = is_attach_rejected(fl);
2123+
if (!err)
2124+
err = fastrpc_init_create_static_process(fl, argp);
21022125
break;
21032126
case FASTRPC_IOCTL_INIT_CREATE:
21042127
err = fastrpc_init_create_process(fl, argp);

drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static int pci1xxxx_eeprom_read(void *priv_t, unsigned int off,
153153

154154
buf[byte] = readl(rb + MMAP_EEPROM_OFFSET(EEPROM_DATA_REG));
155155
}
156-
ret = byte;
157156
error:
158157
release_sys_lock(priv);
159158
return ret;
@@ -197,7 +196,6 @@ static int pci1xxxx_eeprom_write(void *priv_t, unsigned int off,
197196
goto error;
198197
}
199198
}
200-
ret = byte;
201199
error:
202200
release_sys_lock(priv);
203201
return ret;
@@ -258,7 +256,6 @@ static int pci1xxxx_otp_read(void *priv_t, unsigned int off,
258256

259257
buf[byte] = readl(rb + MMAP_OTP_OFFSET(OTP_RD_DATA_OFFSET));
260258
}
261-
ret = byte;
262259
error:
263260
release_sys_lock(priv);
264261
return ret;
@@ -315,7 +312,6 @@ static int pci1xxxx_otp_write(void *priv_t, unsigned int off,
315312
goto error;
316313
}
317314
}
318-
ret = byte;
319315
error:
320316
release_sys_lock(priv);
321317
return ret;

drivers/misc/mei/platform-vsc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
#define MEI_VSC_MAX_MSG_SIZE 512
3030

31-
#define MEI_VSC_POLL_DELAY_US (50 * USEC_PER_MSEC)
32-
#define MEI_VSC_POLL_TIMEOUT_US (200 * USEC_PER_MSEC)
31+
#define MEI_VSC_POLL_DELAY_US (100 * USEC_PER_MSEC)
32+
#define MEI_VSC_POLL_TIMEOUT_US (400 * USEC_PER_MSEC)
3333

3434
#define mei_dev_to_vsc_hw(dev) ((struct mei_vsc_hw *)((dev)->hw))
3535

drivers/misc/mei/vsc-fw-loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct vsc_img_frag {
204204

205205
/**
206206
* struct vsc_fw_loader - represent vsc firmware loader
207-
* @dev: device used to request fimware
207+
* @dev: device used to request firmware
208208
* @tp: transport layer used with the firmware loader
209209
* @csi: CSI image
210210
* @ace: ACE image

drivers/misc/mei/vsc-tp.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ int vsc_tp_rom_xfer(struct vsc_tp *tp, const void *obuf, void *ibuf, size_t len)
331331
return ret;
332332
}
333333

334-
ret = vsc_tp_dev_xfer(tp, tp->tx_buf, tp->rx_buf, len);
334+
ret = vsc_tp_dev_xfer(tp, tp->tx_buf, ibuf ? tp->rx_buf : NULL, len);
335335
if (ret)
336336
return ret;
337337

338338
if (ibuf)
339-
cpu_to_be32_array(ibuf, tp->rx_buf, words);
339+
be32_to_cpu_array(ibuf, tp->rx_buf, words);
340340

341341
return ret;
342342
}
@@ -568,6 +568,19 @@ static void vsc_tp_remove(struct spi_device *spi)
568568
free_irq(spi->irq, tp);
569569
}
570570

571+
static void vsc_tp_shutdown(struct spi_device *spi)
572+
{
573+
struct vsc_tp *tp = spi_get_drvdata(spi);
574+
575+
platform_device_unregister(tp->pdev);
576+
577+
mutex_destroy(&tp->mutex);
578+
579+
vsc_tp_reset(tp);
580+
581+
free_irq(spi->irq, tp);
582+
}
583+
571584
static const struct acpi_device_id vsc_tp_acpi_ids[] = {
572585
{ "INTC1009" }, /* Raptor Lake */
573586
{ "INTC1058" }, /* Tiger Lake */
@@ -580,6 +593,7 @@ MODULE_DEVICE_TABLE(acpi, vsc_tp_acpi_ids);
580593
static struct spi_driver vsc_tp_driver = {
581594
.probe = vsc_tp_probe,
582595
.remove = vsc_tp_remove,
596+
.shutdown = vsc_tp_shutdown,
583597
.driver = {
584598
.name = "vsc-tp",
585599
.acpi_match_table = vsc_tp_acpi_ids,

drivers/nvmem/core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,9 @@ static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
396396
if (!config->base_dev)
397397
return -EINVAL;
398398

399-
if (config->type == NVMEM_TYPE_FRAM)
400-
bin_attr_nvmem_eeprom_compat.attr.name = "fram";
401-
402399
nvmem->eeprom = bin_attr_nvmem_eeprom_compat;
400+
if (config->type == NVMEM_TYPE_FRAM)
401+
nvmem->eeprom.attr.name = "fram";
403402
nvmem->eeprom.attr.mode = nvmem_bin_attr_get_umode(nvmem);
404403
nvmem->eeprom.size = nvmem->size;
405404
#ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -463,7 +462,7 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
463462
"%s@%x,%x", entry->name,
464463
entry->offset,
465464
entry->bit_offset);
466-
attrs[i].attr.mode = 0444;
465+
attrs[i].attr.mode = 0444 & nvmem_bin_attr_get_umode(nvmem);
467466
attrs[i].size = entry->bytes;
468467
attrs[i].read = &nvmem_cell_attr_read;
469468
attrs[i].private = entry;

drivers/nvmem/meson-efuse.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@ static int meson_efuse_read(void *context, unsigned int offset,
1818
void *val, size_t bytes)
1919
{
2020
struct meson_sm_firmware *fw = context;
21+
int ret;
2122

22-
return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
23-
bytes, 0, 0, 0);
23+
ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
24+
bytes, 0, 0, 0);
25+
26+
return ret < 0 ? ret : 0;
2427
}
2528

2629
static int meson_efuse_write(void *context, unsigned int offset,
2730
void *val, size_t bytes)
2831
{
2932
struct meson_sm_firmware *fw = context;
33+
int ret;
34+
35+
ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
36+
bytes, 0, 0, 0);
3037

31-
return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
32-
bytes, 0, 0, 0);
38+
return ret < 0 ? ret : 0;
3339
}
3440

3541
static const struct of_device_id meson_efuse_match[] = {

0 commit comments

Comments
 (0)