Skip to content

Commit d51e28b

Browse files
committed
Enable write to /proc/PID/last_siginfo (delivers signal)
1 parent 5d77ac2 commit d51e28b

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

fs/proc/base.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,13 +1145,8 @@ static int wait_waitsignal(struct task_struct *task, unsigned long long mask) {
11451145

11461146
if (mask & (1ULL << PROCTRACE_START_TASK)) {
11471147
// deliver signal to the child
1148-
// TODO: add semantics to disable delivery
1149-
1150-
if (task->last_siginfo) {
1148+
if (task->last_siginfo && !task->exit_code) {
11511149
task->exit_code = task->last_siginfo->si_signo;
1152-
printk("PROCTRACE sinal sent to the task: %d", task->exit_code);
1153-
} else {
1154-
printk("PROCTRACE no signal to send\n");
11551150
}
11561151

11571152
wake_up_process(task);
@@ -1287,8 +1282,27 @@ static ssize_t last_siginfo_read(struct file *file, char __user *buf,
12871282
return length;
12881283
}
12891284

1285+
/*
1286+
* On zero write, don't deliver signal to the child.
1287+
* On non-zero write, deliver the specified signal
1288+
*/
1289+
static ssize_t last_siginfo_write(struct file *file,
1290+
const unsigned char __user *buf, size_t count, loff_t *ppos) {
1291+
1292+
struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
1293+
1294+
task->last_siginfo = NULL;
1295+
if (count > 1) {
1296+
task->exit_code = *buf;
1297+
return 1;
1298+
}
1299+
1300+
return 0;
1301+
}
1302+
12901303
static const struct file_operations proc_last_siginfo_operations = {
12911304
.read= last_siginfo_read,
1305+
.write= last_siginfo_write,
12921306
};
12931307

12941308
static ssize_t environ_read(struct file *file, char __user *buf,

0 commit comments

Comments
 (0)