From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795782538; b=JclNqJi0pciy6kc8z+cxOiKN3FXn40mMNX9UrPCdJAQtqhOIdvIb80FK344CEbCqnZfm 0z8zZr9XhYunX/zgE90pZC+dtfgyHWX4CoiZw7A8+Z/c2z2q6UHBYzACa65I+Smh1ihPi 27xbAka/YrBdIEnAI3vw22SvTlchxmelsz5LDR3XtdBIGS54fhdDhP5ip+VA41oDlqj46 lS5gfrgUXDjRQLfuZn5bek3svxcRUjGDeExSi1eIxjBW4S8RRBJq5w5HwRESb+6hOA30l R5vVJEjztV2rIqQVlZ9c2M+/JnXpuhYT0VPyqYIqOL+SEGNI7hQOfYkdCmyhuNYGzXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795782538; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=3iHq8357jseZEPfEyY2Z08chWi95v8Y1kHGpmZ69UH8=; b=w/rpXedukh5Mq2J3/nQI6J/Tw5/c55IXoHJCCGwbEJGYg/D5PTBJulYyVzsdTFJTQ59c Speup7uXENO5BwrIC0t9ai2OtKyamDVvUvvxZ3iY7SaN7SIylzfyCy/ldlbdX4hAQuhvR rvSNO149c+HwGGCi3hkWgXP5YHOOAcn6v+6OmZPZD4Jhgq35PIL3IV3moij9xVrhg9CR2 ps0wtvU87I7+mmolwbVHe/xDkIouVcCxmxwB8Hl2kTguTb3/Ld4bNQQwxnNQ354RF1Oy/ 0ULJ0Pn7TWxJMhQGcfcud0n3FhUKL05+aKLoN6weU6NbWLP04jksr2FMTWmsBa+gUnA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=iseZnTaF; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=YX9UkW9u; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A197A606A323 for ; Fri, 27 Nov 2026 12:28:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A197A606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=iseZnTaF; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=YX9UkW9u Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ARApDsG2677325 for ; Fri, 27 Nov 2026 12:28:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 3iHq8357jseZEPfEyY2Z08chWi95v8Y1kHGpmZ69UH8=; b=iseZnTaFgCFpXMMw ec54HP9LDjwx4J65rptPmYVSvR9ZcDicWkOail3UnLs0byHjKYWMNo1GFxsXMMaT AAsG1do/JGmeBEBCBMETqd0rhVBErVyd3aUJADH0blpW0W+mOJYvmWtJpQrsP7yQ 3B/VgyhcB6JI86zaF3nys3t5LqLc/3ygda+RvP3K4DnRHmHIhN6Mxf+mJfy2FXIq a6o/ZmXfdS0TriFMKF6Z64/acVmkRUOyMgXtaHa+CVseJKoBS7qsdwfBSNVRo8pR laT65WJvAbSB9odsyCvwEcSfISbtiCw3URmyrXkSfyvoDXX8g3h8+m8KsxAvmQ6k JdpzLw== Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j74gh9cq1-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 27 Nov 2026 12:28:56 +0000 (GMT) Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-154e9d2d94fso4684274c88.0 for ; Fri, 27 Nov 2026 04:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795782535; x=1796387335; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3iHq8357jseZEPfEyY2Z08chWi95v8Y1kHGpmZ69UH8=; b=YX9UkW9uWFJ0yjsQxmstXaXn1XAWYR/psowJD+faKQZrWab5k7NnRFhYS0lv/fR4xi DTsRPPsoF4xAWtYxNPBUddBktADoTeKoz51IPqXjdwopHmdt/aLAjhX12JrTvkzZxr/i 7/k+B7x3dkSNbNwUQgQDMm1rfJMjBRnZaIUXpRccm6+162euk6F1wcWdexZ5wi9irC9d fHFUfVpoxcKk+3tLJkh2QZjG3dABoGJ8PBCMnamq89zaWCL+W+QMhbWqrZuAFFzr9A0N PyEYh+VFkyYcuD2EHudkWb6MU/hMNx5xb6TmfZjuTpz1KLncAvhF70mPL/YfddFo38aN mNFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795782535; x=1796387335; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3iHq8357jseZEPfEyY2Z08chWi95v8Y1kHGpmZ69UH8=; b=faU3s1ZpOm9JM7JvEqF9ewG3i64vrGbvvgGg2emAAZ/6K8RyhOX0ll4boxJ+qrbHpV fiHloAqd52kqcMBw/nWS9oYF0elfgiQSIZfzsH5kQX8VgXWtn9wk4dUhgQqeybpeqi4J kJH90nyUr/MmO2+8K2HmAQUg9yqthi+XCQL3PTf6Sh/6E8Fxm9vbMH9DhNS3WOsiE58N +jlEyrTElYO7aCUu+tS4jrpQf6XPbZ5MrG3lF5sMyR7Zx4Tt47IgwYws+nEO1geVg9uV Yxy+IoLu8iNzLv53m5gmRzYoV+hRs17YC++BzGGQjVd0pV5+EHiKz4PPrhUQ/y4duV7Q 8eXQ== X-Forwarded-Encrypted: i=1; AL+hErF1p9LIiGxwFhVuOvJg9zip8DaUoz2vE+WgwicdFek3kxFKrNUE+3Umaw6b2ZMrQJjbS8E9VvS1Ijj4nYQ=@vger.kernel.org X-Gm-Message-State: APuU4Z++0IHX7v3dzxf0FUMekiq+5LulzlsTf5lyEtfZiXRVmwcckD06 vEZs/xL8UhKUpxv5hAw7YPQXPhvQlGGp8EeYySo+dSjCKsU5zHNPj4JSjKyQZZB+xeAr4HpgUw2 XF6+HABtLSxNiuwDR+lWNrICRYBQTTJE+27jNliYc7ZGU3ZXYTGfTEHWh7vpAB5zHPu4= X-Gm-Gg: AZFdTZc+LogYdnJ2hUSs9WrnOe4xCAjXc2kZT6pFveK6zljZW0p0dr/iSAI4fWBPsuo s14PDh/BVtx9AvqNglaaj636lMBidnfYNxUbAxjjN9gd1Z70dJNivzpgHAbjx5NunvON6XOck3Y GgukuBWAgaF/uWjtF0KqCa/uMg8W6ZoBzeQY3PGZEChQfS80T0uElcypYSEYC65a+0frnJ1URoi wBNvLsdLHk0Chlg6WKuk7Cr5hfA+x5zTT/27gGrzRk+lVqmPPTD4v1Ws4C/jFYPECgFCp8n/e4F ZhMhKk72x6b9vVxwSuRcuJ2PKAeV4cG+hO9f7osS4P0ItltMGxol8jFzOO2AhewOr0r1fTZd3oS kCNq+ac3ElBQhYfIGsafkFQXuF0heaslIHxQgUg6x4M7vSnvGpKqR2+Ihn0QYI3F0mKU4cl4u5i Pdn5ER X-Received: by 2002:a05:7022:ec17:b0:166:862b:9bcc with SMTP id a92af1059eb24-1b55689ad7amr31111925c88.18.1795782535502; Fri, 27 Nov 2026 04:28:55 -0800 (PST) X-Received: by 2002:a05:7022:ec17:b0:166:862b:9bcc with SMTP id a92af1059eb24-1b55689ad7amr31111888c88.18.1795782534930; Fri, 27 Nov 2026 04:28:54 -0800 (PST) Received: from [10.206.111.23] ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b562a82b3fsm68351064c88.5.2026.11.27.04.28.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Nov 2026 04:28:54 -0800 (PST) Message-ID: <704a4e68-ee5f-4ed3-a975-49c0b131d6b2@oss.qualcomm.com> Date: Fri, 27 Nov 2026 17:58:48 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/4] media: iris: Fix use-after-free on unbind with open sessions To: Vishnu Reddy , Dikshita Agarwal , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , Dmitry Baryshkov , Hungyu Lin Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan O'Donoghue , sashiko-bot , stable@vger.kernel.org References: <20261119-iris-handle-unbind-v3-0-52d467a13907@oss.qualcomm.com> <20261119-iris-handle-unbind-v3-3-52d467a13907@oss.qualcomm.com> Content-Language: en-US From: Vikash Garodia In-Reply-To: <20261119-iris-handle-unbind-v3-3-52d467a13907@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI3MDA0OSBTYWx0ZWRfX4cpkfPugoT6Q NT931jMmY+n5ak6FVu8YFVayDW5rzpizXhB0vjw89vEGc9Ehx0ar4fZJ00qzqYndyqT2+K26u27 mj60nrW9964brgWy781WMLrkaltkF6M= X-Proofpoint-GUID: xQgiK_awnGujNmaP7d15YLm8eq7Ulq6v X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI3MDA0OSBTYWx0ZWRfX+MDEec9Kkubs haUHvRmCT+r1duVHoFLOgk+9SsMuofUNnI+cad+FcjF0YuLEgMlKoMzWz1hhM/Ysfezov8M3ae9 GTIMtx+TntbdaQ4SU1uqpMbntg6o4ft2yM8stjBL7iJRLLZHIrip6WUNa6jfjVAzO9Czr/ngaVl C1joaV7td3JE1RRkWF0mUdhi/DvfXQgBKgPsfkMLnY7GkxJ3HT+B6ghXtEgyzUMruzG30y9g91Z oCkgXaWj3jptQ8zhps3W2ZYwvrrpcC2pq7RAQDYJCmY4wqIymr7A6cdWkv2ngwyPS57mhHz4IrV QXcp6P3v6e9+ZfKW5BFH1eFLN8ZbMf/XQ0hLs5WXe3P+cnoO4//s1w0+qHMG/T4VpvCj2cTE5OX 9zMen+bu3WZA6IZ1UkLEdqj37jqRN1ezbKPZhuTyz3dkSVLx5isd9P6chNT9SpxLBVhhKXqg3Yd LXrkvpJsRw2HoinG9Dw== X-Authority-Analysis: v=2.4 cv=U5kHnuru c=1 sm=1 tr=0 ts=6b097788 cx=c_pps a=kVLUcbK0zfr7ocalXnG1qA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=g8Q9F2srHmfhVmvwUhAA:9 a=QEXdDO2ut3YA:10 a=vr4QvYf-bLy2KjpDp97w:22 X-Proofpoint-ORIG-GUID: xQgiK_awnGujNmaP7d15YLm8eq7Ulq6v X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-27_02,2026-11-26_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611270049 On 11/19/2026 5:15 PM, Vishnu Reddy wrote: > The driver can be unbound through sysfs while a client has a video > session open. The core is devm allocated and freed when remove() > returns, so the open sessions then use freed memory. > > Only the core structure needs to outlive remove(), because it is the > only thing the file operations of an open session still use. Allocate > it with kzalloc and tie it to the reference count of its v4l2_device, > which every registered video device holds. It is freed when the last > file descriptor is closed. The other devm resources (register mapping, > response packet, clocks, power domains, interconnects) are only used by > the power on/off sequence, the clock and bandwidth votes and the > interrupt handler. All of them are released with the unbind, after the > core is shut down. > > To make sure nothing uses them afterwards, set a removing flag at the > start of iris_remove(). It makes core init, new sessions, command > writes and the clock and interconnect votes fail with -ENODEV, so a > client still holding a file descriptor cannot power the hardware on or > vote for resources that are gone. A client waiting for the firmware > only times out and returns an error without touching them. Runtime PM > is also disabled explicitly in iris_remove() instead of with devm, > because its callbacks use the core. > > Callers that hold a runtime PM reference, such as iris_open(), > iris_hfi_queue_cmd_write() and iris_scale_power(), can still be running > when remove() starts, as video_unregister_device() does not wait for > them. Take an rw_semaphore for read around the reference and wait for > it in iris_remove(), so that the references are dropped before runtime > PM is disabled and the unbind releases the resources of the device. > > Fixes: 38506cb7e8d2 ("media: iris: add platform driver for iris video device") > Reported-by: sashiko-bot > Closes:https://lore.kernel.org/all/20260926064921.976721F000FF@smtp.kernel.org > Cc:stable@vger.kernel.org > Signed-off-by: Vishnu Reddy > --- > drivers/media/platform/qcom/iris/iris_core.c | 5 +++ > drivers/media/platform/qcom/iris/iris_core.h | 4 ++ > drivers/media/platform/qcom/iris/iris_hfi_queue.c | 18 ++++++++- > drivers/media/platform/qcom/iris/iris_power.c | 24 +++++++++++- > drivers/media/platform/qcom/iris/iris_probe.c | 48 ++++++++++++++++++----- > drivers/media/platform/qcom/iris/iris_vidc.c | 15 ++++++- > 6 files changed, 102 insertions(+), 12 deletions(-) Reviewed-by: Vikash Garodia