Thread (62 messages) 62 messages, 5 authors, 2021-07-30

Re: [PATCH v15 01/17] block: Add bio_add_folio()

From: Matthew Wilcox <willy@infradead.org>
Date: 2021-07-30 11:32:22
Also in: linux-fsdevel, linux-mm

On Fri, Jul 30, 2021 at 04:25:17PM +0800, Ming Lei wrote:
quoted
+size_t bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
+		size_t off)
+{
+	if (len > UINT_MAX || off > UINT_MAX)
+		return 0;
The added page shouldn't cross 4G boundary, so just wondering why not
check 'if (len > UINT_MAX - off)'?
That check is going to be vulnerable to wrapping, eg
	off = 2^32, len = 512

It would be less vulnerable to wrapping if we cast both sides to
signed long.  But at that point, we're firmly into obscuring the
intent of the check.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help