Thread (14 messages) 14 messages, 2 authors, 2021-10-06

Re: [PATCH 3/3] mm/usercopy: Detect compound page overruns

From: Matthew Wilcox <willy@infradead.org>
Date: 2021-10-05 22:13:14

On Tue, Oct 05, 2021 at 02:26:37PM -0700, Kees Cook wrote:
On Mon, Oct 04, 2021 at 11:42:23PM +0100, Matthew Wilcox (Oracle) wrote:
quoted
+	} else if (PageHead(page)) {
+		/* A compound allocation */
+		if (ptr + n > page_address(page) + page_size(page))
+			usercopy_abort("page alloc", NULL, to_user, 0, n);
"0" could be "ptr - page_address(page)", I think? With that:

Acked-by: Kees Cook <redacted>
Right, so that can be:

        } else if (PageHead(page)) {
		/* A compound allocation */
                unsigned long offset = ptr - page_address(page);
                if (offset + n > page_size(page))
                        usercopy_abort("page alloc", NULL, to_user, offset, n);

which saves us calling page_address() twice.  Probably GCC is smart
enough to CSE it anyway, but it also avoids splitting at the 80 column
boundary ;-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help