* [PATCH AUTOSEL 5.4 1/4] tracing: Add NULL checks for buffer in ring_buffer_free_read_page()
@ 2023-03-01 16:30 Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration Sasha Levin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sasha Levin @ 2023-03-01 16:30 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Jia-Ju Bai, TOTE Robot, Steven Rostedt, Sasha Levin, mhiramat,
linux-trace-kernel
From: Jia-Ju Bai <baijiaju1990@gmail.com>
[ Upstream commit 3e4272b9954094907f16861199728f14002fcaf6 ]
In a previous commit 7433632c9ff6, buffer, buffer->buffers and
buffer->buffers[cpu] in ring_buffer_wake_waiters() can be NULL,
and thus the related checks are added.
However, in the same call stack, these variables are also used in
ring_buffer_free_read_page():
tracing_buffers_release()
ring_buffer_wake_waiters(iter->array_buffer->buffer)
cpu_buffer = buffer->buffers[cpu] -> Add checks by previous commit
ring_buffer_free_read_page(iter->array_buffer->buffer)
cpu_buffer = buffer->buffers[cpu] -> No check
Thus, to avod possible null-pointer derefernces, the related checks
should be added.
These results are reported by a static tool designed by myself.
Link: https://lkml.kernel.org/r/20230113125501.760324-1-baijiaju1990@gmail.com
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/ring_buffer.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 11e8189dd8ae9..58809fffc8171 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -4769,11 +4769,16 @@ EXPORT_SYMBOL_GPL(ring_buffer_alloc_read_page);
*/
void ring_buffer_free_read_page(struct ring_buffer *buffer, int cpu, void *data)
{
- struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
+ struct ring_buffer_per_cpu *cpu_buffer;
struct buffer_data_page *bpage = data;
struct page *page = virt_to_page(bpage);
unsigned long flags;
+ if (!buffer || !buffer->buffers || !buffer->buffers[cpu])
+ return;
+
+ cpu_buffer = buffer->buffers[cpu];
+
/* If the page is still in use someplace else, we can't reuse it */
if (page_ref_count(page) > 1)
goto out;
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration
2023-03-01 16:30 [PATCH AUTOSEL 5.4 1/4] tracing: Add NULL checks for buffer in ring_buffer_free_read_page() Sasha Levin
@ 2023-03-01 16:30 ` Sasha Levin
2023-03-01 16:31 ` Ard Biesheuvel
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 3/4] firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 3 Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 4/4] mfd: arizona: Use pm_runtime_resume_and_get() to prevent refcnt leak Sasha Levin
2 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2023-03-01 16:30 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Johan Hovold, Ard Biesheuvel, Sasha Levin, linux-efi
From: Johan Hovold <johan+linaro@kernel.org>
[ Upstream commit 0217a40d7ba6e71d7f3422fbe89b436e8ee7ece7 ]
Add the missing sanity check to efivars_register() so that it is no
longer possible to override an already registered set of efivar ops
(without first deregistering them).
This can help debug initialisation ordering issues where drivers have so
far unknowingly been relying on overriding the generic ops.
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/efi/vars.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index a32d15b2928f7..87cbcbea40e90 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -1182,19 +1182,28 @@ int efivars_register(struct efivars *efivars,
const struct efivar_operations *ops,
struct kobject *kobject)
{
+ int rv;
+
if (down_interruptible(&efivars_lock))
return -EINTR;
+ if (__efivars) {
+ pr_warn("efivars already registered\n");
+ rv = -EBUSY;
+ goto out;
+ }
+
efivars->ops = ops;
efivars->kobject = kobject;
__efivars = efivars;
pr_info("Registered efivars operations\n");
-
+ rv = 0;
+out:
up(&efivars_lock);
- return 0;
+ return rv;
}
EXPORT_SYMBOL_GPL(efivars_register);
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH AUTOSEL 5.4 3/4] firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 3
2023-03-01 16:30 [PATCH AUTOSEL 5.4 1/4] tracing: Add NULL checks for buffer in ring_buffer_free_read_page() Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration Sasha Levin
@ 2023-03-01 16:30 ` Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 4/4] mfd: arizona: Use pm_runtime_resume_and_get() to prevent refcnt leak Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2023-03-01 16:30 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Darrell Kavanagh, Hans de Goede, Ard Biesheuvel, Sasha Levin,
tglx, mingo, bp, dave.hansen, x86
From: Darrell Kavanagh <darrell.kavanagh@gmail.com>
[ Upstream commit e1d447157f232c650e6f32c9fb89ff3d0207c69a ]
Another Lenovo convertable which reports a landscape resolution of
1920x1200 with a pitch of (1920 * 4) bytes, while the actual framebuffer
has a resolution of 1200x1920 with a pitch of (1200 * 4) bytes.
Signed-off-by: Darrell Kavanagh <darrell.kavanagh@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kernel/sysfb_efi.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c
index 653b7f617b61b..9ea65611fba0b 100644
--- a/arch/x86/kernel/sysfb_efi.c
+++ b/arch/x86/kernel/sysfb_efi.c
@@ -264,6 +264,14 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
"Lenovo ideapad D330-10IGM"),
},
},
+ {
+ /* Lenovo IdeaPad Duet 3 10IGL5 with 1200x1920 portrait screen */
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
+ "IdeaPad Duet 3 10IGL5"),
+ },
+ },
{},
};
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH AUTOSEL 5.4 4/4] mfd: arizona: Use pm_runtime_resume_and_get() to prevent refcnt leak
2023-03-01 16:30 [PATCH AUTOSEL 5.4 1/4] tracing: Add NULL checks for buffer in ring_buffer_free_read_page() Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 3/4] firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 3 Sasha Levin
@ 2023-03-01 16:30 ` Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2023-03-01 16:30 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Liang He, Charles Keepax, Lee Jones, Sasha Levin, patches
From: Liang He <windhl@126.com>
[ Upstream commit 4414a7ab80cebf715045e3c4d465feefbad21139 ]
In arizona_clk32k_enable(), we should use pm_runtime_resume_and_get()
as pm_runtime_get_sync() will increase the refcnt even when it
returns an error.
Signed-off-by: Liang He <windhl@126.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230105061055.1509261-1-windhl@126.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/mfd/arizona-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 3ff872c205eeb..07d256e6875c0 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -45,7 +45,7 @@ int arizona_clk32k_enable(struct arizona *arizona)
if (arizona->clk32k_ref == 1) {
switch (arizona->pdata.clk32k_src) {
case ARIZONA_32KZ_MCLK1:
- ret = pm_runtime_get_sync(arizona->dev);
+ ret = pm_runtime_resume_and_get(arizona->dev);
if (ret != 0)
goto err_ref;
ret = clk_prepare_enable(arizona->mclk[ARIZONA_MCLK1]);
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration Sasha Levin
@ 2023-03-01 16:31 ` Ard Biesheuvel
0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2023-03-01 16:31 UTC (permalink / raw)
To: Sasha Levin; +Cc: linux-kernel, stable, Johan Hovold, linux-efi
On Wed, 1 Mar 2023 at 17:30, Sasha Levin <sashal@kernel.org> wrote:
>
> From: Johan Hovold <johan+linaro@kernel.org>
>
> [ Upstream commit 0217a40d7ba6e71d7f3422fbe89b436e8ee7ece7 ]
>
> Add the missing sanity check to efivars_register() so that it is no
> longer possible to override an already registered set of efivar ops
> (without first deregistering them).
>
> This can help debug initialisation ordering issues where drivers have so
> far unknowingly been relying on overriding the generic ops.
>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
NAK this is not a bugfix.
> ---
> drivers/firmware/efi/vars.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index a32d15b2928f7..87cbcbea40e90 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -1182,19 +1182,28 @@ int efivars_register(struct efivars *efivars,
> const struct efivar_operations *ops,
> struct kobject *kobject)
> {
> + int rv;
> +
> if (down_interruptible(&efivars_lock))
> return -EINTR;
>
> + if (__efivars) {
> + pr_warn("efivars already registered\n");
> + rv = -EBUSY;
> + goto out;
> + }
> +
> efivars->ops = ops;
> efivars->kobject = kobject;
>
> __efivars = efivars;
>
> pr_info("Registered efivars operations\n");
> -
> + rv = 0;
> +out:
> up(&efivars_lock);
>
> - return 0;
> + return rv;
> }
> EXPORT_SYMBOL_GPL(efivars_register);
>
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-01 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01 16:30 [PATCH AUTOSEL 5.4 1/4] tracing: Add NULL checks for buffer in ring_buffer_free_read_page() Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 2/4] efi: efivars: prevent double registration Sasha Levin
2023-03-01 16:31 ` Ard Biesheuvel
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 3/4] firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 3 Sasha Levin
2023-03-01 16:30 ` [PATCH AUTOSEL 5.4 4/4] mfd: arizona: Use pm_runtime_resume_and_get() to prevent refcnt leak Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®