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>
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>
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)
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)