26
26
#include <linux/ptrace.h>
27
27
#include <linux/async.h>
28
28
#include <linux/uaccess.h>
29
- #include <linux/shmem_fs.h>
30
- #include <linux/pipe_fs_i.h>
31
29
32
30
#include <trace/events/module.h>
33
31
@@ -38,8 +36,6 @@ static kernel_cap_t usermodehelper_bset = CAP_FULL_SET;
38
36
static kernel_cap_t usermodehelper_inheritable = CAP_FULL_SET ;
39
37
static DEFINE_SPINLOCK (umh_sysctl_lock );
40
38
static DECLARE_RWSEM (umhelper_sem );
41
- static LIST_HEAD (umh_list );
42
- static DEFINE_MUTEX (umh_list_lock );
43
39
44
40
static void call_usermodehelper_freeinfo (struct subprocess_info * info )
45
41
{
@@ -402,121 +398,6 @@ struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
402
398
}
403
399
EXPORT_SYMBOL (call_usermodehelper_setup );
404
400
405
- static int umd_setup (struct subprocess_info * info , struct cred * new )
406
- {
407
- struct umh_info * umh_info = info -> data ;
408
- struct file * from_umh [2 ];
409
- struct file * to_umh [2 ];
410
- int err ;
411
-
412
- /* create pipe to send data to umh */
413
- err = create_pipe_files (to_umh , 0 );
414
- if (err )
415
- return err ;
416
- err = replace_fd (0 , to_umh [0 ], 0 );
417
- fput (to_umh [0 ]);
418
- if (err < 0 ) {
419
- fput (to_umh [1 ]);
420
- return err ;
421
- }
422
-
423
- /* create pipe to receive data from umh */
424
- err = create_pipe_files (from_umh , 0 );
425
- if (err ) {
426
- fput (to_umh [1 ]);
427
- replace_fd (0 , NULL , 0 );
428
- return err ;
429
- }
430
- err = replace_fd (1 , from_umh [1 ], 0 );
431
- fput (from_umh [1 ]);
432
- if (err < 0 ) {
433
- fput (to_umh [1 ]);
434
- replace_fd (0 , NULL , 0 );
435
- fput (from_umh [0 ]);
436
- return err ;
437
- }
438
-
439
- umh_info -> pipe_to_umh = to_umh [1 ];
440
- umh_info -> pipe_from_umh = from_umh [0 ];
441
- umh_info -> pid = task_pid_nr (current );
442
- current -> flags |= PF_UMH ;
443
- return 0 ;
444
- }
445
-
446
- static void umd_cleanup (struct subprocess_info * info )
447
- {
448
- struct umh_info * umh_info = info -> data ;
449
-
450
- /* cleanup if umh_setup() was successful but exec failed */
451
- if (info -> retval ) {
452
- fput (umh_info -> pipe_to_umh );
453
- fput (umh_info -> pipe_from_umh );
454
- }
455
- }
456
-
457
- /**
458
- * fork_usermode_blob - fork a blob of bytes as a usermode process
459
- * @data: a blob of bytes that can be do_execv-ed as a file
460
- * @len: length of the blob
461
- * @info: information about usermode process (shouldn't be NULL)
462
- *
463
- * If info->cmdline is set it will be used as command line for the
464
- * user process, else "usermodehelper" is used.
465
- *
466
- * Returns either negative error or zero which indicates success
467
- * in executing a blob of bytes as a usermode process. In such
468
- * case 'struct umh_info *info' is populated with two pipes
469
- * and a pid of the process. The caller is responsible for health
470
- * check of the user process, killing it via pid, and closing the
471
- * pipes when user process is no longer needed.
472
- */
473
- int fork_usermode_blob (void * data , size_t len , struct umh_info * info )
474
- {
475
- const char * cmdline = (info -> cmdline ) ? info -> cmdline : "usermodehelper" ;
476
- struct subprocess_info * sub_info ;
477
- char * * argv = NULL ;
478
- struct file * file ;
479
- ssize_t written ;
480
- loff_t pos = 0 ;
481
- int err ;
482
-
483
- file = shmem_kernel_file_setup ("" , len , 0 );
484
- if (IS_ERR (file ))
485
- return PTR_ERR (file );
486
-
487
- written = kernel_write (file , data , len , & pos );
488
- if (written != len ) {
489
- err = written ;
490
- if (err >= 0 )
491
- err = - ENOMEM ;
492
- goto out ;
493
- }
494
-
495
- err = - ENOMEM ;
496
- argv = argv_split (GFP_KERNEL , cmdline , NULL );
497
- if (!argv )
498
- goto out ;
499
-
500
- sub_info = call_usermodehelper_setup ("none" , argv , NULL , GFP_KERNEL ,
501
- umd_setup , umd_cleanup , info );
502
- if (!sub_info )
503
- goto out ;
504
-
505
- sub_info -> file = file ;
506
- err = call_usermodehelper_exec (sub_info , UMH_WAIT_EXEC );
507
- if (!err ) {
508
- mutex_lock (& umh_list_lock );
509
- list_add (& info -> list , & umh_list );
510
- mutex_unlock (& umh_list_lock );
511
- }
512
- out :
513
- if (argv )
514
- argv_free (argv );
515
- fput (file );
516
- return err ;
517
- }
518
- EXPORT_SYMBOL_GPL (fork_usermode_blob );
519
-
520
401
/**
521
402
* call_usermodehelper_exec - start a usermode application
522
403
* @sub_info: information about the subprocessa
@@ -678,26 +559,6 @@ static int proc_cap_handler(struct ctl_table *table, int write,
678
559
return 0 ;
679
560
}
680
561
681
- void __exit_umh (struct task_struct * tsk )
682
- {
683
- struct umh_info * info ;
684
- pid_t pid = tsk -> pid ;
685
-
686
- mutex_lock (& umh_list_lock );
687
- list_for_each_entry (info , & umh_list , list ) {
688
- if (info -> pid == pid ) {
689
- list_del (& info -> list );
690
- mutex_unlock (& umh_list_lock );
691
- goto out ;
692
- }
693
- }
694
- mutex_unlock (& umh_list_lock );
695
- return ;
696
- out :
697
- if (info -> cleanup )
698
- info -> cleanup (info );
699
- }
700
-
701
562
struct ctl_table usermodehelper_table [] = {
702
563
{
703
564
.procname = "bset" ,
0 commit comments