Line data Source code
1 :
2 : struct device;
3 :
4 : void *ldv_dev_get_drvdata(const struct device *dev);
5 : int ldv_dev_set_drvdata(struct device *dev, void *data);
6 :
7 : struct spi_master;
8 : struct device;
9 : struct spi_master *ldv_spi_alloc_master(struct device *host, unsigned size);
10 :
11 : #include <linux/ldv/err.h>
12 :
13 : #include <linux/types.h>
14 : void *ldv_kzalloc(size_t size, gfp_t flags);
15 :
16 : struct clk;
17 :
18 : extern void ldv_clk_disable(struct clk *clk);
19 : extern int ldv_clk_enable(void);
20 :
21 : #include <linux/ldv/common.h>
22 : #include <linux/ldv/irq.h>
23 : #include <verifier/common.h>
24 : #include <verifier/nondet.h>
25 : #include <verifier/memory.h>
26 : #include <verifier/thread.h>
27 :
28 : #include <linux/cdev.h>
29 : #include <linux/miscdevice.h>
30 : #include <linux/fs.h>
31 : #include <linux/pagemap.h>
32 :
33 :
34 : struct ldv_struct_insmod_8 {
35 : int signal_pending;
36 : };
37 :
38 : struct ldv_struct_random_containerless_scenario_5 {
39 : struct file_system_type *arg0;
40 : int signal_pending;
41 : };
42 :
43 : /* EMG Function declarations */
44 : void ldv_character_driver_scenario_1(void *);
45 : void ldv_character_driver_scenario_callback_1_22(ssize_t (*)(struct file *, char *, size_t , loff_t *), struct file *, char *, long unsigned int, loff_t *);
46 : void ldv_character_driver_scenario_callback_1_25(int (*)(struct file *, void *, filldir_t ), struct file *, void *, int (*)(void *, char *, int, loff_t , u64 , unsigned int));
47 : void ldv_character_driver_scenario_callback_1_5(loff_t (*)(struct file *, loff_t , int), struct file *, long long int, int);
48 : int ldv_character_driver_scenario_probe_1_13(int (*)(struct inode *, struct file *), struct inode *, struct file *);
49 : void ldv_character_driver_scenario_release_1_2(int (*)(struct inode *, struct file *), struct inode *, struct file *);
50 : extern void ldv_character_driver_scenario_write_1_4(ssize_t (*)(struct file *, char *, size_t , loff_t *), struct file *, char *, long unsigned int, loff_t *);
51 : void ldv_random_containerless_scenario_callback_4_4(int (*)(struct dentry *), struct dentry *);
52 : void ldv_random_containerless_scenario_callback_4_8(void (*)(struct dentry *, struct inode *), struct dentry *, struct inode *);
53 : void ldv_random_containerless_scenario_callback_6_16(int (*)(struct inode *, struct dentry *), struct inode *, struct dentry *);
54 : void ldv_random_containerless_scenario_callback_6_18(int (*)(struct inode *, struct dentry *, char *), struct inode *, struct dentry *, char *);
55 : void ldv_random_containerless_scenario_callback_6_21(int (*)(struct inode *, struct dentry *), struct inode *, struct dentry *);
56 : void ldv_random_containerless_scenario_callback_6_8(struct dentry *(*)(struct inode *, struct dentry *, struct nameidata *), struct inode *, struct dentry *, struct nameidata *);
57 : void ldv_random_containerless_scenario_callback_6_9(int (*)(struct inode *, struct dentry *, int), struct inode *, struct dentry *, int);
58 :
59 : /* EMG variable declarations */
60 1 : struct ldv_thread ldv_thread_1;
61 :
62 : /* EMG variable initialization */
63 :
64 : /* EMG function definitions */
65 : /* AUX_FUNC ldv_character_driver_scenario_1 */
66 : void ldv_character_driver_scenario_1(void *arg0) {
67 : /* LDV {"thread": 1, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'character_driver_scenario(file_operations)'", "function": "ldv_character_driver_scenario_1"} */
68 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
69 1 : loff_t (*ldv_1_callback_llseek)(struct file *, loff_t , int);
70 1 : ssize_t (*ldv_1_callback_read)(struct file *, char *, size_t , loff_t *);
71 : int (*ldv_1_callback_readdir)(struct file *, void *, filldir_t );
72 : struct file_operations *ldv_1_container_file_operations;
73 1 : char *ldv_1_ldv_param_22_1_default;
74 1 : long long int *ldv_1_ldv_param_22_3_default;
75 1 : char *ldv_1_ldv_param_4_1_default;
76 1 : long long int *ldv_1_ldv_param_4_3_default;
77 1 : long long int ldv_1_ldv_param_5_1_default;
78 1 : int ldv_1_ldv_param_5_2_default;
79 1 : struct file *ldv_1_resource_file;
80 1 : struct inode *ldv_1_resource_inode;
81 1 : int ldv_1_ret_default;
82 1 : int (*ldv_1_size_cnt_func_1_ptr)(void *, char *, int, loff_t , u64 , unsigned int);
83 1 : long unsigned int ldv_1_size_cnt_write_size;
84 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
85 1 : /* Initialize automaton variables */
86 2 : ldv_1_ret_default = 1;
87 1 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "RECEIVE_BEGIN", "comment": "Begin FILE_OPERATIONS callbacks invocations scenario."} */
88 3 : ldv_free(arg0);
89 1 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "RECEIVE_END"} */
90 1 :
91 1 : /* LDV {"action": "DEFAULT_ALLOC_1", "type": "CONDITION_BEGIN", "comment": "Allocate memory after default registration."} */
92 4 : ldv_1_container_file_operations = ldv_xmalloc_unknown_size(0);
93 1 : /* LDV {"action": "DEFAULT_ALLOC_1", "type": "CONDITION_END"} */
94 1 :
95 1 : /* LDV {"action": "INIT", "type": "CONDITION_BEGIN", "comment": "Allocate memory for file and inode structures."} */
96 4 : ldv_1_resource_file = ldv_xmalloc(sizeof(struct file));
97 3 : ldv_1_resource_inode = ldv_xmalloc(sizeof(struct inode));
98 3 : ldv_1_size_cnt_func_1_ptr = ldv_undef_int();
99 : /* LDV {"action": "INIT", "type": "CONDITION_END"} */
100 :
101 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Device appeared in the system."} */
102 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
103 :
104 : /* Jump to a subprocess 'main' initial state */
105 1 : goto ldv_main_1;
106 : /* End of the process */
107 : return;
108 1 :
109 : /* Sbprocess main */
110 : ldv_main_1:
111 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
112 :
113 4 : if (ldv_undef_int()) {
114 : /* LDV {"action": "PROBE", "type": "CALL_BEGIN", "callback": true, "comment": "Open the device file. Invoke callback open from file_operations."} */
115 : /* LDV {"type": "CALLBACK", "call": "ldv_1_ret_default = ((& configfs_dir_open))(ldv_1_resource_inode, ldv_1_resource_file);", "comment": "probe"} */
116 2 : ldv_1_ret_default = ldv_character_driver_scenario_probe_1_13(ldv_1_container_file_operations->open, ldv_1_resource_inode, ldv_1_resource_file);
117 : /* Callback post-call */
118 2 : ldv_1_ret_default = ldv_filter_err_code(ldv_1_ret_default);
119 : /* LDV {"action": "PROBE", "type": "CALL_END"} */
120 :
121 4 : if (ldv_undef_int()) {
122 : /* LDV {"action": "PROBE_SUCCESS", "type": "CONDITION_BEGIN", "comment": "Device file is opened successfully."} */
123 2 : ldv_assume(ldv_1_ret_default == 0);
124 : /* LDV {"action": "PROBE_SUCCESS", "type": "CONDITION_END"} */
125 :
126 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Device file is opened, ready to read and write."} */
127 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
128 :
129 : /* Jump to a subprocess 'call' initial state */
130 1 : goto ldv_call_1;
131 : }
132 : else {
133 : /* LDV {"action": "PROBE_FAIL", "type": "CONDITION_BEGIN", "comment": "Failed to open devices file."} */
134 2 : ldv_assume(ldv_1_ret_default != 0);
135 : /* LDV {"action": "PROBE_FAIL", "type": "CONDITION_END"} */
136 :
137 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Device appeared in the system."} */
138 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
139 :
140 : /* Jump to a subprocess 'main' initial state */
141 1 : goto ldv_main_1;
142 : }
143 : }
144 : else {
145 : /* LDV {"action": "FREE", "type": "CONDITION_BEGIN", "comment": "Free memory of file and inode structures."} */
146 2 : ldv_free(ldv_1_resource_file);
147 2 : ldv_free(ldv_1_resource_inode);
148 : /* LDV {"action": "FREE", "type": "CONDITION_END"} */
149 :
150 : /* LDV {"action": "DEFAULT_FREE_1", "type": "CONDITION_BEGIN", "comment": "Free memory before default deregistration."} */
151 2 : ldv_free(ldv_1_container_file_operations);
152 : /* LDV {"action": "DEFAULT_FREE_1", "type": "CONDITION_END"} */
153 :
154 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "RECEIVE_BEGIN", "comment": "Finish FILE_OPERATIONS callbacks invocations scenario."} */
155 : /* Skip a non-replicative signal receiving */
156 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "RECEIVE_END"} */
157 :
158 : /* Exit function at a terminal state */
159 1 : return;
160 : }
161 : /* End of the subprocess 'main' */
162 : return;
163 1 :
164 : /* Sbprocess call */
165 : ldv_call_1:
166 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
167 :
168 2 : switch (ldv_undef_int()) {
169 3 : case 1: {
170 : /* LDV {"action": "PRE_CALL_4", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
171 3 : ldv_1_ldv_param_4_1_default = ldv_xmalloc_unknown_size(0);
172 3 : ldv_1_ldv_param_4_3_default = ldv_xmalloc_unknown_size(0);
173 : /* LDV {"action": "PRE_CALL_4", "type": "CONDITION_END"} */
174 :
175 : /* LDV {"action": "WRITE", "type": "CALL_BEGIN", "callback": true, "comment": "Write data to the device. Invoke callback write from FILE_OPERATIONS."} */
176 : /* Callback pre-call */
177 2 : ldv_assume(ldv_1_size_cnt_func_1_ptr <= (INT_MAX & PAGE_CACHE_MASK));
178 3 : if (ldv_1_container_file_operations->write) {
179 : /* LDV {"type": "CALLBACK", "call": "(ldv_1_container_file_operations->write)(ldv_1_resource_file, ldv_1_ldv_param_4_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_4_3_default);", "comment": "write"} */
180 3 : ldv_character_driver_scenario_write_1_4(ldv_1_container_file_operations->write, ldv_1_resource_file, ldv_1_ldv_param_4_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_4_3_default);
181 : }
182 : /* LDV {"action": "WRITE", "type": "CALL_END"} */
183 :
184 : /* LDV {"action": "POST_CALL_4", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
185 4 : ldv_free(ldv_1_ldv_param_4_1_default);
186 2 : ldv_free(ldv_1_ldv_param_4_3_default);
187 : /* LDV {"action": "POST_CALL_4", "type": "CONDITION_END"} */
188 :
189 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Device file is opened, ready to read and write."} */
190 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
191 :
192 : /* Jump to a subprocess 'call' initial state */
193 1 : goto ldv_call_1;
194 1 : break;
195 : }
196 3 : case 2: {
197 : /* LDV {"action": "RELEASE", "type": "CALL_BEGIN", "callback": true, "comment": "File structure is released. Invoke callback release from file_operations."} */
198 : /* LDV {"type": "CALLBACK", "call": "((& configfs_dir_close))(ldv_1_resource_inode, ldv_1_resource_file);", "comment": "release"} */
199 2 : ldv_character_driver_scenario_release_1_2(ldv_1_container_file_operations->release, ldv_1_resource_inode, ldv_1_resource_file);
200 : /* LDV {"action": "RELEASE", "type": "CALL_END"} */
201 :
202 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Device appeared in the system."} */
203 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
204 :
205 : /* Jump to a subprocess 'main' initial state */
206 1 : goto ldv_main_1;
207 1 : break;
208 : }
209 3 : case 3: {
210 : /* LDV {"action": "PRE_CALL_5", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
211 : /* LDV {"action": "PRE_CALL_5", "type": "CONDITION_END"} */
212 :
213 2 : switch (ldv_undef_int()) {
214 3 : case 1: {
215 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Invoke callback readdir from file_operations."} */
216 : /* LDV {"type": "CALLBACK", "call": "((& configfs_readdir))(ldv_1_resource_file, ldv_1_resource_inode, ldv_1_size_cnt_func_1_ptr);", "comment": "callback"} */
217 2 : ldv_character_driver_scenario_callback_1_25(ldv_1_callback_readdir, ldv_1_resource_file, ldv_1_resource_inode, ldv_1_size_cnt_func_1_ptr);
218 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
219 :
220 1 : break;
221 1 : }
222 3 : case 2: {
223 : /* LDV {"action": "PRE_CALL_22", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
224 3 : ldv_1_ldv_param_22_1_default = ldv_xmalloc_unknown_size(0);
225 3 : ldv_1_ldv_param_22_3_default = ldv_xmalloc_unknown_size(0);
226 : /* LDV {"action": "PRE_CALL_22", "type": "CONDITION_END"} */
227 :
228 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Invoke callback read from file_operations."} */
229 : /* LDV {"type": "CALLBACK", "call": "((& generic_read_dir))(ldv_1_resource_file, ldv_1_ldv_param_22_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_22_3_default);", "comment": "callback"} */
230 2 : ldv_character_driver_scenario_callback_1_22(ldv_1_callback_read, ldv_1_resource_file, ldv_1_ldv_param_22_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_22_3_default);
231 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
232 :
233 : /* LDV {"action": "POST_CALL_22", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
234 2 : ldv_free(ldv_1_ldv_param_22_1_default);
235 2 : ldv_free(ldv_1_ldv_param_22_3_default);
236 : /* LDV {"action": "POST_CALL_22", "type": "CONDITION_END"} */
237 :
238 1 : break;
239 1 : }
240 3 : case 3: {
241 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Invoke callback llseek from file_operations."} */
242 : /* LDV {"type": "CALLBACK", "call": "((& configfs_dir_lseek))(ldv_1_resource_file, ldv_1_ldv_param_5_1_default, ldv_1_ldv_param_5_2_default);", "comment": "callback"} */
243 2 : ldv_character_driver_scenario_callback_1_5(ldv_1_callback_llseek, ldv_1_resource_file, ldv_1_ldv_param_5_1_default, ldv_1_ldv_param_5_2_default);
244 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
245 :
246 1 : break;
247 1 : }
248 2 : default: ldv_stop();
249 1 : }
250 3 : break;
251 1 : }
252 2 : default: ldv_stop();
253 1 : }
254 0 : /* LDV {"action": "POST_CALL_5", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
255 : /* LDV {"action": "POST_CALL_5", "type": "CONDITION_END"} */
256 0 :
257 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Device file is opened, ready to read and write."} */
258 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
259 :
260 : /* Jump to a subprocess 'call' initial state */
261 3 : goto ldv_call_1;
262 : /* Jump to a subprocess 'call' initial state */
263 : goto ldv_call_1;
264 : /* End of the subprocess 'call' */
265 : return;
266 : /* LDV {"comment": "End of control function based on process 'character_driver_scenario(file_operations)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_character_driver_scenario_1"} */
267 : }
268 :
269 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_1_22 */
270 : void ldv_character_driver_scenario_callback_1_22(ssize_t (*arg0)(struct file *, char *, size_t , loff_t *), struct file *arg1, char *arg2, long unsigned int arg3, long long int *arg4) {
271 1 : ((& generic_read_dir))(arg1, arg2, arg3, arg4);
272 1 : }
273 :
274 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_1_25 */
275 : void ldv_character_driver_scenario_callback_1_25(int (*arg0)(struct file *, void *, filldir_t ), struct file *arg1, void *arg2, int (*arg3)(void *, char *, int, loff_t , u64 , unsigned int)) {
276 5 : ((& configfs_readdir))(arg1, arg2, arg3);
277 1 : }
278 :
279 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_1_5 */
280 : void ldv_character_driver_scenario_callback_1_5(loff_t (*arg0)(struct file *, loff_t , int), struct file *arg1, long long int arg2, int arg3) {
281 3 : ((& configfs_dir_lseek))(arg1, arg2, arg3);
282 1 : }
283 :
284 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_probe_1_13 */
285 : int ldv_character_driver_scenario_probe_1_13(int (*arg0)(struct inode *, struct file *), struct inode *arg1, struct file *arg2) {
286 5 : return ((& configfs_dir_open))(arg1, arg2);
287 : }
288 1 :
289 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_release_1_2 */
290 : void ldv_character_driver_scenario_release_1_2(int (*arg0)(struct inode *, struct file *), struct inode *arg1, struct file *arg2) {
291 2 : ((& configfs_dir_close))(arg1, arg2);
292 1 : }
293 :
294 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_4_4 */
295 : void ldv_random_containerless_scenario_callback_4_4(int (*arg0)(struct dentry *), struct dentry *arg1) {
296 2 : ((& configfs_d_delete))(arg1);
297 1 : }
298 :
299 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_4_8 */
300 : void ldv_random_containerless_scenario_callback_4_8(void (*arg0)(struct dentry *, struct inode *), struct dentry *arg1, struct inode *arg2) {
301 3 : ((& configfs_d_iput))(arg1, arg2);
302 1 : }
303 :
304 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_6_16 */
305 : void ldv_random_containerless_scenario_callback_6_16(int (*arg0)(struct inode *, struct dentry *), struct inode *arg1, struct dentry *arg2) {
306 5 : ((& configfs_rmdir))(arg1, arg2);
307 1 : }
308 :
309 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_6_18 */
310 : void ldv_random_containerless_scenario_callback_6_18(int (*arg0)(struct inode *, struct dentry *, char *), struct inode *arg1, struct dentry *arg2, char *arg3) {
311 4 : ((& configfs_symlink))(arg1, arg2, arg3);
312 1 : }
313 :
314 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_6_21 */
315 : void ldv_random_containerless_scenario_callback_6_21(int (*arg0)(struct inode *, struct dentry *), struct inode *arg1, struct dentry *arg2) {
316 3 : ((& configfs_unlink))(arg1, arg2);
317 1 : }
318 :
319 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_6_8 */
320 : void ldv_random_containerless_scenario_callback_6_8(struct dentry *(*arg0)(struct inode *, struct dentry *, struct nameidata *), struct inode *arg1, struct dentry *arg2, struct nameidata *arg3) {
321 4 : ((& configfs_lookup))(arg1, arg2, arg3);
322 1 : }
323 :
324 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_6_9 */
325 : void ldv_random_containerless_scenario_callback_6_9(int (*arg0)(struct inode *, struct dentry *, int), struct inode *arg1, struct dentry *arg2, int arg3) {
326 4 : ((& configfs_mkdir))(arg1, arg2, arg3);
327 1 : }
328 :
329 :
330 : /* AUX_FUNC ERR_PTR */
331 : static inline void *ERR_PTR (long int error)
332 : {
333 23 :
334 69 : return ldv_err_ptr(error);
335 : }
336 :
337 : /* AUX_FUNC PTR_ERR */
338 : static inline long int PTR_ERR (void const *ptr)
339 : {
340 10 :
341 30 : return ldv_ptr_err(ptr);
342 : }
343 :
344 : /* AUX_FUNC IS_ERR */
345 : static inline long int IS_ERR (void const *ptr)
346 : {
347 12 :
348 36 : return ldv_is_err(ptr);
349 : }
350 :
351 : /* AUX_FUNC IS_ERR_OR_NULL */
352 : static inline long int IS_ERR_OR_NULL (void const *ptr)
353 : {
354 :
355 : return ldv_is_err_or_null(ptr);
356 : }
357 :
358 : /* AUX_FUNC kzalloc */
359 : static inline void *kzalloc (size_t size, gfp_t flags)
360 : {
361 :
362 : return ldv_kzalloc(size, flags);
363 : }
|