Thread (18 messages) flat view 18 messages, 5 authors, 2020-04-21

Re: [PATCH 6/6] sysctl: pass kernel pointers to ->proc_handler

From: Christoph Hellwig <hch@lst.de>
Date: 2020-04-21 07:42:54
Also in: bpf, linux-fsdevel, linux-mm, lkml

On Fri, Apr 17, 2020 at 11:17:18AM -0700, Matthew Wilcox wrote:
quoted
 	if (error)
-		goto out;
+		goto out_free_buf;
 
 	/* careful: calling conventions are nasty here */
I think this comment can go now ;-)
It actually long predates the set_fs that was only added for BPF,
and goes back to:

330d57fb98a91 ("[PATCH] Fix sysctl unregistration oops (CVE-2005-2709)")
in the history.git tree.
quoted
-	} else {
-		error = table->proc_handler(table, write, buf, &count, ppos);
-	}
+	error = table->proc_handler(table, write, kbuf, &count, ppos);
+	if (error)
+		goto out_free_buf;
+
+	error = -EFAULT;
+	if (copy_to_user(ubuf, kbuf, count))
+		goto out_free_buf;
Can we skip this if !write?  Indeed, don't we have to in case the user has
passed a pointer to a read-only memory page?
Indeed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help