From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00D5B3F20F4 for ; Fri, 26 Jun 2026 17:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782494952; cv=none; b=bFk0+GJ3iztOKe/6TTjS0CGRFvUme6TwuGvfgD5pDaHaceyIw5zCRx39pTEkrW5XKL2JpFO4J2Zv696aAL6seB2F+ca1DE8JFf/tzUBZOVONdQkogMzgSXP1b/kGIXVT8jDRRGvc69p5i0WvwEZdA7BCkzn5ifUQxoljOsVO/qg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782494952; c=relaxed/simple; bh=bmnqIteIrsdazyLdwoN0OJVJpD3EaqY64A0zc/yqpkE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A+KPhpkkiQX4ZFGj9w1tlYcyyQFwTYoQqBQXqT4SFlqoiY7cEeer4bodWJw6aGCTJY4JyyRVw9iNd6RWOG5E0yOhsL/+IlFGW/k8jqZfLcfByZbh6v1sjrraPplIt8xTUNawOYNLIWDuHYoxWBhgZrh1BPaOdQ/Ch3M6uhVIiVw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HOVEp9C4; arc=none smtp.client-ip=209.85.210.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HOVEp9C4" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7e951b9524fso858111a34.0 for ; Fri, 26 Jun 2026 10:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782494949; x=1783099749; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=S/VSPjiBxVWzwoGtJrzRhtH5hK8hWcYXUpH5mPgMo2s=; b=HOVEp9C4MoqSx8QJQrG+E4MNqNVoojsAitCvjjTmXtFks9SeYrANVfNXQY5q5AbVeh msqhqUlgJLFyKsQz5qLla0xvKAch0rlZFmNNeNyfCtQLSt4z4ey6YyKNbXNyYEKfUfxO sMnjOqFHzbcPx4djTpEgQdYYRaCMAqcoRLiNLihWZZoRv/BkmRW4FtS8yRrQVxsCOGTe 2OHNDaVwlTQ2rgsN0VAXuSJFj9oTBq28PV6qCREHrktx17n6CLoo8tf4BCJailNrbIIc 0U5jyZRzxKMM9zKWsGuEG1G6iXkOBCVswIuyIaRLzp3cY7KlxEk3JGEvKwk+/N+QIaJd cDcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782494949; x=1783099749; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S/VSPjiBxVWzwoGtJrzRhtH5hK8hWcYXUpH5mPgMo2s=; b=Or1IzOx4+5G1vF9hgxqVwo05lXDhryg5hBbZjj1FY4WbOWAJF1sPPZofHCV26frkWC 7jFEJuk1yUYWpnIdSPdUJvKYmhmnMNGn6JwvkeweTnaq27+NZUtwaWtlNpZgsk/7zv7Q Ciz3kKjZSvurIFWsSfVfWW0GNAfNtHWfx5HwH1RLTQDcFWOdhk+aBNNhI64jGMUksL2M IzneTAD0jbTzyeB9axv4TvBXTdDw+oB4RKWQ4eKj7IikQkQ0pv32c8TJy46wSLDzszYP AlI31hDJJDPa+uTQ8jthIl1w6S7WqKwjnVkRJPDizVsTRoZNfDcagkLxDAgQKWc+f8k3 +YKg== X-Forwarded-Encrypted: i=1; AFNElJ9dRDWxRjNJnUwBU1cQYN0cJnTooKpfyYqjRE2I7+jkl9xp4RXhL+Ae8VQNok34hwSn3oyxb6YYWTXuS9Q=@vger.kernel.org X-Gm-Message-State: AOJu0YyeNXVT0OT6KZ9MVURgkJ9ZZDDfjEbmNv5CRDChuWzhY6Iaw5cV gJgldREz9OxRT3dWnCa/bs/DNRKdyEQ9iOMVsxdOD+sBFdmLtk8u8SJg X-Gm-Gg: AfdE7ckE4Mk/0fsidRF0KQupim43+EWSettQO1L6VngDcECxkq0URTJ6+cAYbE3lkSD csSDJO4TGLfCZ2DCSr4teTn5aDR5VJyAzLckr7aUrUxEnU9CwFXLsGOPao85xUo5QC9/PgWxgZr ds++jOHcipffm9b9nMTuWvcMUHGua7bfHRrk09kcM0pQX086GxpUKWPcKHeWGmhnkI2WiltHSeE zrgvBsYsWGNGuEeybChXV3B3Tpe4ctFH5WmHhdOoxIrtNFDjFdnqavuVnBBMT2/jtOrQqoiySrI dvrvyHy9owymcRh8x4GVOhJl9rawyVHSApGBt7sBoQvd0Bxk55GJvSoidxclCAWRGryLJ4b2McZ Harl1seMFPIm7b3NU6eITfZ4Hk/4Mh93BBZGIBSvoRituLOmwE8Py2utG2qhK9H7hYv71sIkO/0 adgS5F X-Received: by 2002:a05:6830:8291:b0:7e6:ed97:ce5a with SMTP id 46e09a7af769-7e99c2ec47cmr6930978a34.4.1782494948915; Fri, 26 Jun 2026 10:29:08 -0700 (PDT) Received: from localhost ([74.80.182.98]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e9aa78751fsm2063757a34.13.2026.06.26.10.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 10:29:08 -0700 (PDT) Date: Fri, 26 Jun 2026 20:29:01 +0300 From: Dan Carpenter To: Doruk Tan Ozturk Cc: Neil Armstrong , Greg Kroah-Hartman , Mauro Carvalho Chehab , Hans Verkuil , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: meson: vdec: fix use-after-free of prev_frame in codec_vp9_rm_noshow_frame() Message-ID: References: <20260626164025.52694-1-doruk@0sec.ai> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260626164025.52694-1-doruk@0sec.ai> On Fri, Jun 26, 2026 at 06:40:25PM +0200, Doruk Tan Ozturk wrote: > codec_vp9_rm_noshow_frame() frees the first non-shown reference frame on > ref_frames_list without excluding vp9->prev_frame. When the previously > decoded frame was a non-show (alt-ref) frame and the current frame is a > non-show inter frame, the freed object is the one vp9->prev_frame still > points to; codec_vp9_set_mpred_mv() then dereferences the stale pointer > (use_prev_frame_mvs and codec_vp9_get_frame_mv_paddr()), a use-after-free. > > The sibling cleanup codec_vp9_show_frame() already guards this pointer > (tmp == vp9->prev_frame); rm_noshow_frame() simply omits the same check. > Add it. > > The fields that drive this path (show_frame, frame_type, intra_only) are > parsed from the VP9 bitstream, so a crafted stream fed to the stateless > decoder can trigger the free-then-use. > > Found by static analysis; not yet runtime-reproduced (Amlogic Meson > hardware required). > > Found by 0sec's autonomous vulnerability analysis (https://0sec.ai). > > Signed-off-by: Doruk Tan Ozturk > --- > drivers/staging/media/meson/vdec/codec_vp9.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/staging/media/meson/vdec/codec_vp9.c b/drivers/staging/media/meson/vdec/codec_vp9.c > index 8e80ecf84..572f418c9 100644 > --- a/drivers/staging/media/meson/vdec/codec_vp9.c > +++ b/drivers/staging/media/meson/vdec/codec_vp9.c > @@ -1247,6 +1247,15 @@ static void codec_vp9_rm_noshow_frame(struct amvdec_session *sess) > if (tmp->show) > continue; > > + /* > + * prev_frame is still referenced by the MV predictor in > + * codec_vp9_set_mpred_mv(); the sibling codec_vp9_show_frame() > + * already excludes it before freeing. Do the same here to avoid > + * a use-after-free of vp9->prev_frame. > + */ > + if (tmp == vp9->prev_frame) > + continue; I have not looked at this code before so I'm speaking from a position of ignorance but codec_vp9_show_frame() checks vp9->cur_frame as well. Shouldn't we check that here as well? regards, dan carpenter