Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4F6B3A1699 for ; Thu, 7 May 2026 19:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778180630; cv=none; b=qyiD3+e3VD4OTcpfcu+honZKWHVkJwfapmcKQFwNDNRHV3qi/CNvZli8PVtI2MyO+bZU0LG0KNE+MtmNoIZuVfeSSJ2RGGa8GvdtxFerZU5/UJk9CYdDTuWqXqnsmmqQxIDijJU5AdWoyeTP9LrjSNMXEblI8aIAjdO2zsORrIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778180630; c=relaxed/simple; bh=EuJdpBXIqHqUyrMPSRb9jNHkXv8kAVPxQmgWwS26MW0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=JD9uiawflzoGk33brdjVt90BrfbyAmSmfEhSO6RCw6ozROmmFRLfGOPN5qGcfqVchRqGJnJUJGFLu6CQb1VHTVIDhF5GlosbzzeteX+PiwHMsA0Qq8DTNNpEV0Cg+LG2bmN9IEZn+ud3hgOg1YsrqRDH33jGAj5QfvN3h0Y7DnM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NA11SsIL; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=uK2GoUle; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NA11SsIL"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="uK2GoUle" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778180628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Da30zB6qHlYB/8upFKz9PSKeDig+zmAcVMkZYstCps=; b=NA11SsILJnnfVsV8RUafxPVMDaGGd9qYs9zwvGyP3Hb0l3cT8fnLsPUnPLRPRSkmsvpfHR 3MQW7de2lW/qQ3W+eTYY+3r4m0322MuSW58HB1QPmtJ3JtaiUTdt7KKtsclZPYE/mkvbSD +a00khZgU0kknz7xpZWbr+eH2uRRiYs= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-hmj8AiJnNlugsC-wfljC1Q-1; Thu, 07 May 2026 15:03:46 -0400 X-MC-Unique: hmj8AiJnNlugsC-wfljC1Q-1 X-Mimecast-MFC-AGG-ID: hmj8AiJnNlugsC-wfljC1Q_1778180626 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-5104b861649so22981001cf.1 for ; Thu, 07 May 2026 12:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778180626; x=1778785426; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=1Da30zB6qHlYB/8upFKz9PSKeDig+zmAcVMkZYstCps=; b=uK2GoUlexjnh/X0a46ezUpzO3yDswzw5PAZmnllwBuPRv4tFFXfltPfplSnPWye8LL 6MKa18Twz0QztZcyvhwHQYeEKWXYvOvS62VzWbn7luWVdvuak1AouUtKv0eggBg717FY PR5I+6sy0zEIYro1WKgVWupv83pL0XARiOQ32Dy1gzXa32BBFOjFfA0n3Ck4dTLj4Ok/ 3SrSFvrJTyyRZPX0Oi15e/WY2hEVU1pRFeB3ioEjNHkH/aLzgamnIdaCdeMhmP/fJ+SN FIqsZ9jbYTbfvxzc0ErOf3XbeNurFnx3H7h3KfKL6SGDLmPV9N9ZbuhUHJiiKc07IHFJ X+9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778180626; x=1778785426; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1Da30zB6qHlYB/8upFKz9PSKeDig+zmAcVMkZYstCps=; b=F5P7jXayoA+NBLnf5vqgdufyEcFHJ6+cnRniD3r7ZLJEFgvD6p7XpNibVMxP/mSmEA MafxoPOXru8wl+TmtRL0fKcCXHJriJChfIAjpRHFEeDMBGP5NDW5hH5DCWi5Xdd+2jeC AwQ28x978c5jMRL4gc3nZ5Y9YAKQSYSk92kLnvs7tvpeem/l2KS5D928KKv6S0LO6iFD Zn5WH2mMNRfa2Ayf446KVDvX9kYAmbjCr+vtjjmAleYW1mFBDb3Pqq/sNoSP8s7WDSQy Ul+lGryjbqacZewSzUTot5vNqWSovPku9qd0assuThL6PdA+QmpxkNCNstrTJVEerGdy U6Pw== X-Forwarded-Encrypted: i=1; AFNElJ/JTcpEggOjDmz4FKGak1KO9OIwiGfXAhg7eXnUrfruHqzjyB0e5ISgdp3iRJum+S4iL+kIO9whNqSpP98=@vger.kernel.org X-Gm-Message-State: AOJu0YytaLW1aNqxkFvTOJup1mO/Jowv2G6+drC1uFpN+YJWzY8vD54J HWYkdrGlUMFkBi2vJD0D1oWO7jXijSxVfeP/k6Mua1xl8e+Y1H3RwqJf21lr8qhndLFyPJF8Cf+ E91KC0LrnQCkqIxmpA6MzMDtqdEeQTnv/Rw5iGskDOZIZtkL9OR9XYKm0vjmuaWFwiw== X-Gm-Gg: AeBDiev2WOJurlpMZ3uHXyCt7QamVgOD0vv0/+tAqZZNAt2mQFw+TgV700aZu6WRboj NccX46uakVH8gzDgzN5KGt8B5EQsaIf5TuqlseqcpLfhpmWOtf0UcKMjBUjTlQshMYKdj4FrhVP p0Ij5HLwpff8Krph9TzcRgrDoMDgZlOvmMvEP4+rcUFOLlwA5uoqr/OftZD9BW9aQBRT+7Op61Z JmR2GzlWR42A60N5TmcugWEG8OICFN5DP8HzUO/kFPI6B45qJmmLpteS7bxF1Y4z8YU3x7K9E2L vvP5/y4IYWk5MVo7lTkWvEGpnpscB01sqpONZvzn/4AoYH/72LRH0bEu/HwRn5meEinkcOfGhFS CKZhhRmLfgUPpU2lNFw== X-Received: by 2002:a05:622a:647:b0:514:5d88:8296 with SMTP id d75a77b69052e-514621d0e45mr126050251cf.52.1778180626136; Thu, 07 May 2026 12:03:46 -0700 (PDT) X-Received: by 2002:a05:622a:647:b0:514:5d88:8296 with SMTP id d75a77b69052e-514621d0e45mr126049701cf.52.1778180625477; Thu, 07 May 2026 12:03:45 -0700 (PDT) Received: from [192.168.8.4] ([100.0.180.93]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-514850cad3csm4919841cf.3.2026.05.07.12.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 12:03:44 -0700 (PDT) Message-ID: Subject: Re: [PATCH] drm/dp/mst: fix OOB reads in remote DPCD/I2C sideband reply parsers From: lyude@redhat.com To: Ashutosh Desai , dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, linux-kernel@vger.kernel.org Date: Thu, 07 May 2026 15:03:44 -0400 In-Reply-To: <20260410034123.2433769-1-ashutoshdesai993@gmail.com> References: <20260410034123.2433769-1-ashutoshdesai993@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi - one comment down below: On Fri, 2026-04-10 at 03:41 +0000, Ashutosh Desai wrote: > drm_dp_sideband_parse_remote_dpcd_read() reads num_bytes from the raw > message and then unconditionally does: >=20 > =C2=A0 memcpy(bytes, &raw->msg[idx], num_bytes); >=20 > without checking that idx + num_bytes <=3D raw->curlen.=C2=A0 raw->msg[] = is > 256 bytes; if a malicious or misbehaving MST hub sets num_bytes > larger > than the remaining payload, the memcpy reads past the received data > into whatever follows in raw->msg[]. >=20 > drm_dp_sideband_parse_remote_i2c_read_ack() has the same flaw and > also > lacked the post-increment idx bounds check (noted with a /* TODO > check */ > comment since the code was introduced). >=20 > Add the missing bounds checks in both functions, consistent with the > pattern used throughout the rest of the sideband parser. >=20 > Signed-off-by: Ashutosh Desai > --- > =C2=A0drivers/gpu/drm/display/drm_dp_mst_topology.c | 8 +++++++- > =C2=A01 file changed, 7 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c > b/drivers/gpu/drm/display/drm_dp_mst_topology.c > index 170113520..9cef6c576 100644 > --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c > +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c > @@ -873,6 +873,8 @@ static bool > drm_dp_sideband_parse_remote_dpcd_read(struct drm_dp_sideband_msg_rx > =C2=A0 idx++; > =C2=A0 if (idx > raw->curlen) > =C2=A0 goto fail_len; > + if (idx + repmsg->u.remote_dpcd_read_ack.num_bytes > raw- > >curlen) > + goto fail_len; Do we need both checks here? It seems like we could just replace the first check with the second check. > =C2=A0 > =C2=A0 memcpy(repmsg->u.remote_dpcd_read_ack.bytes, &raw->msg[idx], > repmsg->u.remote_dpcd_read_ack.num_bytes); > =C2=A0 return true; > @@ -907,7 +909,11 @@ static bool > drm_dp_sideband_parse_remote_i2c_read_ack(struct drm_dp_sideband_msg > =C2=A0 goto fail_len; > =C2=A0 repmsg->u.remote_i2c_read_ack.num_bytes =3D raw->msg[idx]; > =C2=A0 idx++; > - /* TODO check */ > + if (idx > raw->curlen) > + goto fail_len; > + if (idx + repmsg->u.remote_i2c_read_ack.num_bytes > raw- > >curlen) > + goto fail_len; Same here > + > =C2=A0 memcpy(repmsg->u.remote_i2c_read_ack.bytes, &raw->msg[idx], > repmsg->u.remote_i2c_read_ack.num_bytes); > =C2=A0 return true; > =C2=A0fail_len: