Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b34e680 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ring-buffer: Prevent overflow of size in ring_buffer_resize()"

parents 62d6ede1 1f7ece29
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1693,14 +1693,13 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
	    !cpumask_test_cpu(cpu_id, buffer->cpumask))
		return size;

	size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
	size *= BUF_PAGE_SIZE;
	nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);

	/* we need a minimum of two pages */
	if (size < BUF_PAGE_SIZE * 2)
		size = BUF_PAGE_SIZE * 2;
	if (nr_pages < 2)
		nr_pages = 2;

	nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
	size = nr_pages * BUF_PAGE_SIZE;

	/*
	 * Don't succeed if resizing is disabled, as a reader might be