This source file includes following definitions.
- parse_efi_signature_list
1
2
3
4
5
6
7
8 #define pr_fmt(fmt) "EFI: "fmt
9 #include <linux/module.h>
10 #include <linux/printk.h>
11 #include <linux/err.h>
12 #include <linux/efi.h>
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 int __init parse_efi_signature_list(
38 const char *source,
39 const void *data, size_t size,
40 efi_element_handler_t (*get_handler_for_guid)(const efi_guid_t *))
41 {
42 efi_element_handler_t handler;
43 unsigned int offs = 0;
44
45 pr_devel("-->%s(,%zu)\n", __func__, size);
46
47 while (size > 0) {
48 const efi_signature_data_t *elem;
49 efi_signature_list_t list;
50 size_t lsize, esize, hsize, elsize;
51
52 if (size < sizeof(list))
53 return -EBADMSG;
54
55 memcpy(&list, data, sizeof(list));
56 pr_devel("LIST[%04x] guid=%pUl ls=%x hs=%x ss=%x\n",
57 offs,
58 list.signature_type.b, list.signature_list_size,
59 list.signature_header_size, list.signature_size);
60
61 lsize = list.signature_list_size;
62 hsize = list.signature_header_size;
63 esize = list.signature_size;
64 elsize = lsize - sizeof(list) - hsize;
65
66 if (lsize > size) {
67 pr_devel("<--%s() = -EBADMSG [overrun @%x]\n",
68 __func__, offs);
69 return -EBADMSG;
70 }
71
72 if (lsize < sizeof(list) ||
73 lsize - sizeof(list) < hsize ||
74 esize < sizeof(*elem) ||
75 elsize < esize ||
76 elsize % esize != 0) {
77 pr_devel("- bad size combo @%x\n", offs);
78 return -EBADMSG;
79 }
80
81 handler = get_handler_for_guid(&list.signature_type);
82 if (!handler) {
83 data += lsize;
84 size -= lsize;
85 offs += lsize;
86 continue;
87 }
88
89 data += sizeof(list) + hsize;
90 size -= sizeof(list) + hsize;
91 offs += sizeof(list) + hsize;
92
93 for (; elsize > 0; elsize -= esize) {
94 elem = data;
95
96 pr_devel("ELEM[%04x]\n", offs);
97 handler(source,
98 &elem->signature_data,
99 esize - sizeof(*elem));
100
101 data += esize;
102 size -= esize;
103 offs += esize;
104 }
105 }
106
107 return 0;
108 }