]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.177/dm-fix-to_sector-for-32bit.patch
Linux 3.18.137
[thirdparty/kernel/stable-queue.git] / releases / 4.4.177 / dm-fix-to_sector-for-32bit.patch
1 From 0bdb50c531f7377a9da80d3ce2d61f389c84cb30 Mon Sep 17 00:00:00 2001
2 From: NeilBrown <neil@brown.name>
3 Date: Sun, 6 Jan 2019 21:06:25 +1100
4 Subject: dm: fix to_sector() for 32bit
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: NeilBrown <neil@brown.name>
10
11 commit 0bdb50c531f7377a9da80d3ce2d61f389c84cb30 upstream.
12
13 A dm-raid array with devices larger than 4GB won't assemble on
14 a 32 bit host since _check_data_dev_sectors() was added in 4.16.
15 This is because to_sector() treats its argument as an "unsigned long"
16 which is 32bits (4GB) on a 32bit host. Using "unsigned long long"
17 is more correct.
18
19 Kernels as early as 4.2 can have other problems due to to_sector()
20 being used on the size of a device.
21
22 Fixes: 0cf4503174c1 ("dm raid: add support for the MD RAID0 personality")
23 cc: stable@vger.kernel.org (v4.2+)
24 Reported-and-tested-by: Guillaume Perréal <gperreal@free.fr>
25 Signed-off-by: NeilBrown <neil@brown.name>
26 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29 ---
30 include/linux/device-mapper.h | 2 +-
31 1 file changed, 1 insertion(+), 1 deletion(-)
32
33 --- a/include/linux/device-mapper.h
34 +++ b/include/linux/device-mapper.h
35 @@ -593,7 +593,7 @@ extern struct ratelimit_state dm_ratelim
36 */
37 #define dm_target_offset(ti, sector) ((sector) - (ti)->begin)
38
39 -static inline sector_t to_sector(unsigned long n)
40 +static inline sector_t to_sector(unsigned long long n)
41 {
42 return (n >> SECTOR_SHIFT);
43 }