[PATCH 3/6] Protectable Memory

From
Matthew Wilcox <willy@infradead.org>
Date
2018-03-27 02:31:10
Also in
linux-mm, lkml
Reply to
Igor Stoppa, 2018-03-27
On Tue, Mar 27, 2018 at 04:55:21AM +0300, Igor Stoppa wrote:
quoted hunk ↗ jump to hunk
+static inline void *pmalloc_array_align(struct pmalloc_pool *pool,
+					size_t n, size_t size,
+					short int align_order)
+{
You're missing:

        if (size != 0 && n > SIZE_MAX / size)
                return NULL;
+	return pmalloc_align(pool, n * size, align_order);
+}
quoted hunk ↗ jump to hunk
+static inline void *pcalloc_align(struct pmalloc_pool *pool, size_t n,
+				  size_t size, short int align_order)
+{
+	return pzalloc_align(pool, n * size, align_order);
+}
Ditto.
quoted hunk ↗ jump to hunk
+static inline void *pcalloc(struct pmalloc_pool *pool, size_t n,
+			    size_t size)
+{
+	return pzalloc_align(pool, n * size, PMALLOC_ALIGN_DEFAULT);
+}
If you make this one:

	return pcalloc_align(pool, n, size, PMALLOC_ALIGN_DEFAULT)

then you don't need the check in this function.

Also, do we really need 'align' as a parameter to the allocator functions
rather than to the pool?

I'd just reuse ARCH_KMALLOC_MINALIGN from slab.h as the alignment, and
then add the special alignment options when we have a real user for them.

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thread (10 messages) 10 messages, 3 authors, last reply 2018-03-27
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help