From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796224669; b=19KPh12ZjtfBuT0aCmGZlJg0QEqIDRxi0+QepZy7nCwhVyuerql9f60u2i9KM20tLx8U Ns37pJ9JhWX7VceYddS+c4KjnetSNz7Cf7Aa+aUW4UrhOcQUY6ScHK6OGW38xzDQjVrhI pYbRCou6etvH9FID1UhmcLkjFxTWAXc25J3q4OFVGWlKRiXWCoVX/3FcOQsFuUVRDzMMb IKWN33n1bwGvKK2aPsunjyw07GTFI7xn9YZcPvqtPpr+dUOfN3sUoiViaMe9Id1wiaWux utDrAptn6ulyexnLj8vc2r90GF2c9blrX5BF6zh1QB2fIeeefWFh54zLkvw/+kNjZPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796224669; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=J0y+IPajZ34hiyeVK4mleoV1jvPymbuA1+/Llv2zs+M=; b=nF0gQFudKlXTU9x3Obuau8V8lADdQ7V1+boCb09ZeXpTrFeFiiW54sBmHQWmx1GcQuYE RU91/yTslRTF72By0ZhutqRH5Oa4lz1jgmjZedq2VrB/53n7w3VzqsMWNR74FVgKpBw/F Gn75NCIF98/g0faKFDHBx+ByWFcdPdAK4wsNSeuqASQ8Ss08bSJRp3sQXDUQ/B/uu87zM +hwyKorkz100gj1OWKY+Ls+3+Pgbkdjb8TKx83/QLwN1+tf/uQz7y9+C9yj8hG5hoS/H5 tJuiTFyfcJZaV7rDAePSft5Me06op/E3h9ZLockrejEcK6nOXWvK+5deERA0keF2uwg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=iomG58JE; arc=none smtp.remote-ip=74.125.82.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF4EF606A31A for ; Wed, 2 Dec 2026 15:17:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AF4EF606A31A 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.a=rsa-sha256 header.s=20260707 header.b=iomG58JE Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-386cf1041cdso14253634eec.0 for ; Wed, 02 Dec 2026 07:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796224668; x=1796829468; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=J0y+IPajZ34hiyeVK4mleoV1jvPymbuA1+/Llv2zs+M=; b=iomG58JEgoLcht6KMn91/k7FvDJKJc8dL8M/tD+HrSMkFoX/urq/QoH3x46v+zNApa 7XUWiDqBkuxyOPMHFWtsEJbdJy8aeTDyTZb0ntfaxBIHwi6pfE5IAA+jOHsKPvW1CpYI 2bXx0qH7SB4YwXGRn9Euc4+RFi4hDYlRZyAn5Zz987H3JqPgER21ElVD+3qLnpphPk88 poHR0HzRZTq3YuTDwU9oCk56JOt4l18PcRjSEQBXK7unnFk+jltyOpzt9oCQZN18kJiq U1ZdX7lGH6SmxhOdMgdHpmFkuqXjL6GuZZuFRjvrknS2V/rqjIDYkdVPv7PGM5Yi8eye giQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796224668; x=1796829468; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=J0y+IPajZ34hiyeVK4mleoV1jvPymbuA1+/Llv2zs+M=; b=1d+vuGrMZ3qPR29pzg2TPwz20JQkZAoKJyU6RAQGXeo0LZAviN+lfNGLCn+zRup4fs gmirpfAbBT12saH9VpAOAQB9Mez9Oebmb6XW2IbnPbwR/82OInFiNMDfTZFP5iqzrrjh ymiWvJchhKpH/jAShy6V5lv6if65L1sx2xEL61rUNVkNkifXWFOJ9i0DLwxYabyxra2M cz3FPSAMKSLNegiZq77XMOBW516OSJtOlh1ExXi/YCJCd7vehOVXWqqzfr8xo0CdzcDz 2hQdcSzlqCJ1EnWfAzbIKy+erra0rhvdHFikDR/GKGGzmZOQsQ0gZlt4j9MGvaX1QSRL gOxA== X-Forwarded-Encrypted: i=1; AL+hErFd93+frP+sZQeIHg/qWV1CncrnLBPs7N/3cY/zPzIKz62TuiMp6BrNO4F0kdgUh3m/umB/4jusnwfHQVw=@vger.kernel.org X-Gm-Message-State: APuU4Z97rr4c06soqHqAU7qOF6lDeij8zw5xpCy6vwvhrPQ7abhvBwuN ampYs3tk8Vl3Uktqmb+iKqV2TEVXA5CsGC1ajclXVYUev/MBYsm409i2 X-Gm-Gg: AZFdTZcXNHQ9CdLZgA7E+HY0gy3L+MXHT1rWLTcgJfjYvmjHAaeMeCw4Bq3hH2/xvyX Fmw5e6CNAgTln66fIZyxi1cvpIxEqiMMmgQhADlvAdCD3dEOmJnQKOJwwo3RVrgXTEN8115miAs pZFLSTj030n9447sBPqkylt4N51zDiMNG14gOpI5l+eFuNW5PqhAmHHA8e0M9sWtYeIlcZVyxiJ Q37C5wxxVLdV6LL87xBXzfdzOgvdupNt94s/k2A52tnGjD5BiTCV5oVnayhuiTbkyWPKMYH4RBl p8VQvYvZkPlQqt9qsIjvH/YV9W8javBlAngO6ocpaKiXBw4ECSk+fl+Y3m5zaihuwnqhRK3z/K+ k6KNdLAa+wlflDpisMMXBb2TsgfzNOGSOHFNUPpxinGpKh/M/B++NSvBfaaMcIm0/dqTCQl4ph8 cW3zLw7U47k9oTfjD2q9GtV+HXfE+w1nh64XFX2J2DeG87FfB/crzkvNGqSXYLTv/zKOpW21vMa 4PEJTbWxUzk91O0Yk4wv9hIrHJUPT+qpA81TI0jKpYDhdTbLefQMo0OrjlZDD+9+vjdLOucKQeG 5EF8QKGY/FvG5hg4wnWC4hndW4Hrwv3Utl9jPCs6A+qq1j6Z9gWHA/0LslqDXjEXlYPjeyPNc66 Yx5Xa6ufcEeisMQ== X-Received: by 2002:a05:7300:da13:b0:386:d0f0:5f75 with SMTP id 5a478bee46e88-386d0f061famr22729204eec.6.1796224667442; Wed, 02 Dec 2026 07:17:47 -0800 (PST) Received: from hyeonjun-ThinkPad-X13-Gen-1.. ([124.197.199.8]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386aaae4960sm83959681eec.18.2026.12.02.07.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 07:17:46 -0800 (PST) From: Hyeonjun Hong To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: Geert Uytterhoeven , Magnus Damm , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 0/2] media: rcar-isp: Fix ConfigDMA buffer overflow Date: Thu, 3 Dec 2026 00:17:16 +0900 Message-Id: <20261202151718.694973-1-hyeonjunhong330@gmail.com> X-Mailer: git-send-email 2.34.1 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 Content-Transfer-Encoding: 8bit Hi, The bounds check that protects the ConfigDMA buffer of the R-Car ISP core does not account for the 8 byte header, so one address/value pair can be written past the end of the 16384 byte buffer. The number of pairs depends on the parameters buffer queued by userspace on the params video node. Patch 1/2 fixes the check. Patch 2/2 makes buffer preparation fail when the buffer is full, as the result of the write callback is not checked by the rppx1 block handlers. How this was found and tested: - Found by reading the callers of the v4l2-isp helpers side by side, with the help of an LLM (Claude). - I do not have R-Car hardware. The overflow was reproduced only in a userspace model that compiles the unmodified function bodies of risp_conf_dma_prepare(), rppx1_params(), the CCOR block handler and the v4l2-isp validation helpers, built with AddressSanitizer. 170 header-only, disabled CCOR_POST blocks: 2041 pairs, no report. 171 blocks: heap-buffer-overflow, WRITE of size 4, 0 bytes after the 16384 byte region, in risp_conf_dma_prepare(). With the series applied: stops at 2047 pairs (16384 bytes used) and returns -ENOMEM. - Compile tested for arm64 with W=1. - Not tested on hardware. One thing I could not resolve from the code: risp_core_job_prepare() in core.c limits the pair count to (RISP_IO_PARAMS_BUF_SIZE - 8) / 16, i.e. 16 bytes per pair, while core-io.c and vsp1_vspx.c count 8 bytes per pair. With this series a buffer holding 1024..2047 pairs passes buf_prepare and is then rejected when the job is prepared. I left that check alone as I do not know which limit is the intended one. Hyeonjun Hong (2): media: rcar-isp: Account for the header in the ConfigDMA bounds check media: rcar-isp: Fail buffer preparation if the ConfigDMA buffer is full drivers/media/platform/renesas/rcar-isp/core-io.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) base-commit: 62dfd7c0e599b6f02392b117ee77a070796ad765 -- 2.34.1