Commit Graph

6 Commits

Author SHA1 Message Date
Mathias Krause
1cfd513ea9 memory_driver: Use designated initializer for 'crash_dev'
Instead of using positional initialization, use the more modern
designated initializer style, as already used for 'crash_fops'.

This makes the member initialization not only less ambiguous but also
allows structure layout randomization of the underlying type (as done in
grsecurity).

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
2023-10-10 13:35:33 +09:00
Petr Tesarik
138b6752fd memory_driver: Fix memory driver module build with kernel 5.8+
Kernel commit fe557319aa06c23cffc9346000f119547e0f289a renamed
probe_kernel_{read,write} to copy_{from,to}_kernel_nofault.
Additionally, commit 0493cb086353e786be56010780a0b7025b5db34c
unexported probe_kernel_write(), so writing kernel memory is
no longer possible from a module.

Rename the functions in source, and add wrappers to allow
building the module with older kernel versions.

Without this patch, build with kernel 5.8 and later fails:

kbuild/default/crash.c: In function 'crash_write':
kbuild/default/crash.c:189:12: error: implicit declaration of function 'probe_kernel_write'; did you mean 'kernel_write'? [-Werror=implicit-function-declaration]
  189 |        if (probe_kernel_write(vaddr, buffer, count)) {
      |            ^~~~~~~~~~~~~~~~~~
      |            kernel_write
kbuild/default/crash.c: In function 'crash_read':
kbuild/default/crash.c:225:13: error: implicit declaration of function 'probe_kernel_read'; did you mean 'kernel_read'? [-Werror=implicit-function-declaration]
  225 |         if (probe_kernel_read(buffer, vaddr, count)) {
      |             ^~~~~~~~~~~~~~~~~
      |             kernel_read

[ kh: modified module's version and commit message ]

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
2020-11-09 14:29:50 +09:00
Dave Anderson
dfea9e3bd3 Add a write operation handler to the sample /dev/crash memory driver
that enables writing to kernel memory via the "wr" command.
(serapheim@delphix.com)
2019-01-07 10:14:45 -05:00
Dave Anderson
fad29db973 Fix the sample crash.ko memory driver to prevent an s390X kernel
addressing exception.  Legitimate pages of RAM that successfully
pass the page_is_ram() and pfn_valid() verifier functions may not
be provided by the s390x hypervisor, and the memcpy() from the
non-existent memory to the bounce buffer panics the kernel.  The
patch replaces the the memcpy() call with probe_kernel_read().
(anderson@redhat.com)
2018-02-08 10:23:50 -05:00
Dave Anderson
e726a31519 Update of the sample memory_driver/crash.c /dev/crash kernel driver
to version 1.3, which adds support for Linux 4.6 and later ARM64
kernels, kernels configured with CONFIG_HARDENED_USERCOPY, and
S390X kernels use xlate_dev_mem_ptr() and unxlate_dev_mem_ptr()
instead of kmap() and kunmap().
(anderson@redhat.com)
2016-11-22 11:43:40 -05:00
Dave Anderson
03e3937ec7 Initial commit: crash-7.0.4 2014-01-28 16:46:11 -05:00