Skip to content

Commit 815d570

Browse files
rhvgoyaltorvalds
authored andcommitted
kexec: make kexec_segment user buffer pointer a union
So far kexec_segment->buf was always a user space pointer as user space passed the array of kexec_segment structures and kernel copied it. But with new system call, list of kexec segments will be prepared by kernel and kexec_segment->buf will point to a kernel memory. So while I was adding code where I made assumption that ->buf is pointing to kernel memory, sparse started giving warning. Make ->buf a union. And where a user space pointer is expected, access it using ->buf and where a kernel space pointer is expected, access it using ->kbuf. That takes care of sparse warnings. Signed-off-by: Vivek Goyal <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Michael Kerrisk <[email protected]> Cc: Yinghai Lu <[email protected]> Cc: Eric Biederman <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Matthew Garrett <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Dave Young <[email protected]> Cc: WANG Chao <[email protected]> Cc: Baoquan He <[email protected]> Cc: Andy Lutomirski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8c86e70 commit 815d570

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

include/linux/kexec.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,18 @@ typedef unsigned long kimage_entry_t;
6969
#define IND_SOURCE 0x8
7070

7171
struct kexec_segment {
72-
void __user *buf;
72+
/*
73+
* This pointer can point to user memory if kexec_load() system
74+
* call is used or will point to kernel memory if
75+
* kexec_file_load() system call is used.
76+
*
77+
* Use ->buf when expecting to deal with user memory and use ->kbuf
78+
* when expecting to deal with kernel memory.
79+
*/
80+
union {
81+
void __user *buf;
82+
void *kbuf;
83+
};
7384
size_t bufsz;
7485
unsigned long mem;
7586
size_t memsz;

0 commit comments

Comments
 (0)