.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) |
---|
3 | 4 | * Copyright (C) 2001 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
---|
4 | | - * Licensed under the GPL |
---|
5 | 5 | */ |
---|
6 | 6 | |
---|
7 | 7 | #include <linux/console.h> |
---|
.. | .. |
---|
35 | 35 | #include "mconsole.h" |
---|
36 | 36 | #include "mconsole_kern.h" |
---|
37 | 37 | #include <os.h> |
---|
| 38 | + |
---|
| 39 | +static struct vfsmount *proc_mnt = NULL; |
---|
38 | 40 | |
---|
39 | 41 | static int do_unlink_socket(struct notifier_block *notifier, |
---|
40 | 42 | unsigned long what, void *data) |
---|
.. | .. |
---|
96 | 98 | } |
---|
97 | 99 | if (!list_empty(&mc_requests)) |
---|
98 | 100 | schedule_work(&mconsole_work); |
---|
99 | | - reactivate_fd(fd, MCONSOLE_IRQ); |
---|
100 | 101 | return IRQ_HANDLED; |
---|
101 | 102 | } |
---|
102 | 103 | |
---|
.. | .. |
---|
124 | 125 | |
---|
125 | 126 | void mconsole_proc(struct mc_request *req) |
---|
126 | 127 | { |
---|
127 | | - struct vfsmount *mnt = task_active_pid_ns(current)->proc_mnt; |
---|
| 128 | + struct vfsmount *mnt = proc_mnt; |
---|
128 | 129 | char *buf; |
---|
129 | 130 | int len; |
---|
130 | 131 | struct file *file; |
---|
.. | .. |
---|
135 | 136 | ptr += strlen("proc"); |
---|
136 | 137 | ptr = skip_spaces(ptr); |
---|
137 | 138 | |
---|
| 139 | + if (!mnt) { |
---|
| 140 | + mconsole_reply(req, "Proc not available", 1, 0); |
---|
| 141 | + goto out; |
---|
| 142 | + } |
---|
138 | 143 | file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY, 0); |
---|
139 | 144 | if (IS_ERR(file)) { |
---|
140 | 145 | mconsole_reply(req, "Failed to open file", 1, 0); |
---|
.. | .. |
---|
218 | 223 | |
---|
219 | 224 | void mconsole_stop(struct mc_request *req) |
---|
220 | 225 | { |
---|
221 | | - deactivate_fd(req->originating_fd, MCONSOLE_IRQ); |
---|
| 226 | + block_signals(); |
---|
222 | 227 | os_set_fd_block(req->originating_fd, 1); |
---|
223 | 228 | mconsole_reply(req, "stopped", 0, 0); |
---|
224 | 229 | for (;;) { |
---|
.. | .. |
---|
240 | 245 | (*req->cmd->handler)(req); |
---|
241 | 246 | } |
---|
242 | 247 | os_set_fd_block(req->originating_fd, 0); |
---|
243 | | - reactivate_fd(req->originating_fd, MCONSOLE_IRQ); |
---|
244 | 248 | mconsole_reply(req, "", 0, 0); |
---|
| 249 | + unblock_signals(); |
---|
245 | 250 | } |
---|
246 | 251 | |
---|
247 | 252 | static DEFINE_SPINLOCK(mc_devices_lock); |
---|
.. | .. |
---|
644 | 649 | { |
---|
645 | 650 | struct task_struct *task = arg; |
---|
646 | 651 | |
---|
647 | | - show_stack(task, NULL); |
---|
| 652 | + show_stack(task, NULL, KERN_INFO); |
---|
648 | 653 | } |
---|
649 | 654 | |
---|
650 | 655 | /* |
---|
.. | .. |
---|
685 | 690 | with_console(req, stack_proc, to); |
---|
686 | 691 | } |
---|
687 | 692 | |
---|
| 693 | +static int __init mount_proc(void) |
---|
| 694 | +{ |
---|
| 695 | + struct file_system_type *proc_fs_type; |
---|
| 696 | + struct vfsmount *mnt; |
---|
| 697 | + |
---|
| 698 | + proc_fs_type = get_fs_type("proc"); |
---|
| 699 | + if (!proc_fs_type) |
---|
| 700 | + return -ENODEV; |
---|
| 701 | + |
---|
| 702 | + mnt = kern_mount(proc_fs_type); |
---|
| 703 | + put_filesystem(proc_fs_type); |
---|
| 704 | + if (IS_ERR(mnt)) |
---|
| 705 | + return PTR_ERR(mnt); |
---|
| 706 | + |
---|
| 707 | + proc_mnt = mnt; |
---|
| 708 | + return 0; |
---|
| 709 | +} |
---|
| 710 | + |
---|
688 | 711 | /* |
---|
689 | 712 | * Changed by mconsole_setup, which is __setup, and called before SMP is |
---|
690 | 713 | * active. |
---|
.. | .. |
---|
697 | 720 | long sock; |
---|
698 | 721 | int err; |
---|
699 | 722 | char file[UNIX_PATH_MAX]; |
---|
| 723 | + |
---|
| 724 | + mount_proc(); |
---|
700 | 725 | |
---|
701 | 726 | if (umid_file_name("mconsole", file, sizeof(file))) |
---|
702 | 727 | return -1; |
---|
.. | .. |
---|
754 | 779 | return count; |
---|
755 | 780 | } |
---|
756 | 781 | |
---|
757 | | -static const struct file_operations mconsole_proc_fops = { |
---|
758 | | - .owner = THIS_MODULE, |
---|
759 | | - .write = mconsole_proc_write, |
---|
760 | | - .llseek = noop_llseek, |
---|
| 782 | +static const struct proc_ops mconsole_proc_ops = { |
---|
| 783 | + .proc_write = mconsole_proc_write, |
---|
| 784 | + .proc_lseek = noop_llseek, |
---|
761 | 785 | }; |
---|
762 | 786 | |
---|
763 | 787 | static int create_proc_mconsole(void) |
---|
.. | .. |
---|
767 | 791 | if (notify_socket == NULL) |
---|
768 | 792 | return 0; |
---|
769 | 793 | |
---|
770 | | - ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_fops); |
---|
| 794 | + ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_ops); |
---|
771 | 795 | if (ent == NULL) { |
---|
772 | 796 | printk(KERN_INFO "create_proc_mconsole : proc_create failed\n"); |
---|
773 | 797 | return 0; |
---|