From: Sasha Levin Date: Sun, 5 Jan 2025 22:02:01 +0000 (-0500) Subject: Fixes for 5.10 X-Git-Tag: v5.4.289~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d27ecebfc55001ffde3a2025ca034e6e6bf83d9;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/modpost-fix-input-module_device_table-built-for-64-b.patch b/queue-5.10/modpost-fix-input-module_device_table-built-for-64-b.patch new file mode 100644 index 00000000000..dfbb17103df --- /dev/null +++ b/queue-5.10/modpost-fix-input-module_device_table-built-for-64-b.patch @@ -0,0 +1,93 @@ +From be523fd4b1af2ac1682fac157e28c521928e4e39 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 3 Nov 2024 21:52:57 +0900 +Subject: modpost: fix input MODULE_DEVICE_TABLE() built for 64-bit on 32-bit + host + +From: Masahiro Yamada + +[ Upstream commit 77dc55a978e69625f9718460012e5ef0172dc4de ] + +When building a 64-bit kernel on a 32-bit build host, incorrect +input MODULE_ALIAS() entries may be generated. + +For example, when compiling a 64-bit kernel with CONFIG_INPUT_MOUSEDEV=m +on a 64-bit build machine, you will get the correct output: + + $ grep MODULE_ALIAS drivers/input/mousedev.mod.c + MODULE_ALIAS("input:b*v*p*e*-e*1,*2,*k*110,*r*0,*1,*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*2,*k*r*8,*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*3,*k*14A,*r*a*0,*1,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*3,*k*145,*r*a*0,*1,*18,*1C,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*3,*k*110,*r*a*0,*1,*m*l*s*f*w*"); + +However, building the same kernel on a 32-bit machine results in +incorrect output: + + $ grep MODULE_ALIAS drivers/input/mousedev.mod.c + MODULE_ALIAS("input:b*v*p*e*-e*1,*2,*k*110,*130,*r*0,*1,*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*2,*k*r*8,*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*3,*k*14A,*16A,*r*a*0,*1,*20,*21,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*3,*k*145,*165,*r*a*0,*1,*18,*1C,*20,*21,*38,*3C,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*3,*k*110,*130,*r*a*0,*1,*20,*21,*m*l*s*f*w*"); + +A similar issue occurs with CONFIG_INPUT_JOYDEV=m. On a 64-bit build +machine, the output is: + + $ grep MODULE_ALIAS drivers/input/joydev.mod.c + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*0,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*2,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*8,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*6,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*k*120,*r*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*k*130,*r*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*k*2C0,*r*a*m*l*s*f*w*"); + +However, on a 32-bit machine, the output is incorrect: + + $ grep MODULE_ALIAS drivers/input/joydev.mod.c + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*0,*20,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*2,*22,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*8,*28,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*3,*k*r*a*6,*26,*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*k*11F,*13F,*r*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*k*11F,*13F,*r*a*m*l*s*f*w*"); + MODULE_ALIAS("input:b*v*p*e*-e*1,*k*2C0,*2E0,*r*a*m*l*s*f*w*"); + +When building a 64-bit kernel, BITS_PER_LONG is defined as 64. However, +on a 32-bit build machine, the constant 1L is a signed 32-bit value. +Left-shifting it beyond 32 bits causes wraparound, and shifting by 31 +or 63 bits makes it a negative value. + +The fix in commit e0e92632715f ("[PATCH] PATCH: 1 line 2.6.18 bugfix: +modpost-64bit-fix.patch") is incorrect; it only addresses cases where +a 64-bit kernel is built on a 64-bit build machine, overlooking cases +on a 32-bit build machine. + +Using 1ULL ensures a 64-bit width on both 32-bit and 64-bit machines, +avoiding the wraparound issue. + +Fixes: e0e92632715f ("[PATCH] PATCH: 1 line 2.6.18 bugfix: modpost-64bit-fix.patch") +Signed-off-by: Masahiro Yamada +Stable-dep-of: bf36b4bf1b9a ("modpost: fix the missed iteration for the max bit in do_input()") +Signed-off-by: Sasha Levin +--- + scripts/mod/file2alias.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c +index 1c9c33f491e6..2febe2b8bedb 100644 +--- a/scripts/mod/file2alias.c ++++ b/scripts/mod/file2alias.c +@@ -720,7 +720,7 @@ static void do_input(char *alias, + for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) + arr[i] = TO_NATIVE(arr[i]); + for (i = min; i < max; i++) +- if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) ++ if (arr[i / BITS_PER_LONG] & (1ULL << (i%BITS_PER_LONG))) + sprintf(alias + strlen(alias), "%X,*", i); + } + +-- +2.39.5 + diff --git a/queue-5.10/modpost-fix-the-missed-iteration-for-the-max-bit-in-.patch b/queue-5.10/modpost-fix-the-missed-iteration-for-the-max-bit-in-.patch new file mode 100644 index 00000000000..de405752a4d --- /dev/null +++ b/queue-5.10/modpost-fix-the-missed-iteration-for-the-max-bit-in-.patch @@ -0,0 +1,36 @@ +From 3d293515525bcf30d2eb0d3529502776fd925dee Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 26 Dec 2024 00:33:35 +0900 +Subject: modpost: fix the missed iteration for the max bit in do_input() + +From: Masahiro Yamada + +[ Upstream commit bf36b4bf1b9a7a0015610e2f038ee84ddb085de2 ] + +This loop should iterate over the range from 'min' to 'max' inclusively. +The last interation is missed. + +Fixes: 1d8f430c15b3 ("[PATCH] Input: add modalias support") +Signed-off-by: Masahiro Yamada +Tested-by: John Paul Adrian Glaubitz +Signed-off-by: Sasha Levin +--- + scripts/mod/file2alias.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c +index 2febe2b8bedb..92b9b9e8bf10 100644 +--- a/scripts/mod/file2alias.c ++++ b/scripts/mod/file2alias.c +@@ -719,7 +719,7 @@ static void do_input(char *alias, + + for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) + arr[i] = TO_NATIVE(arr[i]); +- for (i = min; i < max; i++) ++ for (i = min; i <= max; i++) + if (arr[i / BITS_PER_LONG] & (1ULL << (i%BITS_PER_LONG))) + sprintf(alias + strlen(alias), "%X,*", i); + } +-- +2.39.5 + diff --git a/queue-5.10/series b/queue-5.10/series index 3a1f9e58712..9096c0ece71 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -128,3 +128,5 @@ irqchip-gic-correct-declaration-of-percpu_base-point.patch arc-build-try-to-guess-gcc-variant-of-cross-compiler.patch btrfs-locking-remove-the-recursion-handling-code.patch btrfs-don-t-set-lock_owner-when-locking-extent-buffe.patch +modpost-fix-input-module_device_table-built-for-64-b.patch +modpost-fix-the-missed-iteration-for-the-max-bit-in-.patch