Commit 4ce718f
mm: fix div by zero in bdi_ratio_from_pages
During testing it has been detected, that it is possible to get div by
zero error in bdi_set_min_bytes. The error is caused by the function
bdi_ratio_from_pages(). bdi_ratio_from_pages() calls global_dirty_limits.
If the dirty threshold is 0, the div by zero is raised. This can happen
if the root user is setting:
echo 0 > /proc/sys/vm/dirty_ratio
The following is a test case:
echo 0 > /proc/sys/vm/dirty_ratio
cd /sys/class/bdi/<device>
echo 1 > strict_limit
echo 8192 > min_bytes
==> error is raised.
The problem is addressed by returning -EINVAL if dirty_ratio or
dirty_bytes is set to 0.
[[email protected]: check for -EINVAL in bdi_set_min_bytes() and bdi_set_max_bytes()]
Link: https://lkml.kernel.org/r/[email protected]
[[email protected]: v3]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Stefan Roesch <[email protected]>
Reported-by: cheung wall <[email protected]>
Closes: https://lore.kernel.org/linux-mm/[email protected]/T/#t
Acked-by: David Hildenbrand <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Qiang Zhang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent 59f5910 commit 4ce718f
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
| 695 | + | |
| 696 | + | |
695 | 697 | | |
696 | 698 | | |
697 | 699 | | |
| |||
790 | 792 | | |
791 | 793 | | |
792 | 794 | | |
793 | | - | |
| 795 | + | |
794 | 796 | | |
795 | 797 | | |
796 | 798 | | |
797 | 799 | | |
798 | 800 | | |
799 | 801 | | |
| 802 | + | |
| 803 | + | |
800 | 804 | | |
801 | 805 | | |
802 | 806 | | |
| |||
809 | 813 | | |
810 | 814 | | |
811 | 815 | | |
812 | | - | |
| 816 | + | |
813 | 817 | | |
814 | 818 | | |
815 | 819 | | |
816 | 820 | | |
817 | 821 | | |
818 | 822 | | |
| 823 | + | |
| 824 | + | |
819 | 825 | | |
820 | 826 | | |
821 | 827 | | |
| |||
0 commit comments