]> www.infradead.org Git - nvme.git/commit
mm: avoid overflows in dirty throttling logic
authorJan Kara <jack@suse.cz>
Fri, 21 Jun 2024 14:42:38 +0000 (16:42 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 3 Jul 2024 19:29:24 +0000 (12:29 -0700)
commit385d838df280eba6c8680f9777bfa0d0bfe7e8b2
tree53e78e96eebf4ea9dbae916c1c2ab8c6e1f97ef7
parent30139c702048f1097342a31302cbd3d478f50c63
mm: avoid overflows in dirty throttling logic

The dirty throttling logic is interspersed with assumptions that dirty
limits in PAGE_SIZE units fit into 32-bit (so that various multiplications
fit into 64-bits).  If limits end up being larger, we will hit overflows,
possible divisions by 0 etc.  Fix these problems by never allowing so
large dirty limits as they have dubious practical value anyway.  For
dirty_bytes / dirty_background_bytes interfaces we can just refuse to set
so large limits.  For dirty_ratio / dirty_background_ratio it isn't so
simple as the dirty limit is computed from the amount of available memory
which can change due to memory hotplug etc.  So when converting dirty
limits from ratios to numbers of pages, we just don't allow the result to
exceed UINT_MAX.

This is root-only triggerable problem which occurs when the operator
sets dirty limits to >16 TB.

Link: https://lkml.kernel.org/r/20240621144246.11148-2-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Zach O'Keefe <zokeefe@google.com>
Reviewed-By: Zach O'Keefe <zokeefe@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page-writeback.c