Skip to content

Commit 1791c39

Browse files
committed
Merge tag 'char-misc-7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc/iio driver fixes from Greg KH: "Here are a relativly large number of small char/misc/iio and other driver fixes for 7.0-rc7. There's a bunch, but overall they are all small fixes for issues that people have been having that I finally caught up with getting merged due to delays on my end. The "largest" change overall is just some documentation updates to the security-bugs.rst file to hopefully tell the AI tools (and any users that actually read the documentation), how to send us better security bug reports as the quantity of reports these past few weeks has increased dramatically due to tools getting better at "finding" things. Included in here are: - lots of small IIO driver fixes for issues reported in 7.0-rc - gpib driver fixes - comedi driver fixes - interconnect driver fix - nvmem driver fixes - mei driver fix - counter driver fix - binder rust driver fixes - some other small misc driver fixes All of these have been in linux-next this week with no reported issues" * tag 'char-misc-7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (63 commits) Documentation: fix two typos in latest update to the security report howto Documentation: clarify the mandatory and desirable info for security reports Documentation: explain how to find maintainers addresses for security reports Documentation: minor updates to the security contacts .get_maintainer.ignore: add myself nvmem: zynqmp_nvmem: Fix buffer size in DMA and memcpy nvmem: imx: assign nvmem_cell_info::raw_len misc: fastrpc: check qcom_scm_assign_mem() return in rpmsg_probe misc: fastrpc: possible double-free of cctx->remote_heap comedi: dt2815: add hardware detection to prevent crash comedi: runflags cannot determine whether to reclaim chanlist comedi: Reinit dev->spinlock between attachments to low-level drivers comedi: me_daq: Fix potential overrun of firmware buffer comedi: me4000: Fix potential overrun of firmware buffer comedi: ni_atmio16d: Fix invalid clean-up after failed attach gpib: fix use-after-free in IO ioctl handlers gpib: lpvo_usb: fix memory leak on disconnect gpib: Fix fluke driver s390 compile issue lis3lv02d: Omit IRQF_ONESHOT if no threaded handler is provided lis3lv02d: fix kernel-doc warnings ...
2 parents 7a60c79 + f387e2e commit 1791c39

49 files changed

Lines changed: 545 additions & 260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.get_maintainer.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Alan Cox <alan@lxorguk.ukuu.org.uk>
22
Alan Cox <root@hraefn.swansea.linux.org.uk>
33
Alyssa Rosenzweig <alyssa@rosenzweig.io>
4+
Askar Safin <safinaskar@gmail.com>
45
Christoph Hellwig <hch@lst.de>
56
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
67
Marc Gonzalez <marc.w.gonzalez@free.fr>

Documentation/process/security-bugs.rst

Lines changed: 139 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,138 @@ Security bugs
55

66
Linux kernel developers take security very seriously. As such, we'd
77
like to know when a security bug is found so that it can be fixed and
8-
disclosed as quickly as possible. Please report security bugs to the
9-
Linux kernel security team.
8+
disclosed as quickly as possible.
9+
10+
Preparing your report
11+
---------------------
12+
13+
Like with any bug report, a security bug report requires a lot of analysis work
14+
from the developers, so the more information you can share about the issue, the
15+
better. Please review the procedure outlined in
16+
Documentation/admin-guide/reporting-issues.rst if you are unclear about what
17+
information is helpful. The following information are absolutely necessary in
18+
**any** security bug report:
19+
20+
* **affected kernel version range**: with no version indication, your report
21+
will not be processed. A significant part of reports are for bugs that
22+
have already been fixed, so it is extremely important that vulnerabilities
23+
are verified on recent versions (development tree or latest stable
24+
version), at least by verifying that the code has not changed since the
25+
version where it was detected.
26+
27+
* **description of the problem**: a detailed description of the problem, with
28+
traces showing its manifestation, and why you consider that the observed
29+
behavior as a problem in the kernel, is necessary.
30+
31+
* **reproducer**: developers will need to be able to reproduce the problem to
32+
consider a fix as effective. This includes both a way to trigger the issue
33+
and a way to confirm it happens. A reproducer with low complexity
34+
dependencies will be needed (source code, shell script, sequence of
35+
instructions, file-system image etc). Binary-only executables are not
36+
accepted. Working exploits are extremely helpful and will not be released
37+
without consent from the reporter, unless they are already public. By
38+
definition if an issue cannot be reproduced, it is not exploitable, thus it
39+
is not a security bug.
40+
41+
* **conditions**: if the bug depends on certain configuration options,
42+
sysctls, permissions, timing, code modifications etc, these should be
43+
indicated.
44+
45+
In addition, the following information are highly desirable:
46+
47+
* **suspected location of the bug**: the file names and functions where the
48+
bug is suspected to be present are very important, at least to help forward
49+
the report to the appropriate maintainers. When not possible (for example,
50+
"system freezes each time I run this command"), the security team will help
51+
identify the source of the bug.
52+
53+
* **a proposed fix**: bug reporters who have analyzed the cause of a bug in
54+
the source code almost always have an accurate idea on how to fix it,
55+
because they spent a long time studying it and its implications. Proposing
56+
a tested fix will save maintainers a lot of time, even if the fix ends up
57+
not being the right one, because it helps understand the bug. When
58+
proposing a tested fix, please always format it in a way that can be
59+
immediately merged (see Documentation/process/submitting-patches.rst).
60+
This will save some back-and-forth exchanges if it is accepted, and you
61+
will be credited for finding and fixing this issue. Note that in this case
62+
only a ``Signed-off-by:`` tag is needed, without ``Reported-by:`` when the
63+
reporter and author are the same.
64+
65+
* **mitigations**: very often during a bug analysis, some ways of mitigating
66+
the issue appear. It is useful to share them, as they can be helpful to
67+
keep end users protected during the time it takes them to apply the fix.
68+
69+
Identifying contacts
70+
--------------------
71+
72+
The most effective way to report a security bug is to send it directly to the
73+
affected subsystem's maintainers and Cc: the Linux kernel security team. Do
74+
not send it to a public list at this stage, unless you have good reasons to
75+
consider the issue as being public or trivial to discover (e.g. result of a
76+
widely available automated vulnerability scanning tool that can be repeated by
77+
anyone).
78+
79+
If you're sending a report for issues affecting multiple parts in the kernel,
80+
even if they're fairly similar issues, please send individual messages (think
81+
that maintainers will not all work on the issues at the same time). The only
82+
exception is when an issue concerns closely related parts maintained by the
83+
exact same subset of maintainers, and these parts are expected to be fixed all
84+
at once by the same commit, then it may be acceptable to report them at once.
85+
86+
One difficulty for most first-time reporters is to figure the right list of
87+
recipients to send a report to. In the Linux kernel, all official maintainers
88+
are trusted, so the consequences of accidentally including the wrong maintainer
89+
are essentially a bit more noise for that person, i.e. nothing dramatic. As
90+
such, a suitable method to figure the list of maintainers (which kernel
91+
security officers use) is to rely on the get_maintainer.pl script, tuned to
92+
only report maintainers. This script, when passed a file name, will look for
93+
its path in the MAINTAINERS file to figure a hierarchical list of relevant
94+
maintainers. Calling it a first time with the finest level of filtering will
95+
most of the time return a short list of this specific file's maintainers::
96+
97+
$ ./scripts/get_maintainer.pl --no-l --no-r --pattern-depth 1 \
98+
drivers/example.c
99+
Developer One <dev1@example.com> (maintainer:example driver)
100+
Developer Two <dev2@example.org> (maintainer:example driver)
101+
102+
These two maintainers should then receive the message. If the command does not
103+
return anything, it means the affected file is part of a wider subsystem, so we
104+
should be less specific::
105+
106+
$ ./scripts/get_maintainer.pl --no-l --no-r drivers/example.c
107+
Developer One <dev1@example.com> (maintainer:example subsystem)
108+
Developer Two <dev2@example.org> (maintainer:example subsystem)
109+
Developer Three <dev3@example.com> (maintainer:example subsystem [GENERAL])
110+
Developer Four <dev4@example.org> (maintainer:example subsystem [GENERAL])
111+
112+
Here, picking the first, most specific ones, is sufficient. When the list is
113+
long, it is possible to produce a comma-delimited e-mail address list on a
114+
single line suitable for use in the To: field of a mailer like this::
115+
116+
$ ./scripts/get_maintainer.pl --no-tree --no-l --no-r --no-n --m \
117+
--no-git-fallback --no-substatus --no-rolestats --no-multiline \
118+
--pattern-depth 1 drivers/example.c
119+
dev1@example.com, dev2@example.org
120+
121+
or this for the wider list::
122+
123+
$ ./scripts/get_maintainer.pl --no-tree --no-l --no-r --no-n --m \
124+
--no-git-fallback --no-substatus --no-rolestats --no-multiline \
125+
drivers/example.c
126+
dev1@example.com, dev2@example.org, dev3@example.com, dev4@example.org
127+
128+
If at this point you're still facing difficulties spotting the right
129+
maintainers, **and only in this case**, it's possible to send your report to
130+
the Linux kernel security team only. Your message will be triaged, and you
131+
will receive instructions about whom to contact, if needed. Your message may
132+
equally be forwarded as-is to the relevant maintainers.
133+
134+
Sending the report
135+
------------------
136+
137+
Reports are to be sent over e-mail exclusively. Please use a working e-mail
138+
address, preferably the same that you want to appear in ``Reported-by`` tags
139+
if any. If unsure, send your report to yourself first.
10140

11141
The security team and maintainers almost always require additional
12142
information beyond what was initially provided in a report and rely on
@@ -18,20 +148,12 @@ run additional tests. Reports where the reporter does not respond promptly
18148
or cannot effectively discuss their findings may be abandoned if the
19149
communication does not quickly improve.
20150

21-
As it is with any bug, the more information provided the easier it
22-
will be to diagnose and fix. Please review the procedure outlined in
23-
'Documentation/admin-guide/reporting-issues.rst' if you are unclear about what
24-
information is helpful. Any exploit code is very helpful and will not
25-
be released without consent from the reporter unless it has already been
26-
made public.
27-
151+
The report must be sent to maintainers, with the security team in ``Cc:``.
28152
The Linux kernel security team can be contacted by email at
29153
<security@kernel.org>. This is a private list of security officers
30-
who will help verify the bug report and develop and release a fix.
31-
If you already have a fix, please include it with your report, as
32-
that can speed up the process considerably. It is possible that the
33-
security team will bring in extra help from area maintainers to
34-
understand and fix the security vulnerability.
154+
who will help verify the bug report and assist developers working on a fix.
155+
It is possible that the security team will bring in extra help from area
156+
maintainers to understand and fix the security vulnerability.
35157

36158
Please send **plain text** emails without attachments where possible.
37159
It is much harder to have a context-quoted discussion about a complex
@@ -42,7 +164,9 @@ reproduction steps, and follow it with a proposed fix, all in plain text.
42164
Markdown, HTML and RST formatted reports are particularly frowned upon since
43165
they're quite hard to read for humans and encourage to use dedicated viewers,
44166
sometimes online, which by definition is not acceptable for a confidential
45-
security report.
167+
security report. Note that some mailers tend to mangle formatting of plain
168+
text by default, please consult Documentation/process/email-clients.rst for
169+
more info.
46170

47171
Disclosure and embargoed information
48172
------------------------------------

drivers/android/binder/page_range.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
//
1414
// The shrinker will use trylock methods because it locks them in a different order.
1515

16+
use crate::AssertSync;
17+
1618
use core::{
1719
marker::PhantomPinned,
1820
mem::{size_of, size_of_val, MaybeUninit},
@@ -143,14 +145,14 @@ pub(crate) struct ShrinkablePageRange {
143145
}
144146

145147
// We do not define any ops. For now, used only to check identity of vmas.
146-
static BINDER_VM_OPS: bindings::vm_operations_struct = pin_init::zeroed();
148+
static BINDER_VM_OPS: AssertSync<bindings::vm_operations_struct> = AssertSync(pin_init::zeroed());
147149

148150
// To ensure that we do not accidentally install pages into or zap pages from the wrong vma, we
149151
// check its vm_ops and private data before using it.
150152
fn check_vma(vma: &virt::VmaRef, owner: *const ShrinkablePageRange) -> Option<&virt::VmaMixedMap> {
151153
// SAFETY: Just reading the vm_ops pointer of any active vma is safe.
152154
let vm_ops = unsafe { (*vma.as_ptr()).vm_ops };
153-
if !ptr::eq(vm_ops, &BINDER_VM_OPS) {
155+
if !ptr::eq(vm_ops, &BINDER_VM_OPS.0) {
154156
return None;
155157
}
156158

@@ -342,7 +344,7 @@ impl ShrinkablePageRange {
342344

343345
// SAFETY: We own the vma, and we don't use any methods on VmaNew that rely on
344346
// `vm_ops`.
345-
unsafe { (*vma.as_ptr()).vm_ops = &BINDER_VM_OPS };
347+
unsafe { (*vma.as_ptr()).vm_ops = &BINDER_VM_OPS.0 };
346348

347349
Ok(num_pages)
348350
}

drivers/android/binder/rust_binder_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl kernel::Module for BinderModule {
306306
/// Makes the inner type Sync.
307307
#[repr(transparent)]
308308
pub struct AssertSync<T>(T);
309-
// SAFETY: Used only to insert `file_operations` into a global, which is safe.
309+
// SAFETY: Used only to insert C bindings types into globals, which is safe.
310310
unsafe impl<T> Sync for AssertSync<T> {}
311311

312312
/// File operations that rust_binderfs.c can use.

drivers/comedi/comedi_fops.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,15 @@ static void do_become_nonbusy(struct comedi_device *dev,
793793
__comedi_clear_subdevice_runflags(s, COMEDI_SRF_RUNNING |
794794
COMEDI_SRF_BUSY);
795795
spin_unlock_irqrestore(&s->spin_lock, flags);
796-
if (comedi_is_runflags_busy(runflags)) {
796+
if (async) {
797797
/*
798798
* "Run active" counter was set to 1 when setting up the
799799
* command. Decrement it and wait for it to become 0.
800800
*/
801-
comedi_put_is_subdevice_running(s);
802-
wait_for_completion(&async->run_complete);
801+
if (comedi_is_runflags_busy(runflags)) {
802+
comedi_put_is_subdevice_running(s);
803+
wait_for_completion(&async->run_complete);
804+
}
803805
comedi_buf_reset(s);
804806
async->inttrig = NULL;
805807
kfree(async->cmd.chanlist);

drivers/comedi/drivers.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,14 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
10631063
ret = -EIO;
10641064
goto out;
10651065
}
1066+
if (IS_ENABLED(CONFIG_LOCKDEP)) {
1067+
/*
1068+
* dev->spinlock is for private use by the attached low-level
1069+
* driver. Reinitialize it to stop lock-dependency tracking
1070+
* between attachments to different low-level drivers.
1071+
*/
1072+
spin_lock_init(&dev->spinlock);
1073+
}
10661074
dev->driver = driv;
10671075
dev->board_name = dev->board_ptr ? *(const char **)dev->board_ptr
10681076
: dev->driver->driver_name;

drivers/comedi/drivers/dt2815.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
175175
? current_range_type : voltage_range_type;
176176
}
177177

178+
/*
179+
* Check if hardware is present before attempting any I/O operations.
180+
* Reading 0xff from status register typically indicates no hardware
181+
* on the bus (floating bus reads as all 1s).
182+
*/
183+
if (inb(dev->iobase + DT2815_STATUS) == 0xff) {
184+
dev_err(dev->class_dev,
185+
"No hardware detected at I/O base 0x%lx\n",
186+
dev->iobase);
187+
return -ENODEV;
188+
}
189+
178190
/* Init the 2815 */
179191
outb(0x00, dev->iobase + DT2815_STATUS);
180192
for (i = 0; i < 100; i++) {

drivers/comedi/drivers/me4000.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,18 @@ static int me4000_xilinx_download(struct comedi_device *dev,
315315
unsigned int val;
316316
unsigned int i;
317317

318+
/* Get data stream length from header. */
319+
if (size >= 4) {
320+
file_length = (((unsigned int)data[0] & 0xff) << 24) +
321+
(((unsigned int)data[1] & 0xff) << 16) +
322+
(((unsigned int)data[2] & 0xff) << 8) +
323+
((unsigned int)data[3] & 0xff);
324+
}
325+
if (size < 16 || file_length > size - 16) {
326+
dev_err(dev->class_dev, "Firmware length inconsistency\n");
327+
return -EINVAL;
328+
}
329+
318330
if (!xilinx_iobase)
319331
return -ENODEV;
320332

@@ -346,10 +358,6 @@ static int me4000_xilinx_download(struct comedi_device *dev,
346358
outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
347359

348360
/* Download Xilinx firmware */
349-
file_length = (((unsigned int)data[0] & 0xff) << 24) +
350-
(((unsigned int)data[1] & 0xff) << 16) +
351-
(((unsigned int)data[2] & 0xff) << 8) +
352-
((unsigned int)data[3] & 0xff);
353361
usleep_range(10, 1000);
354362

355363
for (i = 0; i < file_length; i++) {

drivers/comedi/drivers/me_daq.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,25 @@ static int me2600_xilinx_download(struct comedi_device *dev,
344344
unsigned int file_length;
345345
unsigned int i;
346346

347+
/*
348+
* Format of the firmware
349+
* Build longs from the byte-wise coded header
350+
* Byte 1-3: length of the array
351+
* Byte 4-7: version
352+
* Byte 8-11: date
353+
* Byte 12-15: reserved
354+
*/
355+
if (size >= 4) {
356+
file_length = (((unsigned int)data[0] & 0xff) << 24) +
357+
(((unsigned int)data[1] & 0xff) << 16) +
358+
(((unsigned int)data[2] & 0xff) << 8) +
359+
((unsigned int)data[3] & 0xff);
360+
}
361+
if (size < 16 || file_length > size - 16) {
362+
dev_err(dev->class_dev, "Firmware length inconsistency\n");
363+
return -EINVAL;
364+
}
365+
347366
/* disable irq's on PLX */
348367
writel(0x00, devpriv->plx_regbase + PLX9052_INTCSR);
349368

@@ -357,22 +376,6 @@ static int me2600_xilinx_download(struct comedi_device *dev,
357376
writeb(0x00, dev->mmio + 0x0);
358377
sleep(1);
359378

360-
/*
361-
* Format of the firmware
362-
* Build longs from the byte-wise coded header
363-
* Byte 1-3: length of the array
364-
* Byte 4-7: version
365-
* Byte 8-11: date
366-
* Byte 12-15: reserved
367-
*/
368-
if (size < 16)
369-
return -EINVAL;
370-
371-
file_length = (((unsigned int)data[0] & 0xff) << 24) +
372-
(((unsigned int)data[1] & 0xff) << 16) +
373-
(((unsigned int)data[2] & 0xff) << 8) +
374-
((unsigned int)data[3] & 0xff);
375-
376379
/*
377380
* Loop for writing firmware byte by byte to xilinx
378381
* Firmware data start at offset 16

drivers/comedi/drivers/ni_atmio16d.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,8 @@ static int atmio16d_attach(struct comedi_device *dev,
698698

699699
static void atmio16d_detach(struct comedi_device *dev)
700700
{
701-
reset_atmio16d(dev);
701+
if (dev->private)
702+
reset_atmio16d(dev);
702703
comedi_legacy_detach(dev);
703704
}
704705

0 commit comments

Comments
 (0)