mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 12:03:54 +02:00
During concurrency testing, multiple instances can run in parallel, and
each instance uses its own inst->lock while the core->lock protects the
list of active instances. The race happens because these locks cover
different scopes, inst->lock protects only the internals of a single
instance, while the Macro Blocks Per Frame (MBPF) checker walks the
core list under core->lock and reads fields like fmt_src->width and
fmt_src->height. At the same time, iris_close() may free fmt_src and
fmt_dst under inst->lock while the instance is still present in the core
list. This allows a situation where the MBPF checker, still iterating
through the core list, reaches an instance whose fmt_src was already
freed by another thread and ends up dereferencing a dangling pointer,
resulting in a use-after-free. This happens because the MBPF checker
assumes that any instance in the core list is fully valid, but the
freeing of fmt_src and fmt_dst without removing the instance from the
core list is not correct.
The correct ordering is to defer freeing fmt_src and fmt_dst until after
the instance has been removed from the core list and all teardown under
the core lock has completed, ensuring that no dangling pointers are ever
exposed during MBPF checks.
Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Fixes: 5ad964ad56 ("media: iris: Initialize and deinitialize encoder instance structure")
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
25 lines
969 B
C
25 lines
969 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
*/
|
|
|
|
#ifndef __IRIS_VDEC_H__
|
|
#define __IRIS_VDEC_H__
|
|
|
|
struct iris_inst;
|
|
|
|
int iris_vdec_inst_init(struct iris_inst *inst);
|
|
int iris_vdec_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f);
|
|
int iris_vdec_try_fmt(struct iris_inst *inst, struct v4l2_format *f);
|
|
int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f);
|
|
int iris_vdec_validate_format(struct iris_inst *inst, u32 pixelformat);
|
|
int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_event_subscription *sub);
|
|
void iris_vdec_src_change(struct iris_inst *inst);
|
|
int iris_vdec_streamon_input(struct iris_inst *inst);
|
|
int iris_vdec_streamon_output(struct iris_inst *inst);
|
|
int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf);
|
|
int iris_vdec_start_cmd(struct iris_inst *inst);
|
|
int iris_vdec_stop_cmd(struct iris_inst *inst);
|
|
|
|
#endif
|