Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 B1D0F24676D for ; Wed, 24 Jun 2026 10:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782298414; cv=none; b=eRdtr69nWiLiFhnvQOAmBlRLKDPS/A3QqlEAGfXSyqgDF38dqBhtjbQ7T42jp3hmj19UVnMr3FFrJut45Js7R08+NKXnIYwUG6bjIzbF4GcmsFt8sVPGn2cpGtuNAnpx+hOWlDVS7rqV520tHN+8jBFrtcFBe7fp6E9vhZ+uNj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782298414; c=relaxed/simple; bh=xkSP6rfxVPTJPBs8wkTQDOo+HIrOur4oQF63ZxH39Ok=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=qVzqO2el/YU4dUKfOhCWpOgL8R7Vm43Q1PT7hsoUk94PKO4c45QYo9RsWqEpZyM5p2XPG5qOvyebmvx9aWsfgu9DwPrLmOb3df8uxyn+WvD6NzarxejAOikwAW3Q4QJEplezO5Jwe7HxuqaUdz8dHB1vzpF6tOKnGGp0aoKIvTI= 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=MVMSTZcD; arc=none smtp.client-ip=209.85.214.177 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="MVMSTZcD" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2c6d3851e09so2839295ad.0 for ; Wed, 24 Jun 2026 03:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782298413; x=1782903213; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JWOMe1Vz3W+v517I8b3uSpOSApQ68Rx8tqs3YI+j81M=; b=MVMSTZcDboqfn2KIe/V2xrfFMPoGSikfSbjirvNaxy6/m4tzzGPfJaoHKZuEZpF6sX jCTjQHUcK2rvSdvowRtluswzQQ0b+MRniIPr4JyT7TALVvn38X+SKE1H7XClqeLy2GZG 7V2Nw53uV0r1EASth2fSj0pnRg6KUWo6kGLPkJ4qyhoJD6T2kfeTKY/t5+BYkqAlZh/g qFk8h7a3y6ObmQh7F95OsoMWGwN55d2d3hNA81FEp0jrw3gaF+hqtFyZHw5b6URSNxnl T5qksHCsejuxYqG8PaaSUT21rBNrPv58b8fxUBAS6VoszPtBDF4dFKMgwkPM8SpUhnEV MgJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782298413; x=1782903213; h=mime-version:content-transfer-encoding:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JWOMe1Vz3W+v517I8b3uSpOSApQ68Rx8tqs3YI+j81M=; b=YhpDX9c/NEZJWX1EgAGab+/EYtxb9gawieikeunisJQaGHQLf2X8SnGbP+kAbpPA8+ 0j4N9Rqn/Qyy3BYtOz+IbRjYNAFaAdrTUBiJLgixaEIVwdAN6AYCrluzNQ/pSOuTw1Jl v1G1K0gHzjFUxrqoLgx0j+VfNtdSbMZEeECfod4avunqCWG4AUfwb1CfKMghjIu+The7 jMJD45GEQrd2hsX/sX2vnyZKEzfW0G27z4C1P6iVHHMVAbv0M3mqrHVw8MwKAoQCA7Yg 4y8LjxDUkr8g0ZkSG/xG++sjX0/c1/J9PEtegCsFb9jL/XkG2K1RjTe/qsFufB0wre3S Cr2w== X-Forwarded-Encrypted: i=1; AHgh+Rorci2/mYBJ92zFYvS9Zf940MrkIDr7sfElKs8jQ+arIZ27luVUVNG5NJq+yNqn87mx9YBO780g0+AyvyA=@vger.kernel.org X-Gm-Message-State: AOJu0YyfJmdaTgPIeN/ziw5dCtqNmKNGO0rvk1IqjPFxZUvHreq2VIBT /y4DTsseSx/dIrzNro2FBm/esHIPuVMhNOW8eJ5+Pi/Q4q81dm1j33sd X-Gm-Gg: AfdE7ckVrWWtpYxd+G6E5H7qGWVjOrWfUh8cc0irVMvAL+CErHjD9o/r1bfVjZvLSie G+kc/Y13ilUYRTrfY8ODx9gV0oSCJBLn6qa8Xo+oaHwDy4RlX1AHA3t4BzCQ+LzoDH0ccfVKl06 SwrMlN2ugXaUicoPOlHXY1u3SApr7Gvi405WWng5AbKRsxewFkVBIQeT6VKJEjuLcQpFWCliCz5 NHtj5oQqHf0Wy0ZvRYnOhtyjXOzw7Q9zAXD4YK3WGyp4/4CO0fh8J+W+W00jftwW2Xmsni9c4vy B0lbB9WerSHvBx1EKu5vz0V/z/B+2pvjttn3fFMkJz7Vf0NECvxgGsmhUQ3xpw3GQ3zGb3sV4Rl uJHuetJiKHYpXSTZ/bzBhdm+KX+C1GzVTIp6FCgljwRhICbBCU5h8IgJfBJvWpowLMo0v6eUG2w doSU+DLK0lk6hsSm9eKoYLY1hqkCeiKn5v25zygaIxmniHaCO4 X-Received: by 2002:a17:902:e80d:b0:2bf:9760:b963 with SMTP id d9443c01a7336-2c7e14f24a5mr27464605ad.26.1782298412782; Wed, 24 Jun 2026 03:53:32 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7439f8cfbsm130388285ad.45.2026.06.24.03.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 03:53:32 -0700 (PDT) From: Maoyi Xie To: Andrzej Hajda , Neil Armstrong , Robert Foss Cc: Laurent Pinchart , Douglas Anderson , linux-kernel@vger.kernel.org Subject: drm/bridge: tc358767: AUX read uses an unclamped device length Date: Wed, 24 Jun 2026 18:53:29 +0800 Message-ID: <178229840928.3043295.10662193649777059190@maoyixie.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi all, I think tc_aux_transfer() in drivers/gpu/drm/bridge/tc358767.c can write out of bounds on an AUX read. It uses the byte count the hardware reports as the copy length, without clamping it back to the requested size. I would appreciate it if you could take a look. tc_aux_transfer() first clamps the request to the AUX payload limit: size_t size = min_t(size_t, DP_AUX_MAX_PAYLOAD_BYTES - 1, msg->size); After the transfer it overwrites size with the count the hardware reports: if (size) size = FIELD_GET(AUX_BYTES, auxstatus); AUX_BYTES is GENMASK(15, 8). It can be up to 255. Nothing clamps it again before the read: if (size) return tc_aux_read_data(tc, msg->buffer, size); tc_aux_read_data() reads that many bytes into a fixed stack buffer and then copies them into the caller buffer: u32 auxrdata[DP_AUX_MAX_PAYLOAD_BYTES / sizeof(u32)]; int ret, count = ALIGN(size, sizeof(u32)); ret = regmap_raw_read(tc->regmap, DP0_AUXRDATA(0), auxrdata, count); ... memcpy(data, auxrdata, size); auxrdata is 16 bytes. AUX_BYTES can be as high as 255, which makes count 256. regmap_raw_read then writes past auxrdata on the stack, and the memcpy writes past msg->buffer. AUX_BYTES reflects the downstream DP sink response. tc_aux_transfer is the registered drm_dp_aux transfer handler. It is reached through DPCD and EDID reads, or from userspace through /dev/drm_dp_auxN. So a malicious or buggy sink is the source. ti-sn65dsi86 had the same pattern. It was fixed in aca58eac52b8 ("drm/bridge: ti-sn65dsi86: Never store more than msg->size bytes in AUX xfer"), which clamps the hardware length back to the request. tc358767 fetches the count from the device the same way but does not clamp. I do not have the hardware. A test of the read path with an oversized count trips the stack protector. Does this look like a real overflow to you? Is clamping the reported size back to the request the right fix, like ti-sn65dsi86 did? I am happy to send a patch with the reproducer once you confirm. Kaixuan Li and I found this together. Thanks, Maoyi https://maoyixie.com/