Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\kexec_file.c Create Date:2022-07-28 11:04:06
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:In file mode list of segments is prepared by kernel. Copy relevant* data from user space, do error checking, prepare segment list

Proto:static int kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, const char __user *cmdline_ptr, unsigned long cmdline_len, unsigned flags)

Type:int

Parameter:

TypeParameterName
struct kimage *image
intkernel_fd
intinitrd_fd
const char __user *cmdline_ptr
unsigned longcmdline_len
unsignedflags
246  ret = kernel_read_file_from_fd(kernel_fd, & Additional fields for file based kexec syscall , & size, INT_MAX, READING_KEXEC_IMAGE)
248  If ret Then Return ret
250  kernel_buf_len = size
253  ret = Architectures can provide this probe function
255  If ret Then Go to out
265  If Not (flags & KEXEC_FILE_NO_INITRAMFS) Then
266  ret = kernel_read_file_from_fd(initrd_fd, & initrd_buf, & size, INT_MAX, READING_KEXEC_INITRAMFS)
269  If ret Then Go to out
271  initrd_buf_len = size
274  If cmdline_len Then
275  cmdline_buf = memdup_user(cmdline_ptr, cmdline_len)
276  If IS_ERR(cmdline_buf) Then
278  cmdline_buf = NULL
279  Go to out
282  cmdline_buf_len = cmdline_len
285  If cmdline_buf[cmdline_len - 1] != '\0' Then
286  ret = -EINVAL
287  Go to out
290  ima_kexec_cmdline(cmdline_buf, cmdline_buf_len - 1)
295  ima_add_kexec_buffer(image)
298  ldata = arch_kexec_kernel_image_load(image)
300  If IS_ERR(ldata) Then
301  ret = PTR_ERR(ldata)
302  Go to out
305  Image loader handling the kernel can store a pointer here = ldata
306  out :
308  If ret Then Free up memory used by kernel, initrd, and command line. This is temporary* memory allocation which is not needed any more after these buffers have* been loaded into separate segments and have been copied elsewhere.
310  Return ret
Caller
NameDescribe
kimage_file_alloc_init