mirror of
https://github.com/nelsbrock/fun-linux-patches.git
synced 2026-08-14 21:56:48 +02:00
initial commit
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
|
||||
index 3c6670cf905f..ec176debb778 100644
|
||||
--- a/drivers/char/mem.c
|
||||
+++ b/drivers/char/mem.c
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <linux/uio.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/security.h>
|
||||
+#include <linux/minmax.h>
|
||||
+#include <linux/printk.h>
|
||||
|
||||
#define DEVMEM_MINOR 1
|
||||
#define DEVPORT_MINOR 4
|
||||
@@ -428,7 +430,20 @@ static ssize_t write_port(struct file *file, const char __user *buf,
|
||||
static ssize_t read_null(struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
- return 0;
|
||||
+ static const char content[] = "null\n";
|
||||
+ size_t content_length = sizeof(content);
|
||||
+
|
||||
+ if (*ppos >= content_length)
|
||||
+ return 0;
|
||||
+
|
||||
+ size_t copy_len = min(content_length - *ppos, count);
|
||||
+ if (copy_to_user(buf, content + *ppos, copy_len)) {
|
||||
+ pr_err("null: User copy failed\n");
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ *ppos += copy_len;
|
||||
+ return copy_len;
|
||||
}
|
||||
|
||||
static ssize_t write_null(struct file *file, const char __user *buf,
|
||||
@@ -437,33 +452,23 @@ static ssize_t write_null(struct file *file, const char __user *buf,
|
||||
return count;
|
||||
}
|
||||
|
||||
-static ssize_t read_iter_null(struct kiocb *iocb, struct iov_iter *to)
|
||||
-{
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static ssize_t write_iter_null(struct kiocb *iocb, struct iov_iter *from)
|
||||
+static ssize_t write_iter_zero(struct kiocb *iocb, struct iov_iter *from)
|
||||
{
|
||||
size_t count = iov_iter_count(from);
|
||||
iov_iter_advance(from, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
-static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf,
|
||||
+static int pipe_to_zero(struct pipe_inode_info *info, struct pipe_buffer *buf,
|
||||
struct splice_desc *sd)
|
||||
{
|
||||
return sd->len;
|
||||
}
|
||||
|
||||
-static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
|
||||
+static ssize_t splice_write_zero(struct pipe_inode_info *pipe, struct file *out,
|
||||
loff_t *ppos, size_t len, unsigned int flags)
|
||||
{
|
||||
- return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
|
||||
-}
|
||||
-
|
||||
-static int uring_cmd_null(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
|
||||
-{
|
||||
- return 0;
|
||||
+ return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_zero);
|
||||
}
|
||||
|
||||
static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
|
||||
@@ -627,8 +632,6 @@ static int open_port(struct inode *inode, struct file *filp)
|
||||
#define zero_lseek null_lseek
|
||||
#define full_lseek null_lseek
|
||||
#define write_zero write_null
|
||||
-#define write_iter_zero write_iter_null
|
||||
-#define splice_write_zero splice_write_null
|
||||
#define open_mem open_port
|
||||
|
||||
static const struct file_operations __maybe_unused mem_fops = {
|
||||
@@ -644,13 +647,8 @@ static const struct file_operations __maybe_unused mem_fops = {
|
||||
};
|
||||
|
||||
static const struct file_operations null_fops = {
|
||||
- .llseek = null_lseek,
|
||||
.read = read_null,
|
||||
.write = write_null,
|
||||
- .read_iter = read_iter_null,
|
||||
- .write_iter = write_iter_null,
|
||||
- .splice_write = splice_write_null,
|
||||
- .uring_cmd = uring_cmd_null,
|
||||
};
|
||||
|
||||
static const struct file_operations __maybe_unused port_fops = {
|
||||
@@ -0,0 +1,35 @@
|
||||
diff --git a/fs/exec.c b/fs/exec.c
|
||||
index 5ee2545c3e18..39739119d148 100644
|
||||
--- a/fs/exec.c
|
||||
+++ b/fs/exec.c
|
||||
@@ -1939,6 +1939,8 @@ static int do_execveat_common(int fd, struct filename *filename,
|
||||
goto out_ret;
|
||||
}
|
||||
|
||||
+ pr_info("Task (pid: %d, comm: '%s') executed '%s'\n", current->pid, current->comm, bprm->filename);
|
||||
+
|
||||
retval = count(argv, MAX_ARG_STRINGS);
|
||||
if (retval == 0)
|
||||
pr_warn_once("process '%s' launched '%s' with NULL argv: empty string added\n",
|
||||
diff --git a/kernel/fork.c b/kernel/fork.c
|
||||
index 3b9cdb42e757..11c52d81e0c3 100644
|
||||
--- a/kernel/fork.c
|
||||
+++ b/kernel/fork.c
|
||||
@@ -2867,6 +2867,7 @@ pid_t kernel_clone(struct kernel_clone_args *args)
|
||||
struct task_struct *p;
|
||||
int trace = 0;
|
||||
pid_t nr;
|
||||
+ char comm[TASK_COMM_LEN];
|
||||
|
||||
/*
|
||||
* For legacy clone() calls, CLONE_PIDFD uses the parent_tid argument
|
||||
@@ -2915,6 +2916,9 @@ pid_t kernel_clone(struct kernel_clone_args *args)
|
||||
pid = get_task_pid(p, PIDTYPE_PID);
|
||||
nr = pid_vnr(pid);
|
||||
|
||||
+ get_task_comm(comm, p);
|
||||
+ pr_info("Task (pid: %d, comm: '%s') cloned to new task (pid: %d, comm: '%.*s')\n", current->pid, current->comm, nr, TASK_COMM_LEN, comm);
|
||||
+
|
||||
if (clone_flags & CLONE_PARENT_SETTID)
|
||||
put_user(nr, args->parent_tid);
|
||||
|
||||
Reference in New Issue
Block a user