linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 18/47] media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe()
       [not found] <20211108175031.1190422-1-sashal@kernel.org>
@ 2021-11-08 17:50 ` Sasha Levin
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 19/47] media: s5p-mfc: Add checking to s5p_mfc_probe() Sasha Levin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2021-11-08 17:50 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Tuo Li, TOTE Robot, Hans Verkuil, Mauro Carvalho Chehab,
	Sasha Levin, a.hajda, mchehab, linux-arm-kernel, linux-media

From: Tuo Li <islituo@gmail.com>

[ Upstream commit 8515965e5e33f4feb56134348c95953f3eadfb26 ]

The variable pdev is assigned to dev->plat_dev, and dev->plat_dev is
checked in:
  if (!dev->plat_dev)

This indicates both dev->plat_dev and pdev can be NULL. If so, the
function dev_err() is called to print error information.
  dev_err(&pdev->dev, "No platform data specified\n");

However, &pdev->dev is an illegal address, and it is dereferenced in
dev_err().

To fix this possible null-pointer dereference, replace dev_err() with
mfc_err().

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 4b8516c35bc20..80bb58d31c3f6 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1276,7 +1276,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 	spin_lock_init(&dev->condlock);
 	dev->plat_dev = pdev;
 	if (!dev->plat_dev) {
-		dev_err(&pdev->dev, "No platform data specified\n");
+		mfc_err("No platform data specified\n");
 		return -ENODEV;
 	}
 
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH AUTOSEL 4.19 19/47] media: s5p-mfc: Add checking to s5p_mfc_probe().
       [not found] <20211108175031.1190422-1-sashal@kernel.org>
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 18/47] media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe() Sasha Levin
@ 2021-11-08 17:50 ` Sasha Levin
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 38/47] ARM: clang: Do not rely on lr register for stacktrace Sasha Levin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2021-11-08 17:50 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Nadezda Lutovinova, Hans Verkuil, Mauro Carvalho Chehab,
	Sasha Levin, a.hajda, mchehab, linux-arm-kernel, linux-media

From: Nadezda Lutovinova <lutovinova@ispras.ru>

[ Upstream commit cdfaf4752e6915a4b455ad4400133e540e4dc965 ]

If of_device_get_match_data() return NULL,
then null pointer dereference occurs in  s5p_mfc_init_pm().
The patch adds checking if dev->variant is NULL.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 80bb58d31c3f6..0fc101bc58d67 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1281,6 +1281,10 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 	}
 
 	dev->variant = of_device_get_match_data(&pdev->dev);
+	if (!dev->variant) {
+		dev_err(&pdev->dev, "Failed to get device MFC hardware variant information\n");
+		return -ENOENT;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dev->regs_base = devm_ioremap_resource(&pdev->dev, res);
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH AUTOSEL 4.19 38/47] ARM: clang: Do not rely on lr register for stacktrace
       [not found] <20211108175031.1190422-1-sashal@kernel.org>
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 18/47] media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe() Sasha Levin
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 19/47] media: s5p-mfc: Add checking to s5p_mfc_probe() Sasha Levin
@ 2021-11-08 17:50 ` Sasha Levin
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 40/47] ARM: 9136/1: ARMv7-M uses BE-8, not BE-32 Sasha Levin
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl() Sasha Levin
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2021-11-08 17:50 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Masami Hiramatsu, Nick Desaulniers, Steven Rostedt, Sasha Levin,
	linux, nathan, linux-arm-kernel, llvm

From: Masami Hiramatsu <mhiramat@kernel.org>

[ Upstream commit b3ea5d56f212ad81328c82454829a736197ebccc ]

Currently the stacktrace on clang compiled arm kernel uses the 'lr'
register to find the first frame address from pt_regs. However, that
is wrong after calling another function, because the 'lr' register
is used by 'bl' instruction and never be recovered.

As same as gcc arm kernel, directly use the frame pointer (r11) of
the pt_regs to find the first frame address.

Note that this fixes kretprobe stacktrace issue only with
CONFIG_UNWINDER_FRAME_POINTER=y. For the CONFIG_UNWINDER_ARM,
we need another fix.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm/kernel/stacktrace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index d23ab9ec130a3..a452b859f485f 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -53,8 +53,7 @@ int notrace unwind_frame(struct stackframe *frame)
 
 	frame->sp = frame->fp;
 	frame->fp = *(unsigned long *)(fp);
-	frame->pc = frame->lr;
-	frame->lr = *(unsigned long *)(fp + 4);
+	frame->pc = *(unsigned long *)(fp + 4);
 #else
 	/* check current frame pointer is within bounds */
 	if (fp < low + 12 || fp > high - 4)
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH AUTOSEL 4.19 40/47] ARM: 9136/1: ARMv7-M uses BE-8, not BE-32
       [not found] <20211108175031.1190422-1-sashal@kernel.org>
                   ` (2 preceding siblings ...)
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 38/47] ARM: clang: Do not rely on lr register for stacktrace Sasha Levin
@ 2021-11-08 17:50 ` Sasha Levin
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl() Sasha Levin
  4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2021-11-08 17:50 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Arnd Bergmann, Vladimir Murzin, Russell King, Sasha Levin, linux,
	ndesaulniers, wangkefeng.wang, ardb, u.kleine-koenig,
	linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

[ Upstream commit 345dac33f58894a56d17b92a41be10e16585ceff ]

When configuring the kernel for big-endian, we set either BE-8 or BE-32
based on the CPU architecture level. Until linux-4.4, we did not have
any ARMv7-M platform allowing big-endian builds, but now i.MX/Vybrid
is in that category, adn we get a build error because of this:

arch/arm/kernel/module-plts.c: In function 'get_module_plt':
arch/arm/kernel/module-plts.c:60:46: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]

This comes down to picking the wrong default, ARMv7-M uses BE8
like ARMv7-A does. Changing the default gets the kernel to compile
and presumably works.

https://lore.kernel.org/all/1455804123-2526139-2-git-send-email-arnd@arndb.de/

Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm/mm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index b169e580bf829..9738c1f9737c9 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -751,7 +751,7 @@ config CPU_BIG_ENDIAN
 config CPU_ENDIAN_BE8
 	bool
 	depends on CPU_BIG_ENDIAN
-	default CPU_V6 || CPU_V6K || CPU_V7
+	default CPU_V6 || CPU_V6K || CPU_V7 || CPU_V7M
 	help
 	  Support for the BE-8 (big-endian) mode on ARMv6 and ARMv7 processors.
 
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl()
       [not found] <20211108175031.1190422-1-sashal@kernel.org>
                   ` (3 preceding siblings ...)
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 40/47] ARM: 9136/1: ARMv7-M uses BE-8, not BE-32 Sasha Levin
@ 2021-11-08 17:50 ` Sasha Levin
  2021-11-09 13:20   ` Catalin Marinas
  4 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2021-11-08 17:50 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Mark Brown, Catalin Marinas, Will Deacon, Sasha Levin, maz,
	Dave.Martin, tanxiaofei, linux-arm-kernel

From: Mark Brown <broonie@kernel.org>

[ Upstream commit 49ed920408f85fb143020cf7d95612b6b12a84a2 ]

Fixes build problems for configurations with KVM enabled but SVE disabled.

Reported-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20211022141635.2360415-2-broonie@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/include/asm/fpsimd.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index dd1ad3950ef5d..5bd799ea683b4 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -130,6 +130,11 @@ static inline void fpsimd_release_task(struct task_struct *task) { }
 static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
 static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
 
+static inline int sve_max_virtualisable_vl(void)
+{
+	return 0;
+}
+
 static inline int sve_set_current_vl(unsigned long arg)
 {
 	return -EINVAL;
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl()
  2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl() Sasha Levin
@ 2021-11-09 13:20   ` Catalin Marinas
  2021-11-14 14:04     ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2021-11-09 13:20 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Mark Brown, Will Deacon, maz, Dave.Martin,
	tanxiaofei, linux-arm-kernel

On Mon, Nov 08, 2021 at 12:50:25PM -0500, Sasha Levin wrote:
> From: Mark Brown <broonie@kernel.org>
> 
> [ Upstream commit 49ed920408f85fb143020cf7d95612b6b12a84a2 ]
> 
> Fixes build problems for configurations with KVM enabled but SVE disabled.
> 
> Reported-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Link: https://lore.kernel.org/r/20211022141635.2360415-2-broonie@kernel.org
> Signed-off-by: Will Deacon <will@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  arch/arm64/include/asm/fpsimd.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index dd1ad3950ef5d..5bd799ea683b4 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -130,6 +130,11 @@ static inline void fpsimd_release_task(struct task_struct *task) { }
>  static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
>  static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
>  
> +static inline int sve_max_virtualisable_vl(void)
> +{
> +	return 0;
> +}

IIRC this fix was only needed for 5.16-rc1.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl()
  2021-11-09 13:20   ` Catalin Marinas
@ 2021-11-14 14:04     ` Sasha Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2021-11-14 14:04 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-kernel, stable, Mark Brown, Will Deacon, maz, Dave.Martin,
	tanxiaofei, linux-arm-kernel

On Tue, Nov 09, 2021 at 01:20:44PM +0000, Catalin Marinas wrote:
>On Mon, Nov 08, 2021 at 12:50:25PM -0500, Sasha Levin wrote:
>> From: Mark Brown <broonie@kernel.org>
>>
>> [ Upstream commit 49ed920408f85fb143020cf7d95612b6b12a84a2 ]
>>
>> Fixes build problems for configurations with KVM enabled but SVE disabled.
>>
>> Reported-by: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Mark Brown <broonie@kernel.org>
>> Link: https://lore.kernel.org/r/20211022141635.2360415-2-broonie@kernel.org
>> Signed-off-by: Will Deacon <will@kernel.org>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>>  arch/arm64/include/asm/fpsimd.h | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
>> index dd1ad3950ef5d..5bd799ea683b4 100644
>> --- a/arch/arm64/include/asm/fpsimd.h
>> +++ b/arch/arm64/include/asm/fpsimd.h
>> @@ -130,6 +130,11 @@ static inline void fpsimd_release_task(struct task_struct *task) { }
>>  static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
>>  static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
>>
>> +static inline int sve_max_virtualisable_vl(void)
>> +{
>> +	return 0;
>> +}
>
>IIRC this fix was only needed for 5.16-rc1.

I'll drop it, thanks!

-- 
Thanks,
Sasha

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-14 14:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20211108175031.1190422-1-sashal@kernel.org>
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 18/47] media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 19/47] media: s5p-mfc: Add checking to s5p_mfc_probe() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 38/47] ARM: clang: Do not rely on lr register for stacktrace Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 40/47] ARM: 9136/1: ARMv7-M uses BE-8, not BE-32 Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl() Sasha Levin
2021-11-09 13:20   ` Catalin Marinas
2021-11-14 14:04     ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).