Commit b86f4b7
dm-integrity: don't modify bio's immutable bio_vec in integrity_metadata()
__bio_for_each_segment assumes that the first struct bio_vec argument
doesn't change - it calls "bio_advance_iter_single((bio), &(iter),
(bvl).bv_len)" to advance the iterator. Unfortunately, the dm-integrity
code changes the bio_vec with "bv.bv_len -= pos". When this code path
is taken, the iterator would be out of sync and dm-integrity would
report errors. This happens if the machine is out of memory and
"kmalloc" fails.
Fix this bug by making a copy of "bv" and changing the copy instead.
Fixes: 7eada90 ("dm: add integrity target")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>1 parent db29d79 commit b86f4b7
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1755 | 1755 | | |
1756 | 1756 | | |
1757 | 1757 | | |
| 1758 | + | |
1758 | 1759 | | |
1759 | 1760 | | |
1760 | 1761 | | |
1761 | 1762 | | |
1762 | | - | |
| 1763 | + | |
1763 | 1764 | | |
1764 | 1765 | | |
1765 | 1766 | | |
| |||
1768 | 1769 | | |
1769 | 1770 | | |
1770 | 1771 | | |
1771 | | - | |
| 1772 | + | |
1772 | 1773 | | |
1773 | 1774 | | |
1774 | 1775 | | |
| |||
1793 | 1794 | | |
1794 | 1795 | | |
1795 | 1796 | | |
1796 | | - | |
1797 | | - | |
1798 | | - | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
1799 | 1800 | | |
1800 | 1801 | | |
1801 | 1802 | | |
| |||
0 commit comments