Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp59252rdb; Mon, 18 Dec 2023 08:53:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGPpF6+s3LAu0whrnIjbHj/97pYnIEj9TTn/yI65IDCTb4oO684E5hzuxxxk1yYi4/PKHv X-Received: by 2002:a05:6a21:a59d:b0:194:9298:b7a0 with SMTP id gd29-20020a056a21a59d00b001949298b7a0mr171914pzc.27.1702918417399; Mon, 18 Dec 2023 08:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702918417; cv=none; d=google.com; s=arc-20160816; b=t01xpGHHBli/ie6Hximd+8zNfjwi6wIF5qb6h9uu7f//mOv5YnYzMnV2OvsjG3Ie5/ obV3l8J7+qjpm+di2QufzEDvuEr2gaUVaBXm2ZQTUF7yP4JXxRlDVN1jDHeA1cip5C79 /hcwDCfzsEY6Sqn52lTGFl92UgbQVCI2/6WY2qfCJSRpn/KHsz0R45P7tR19TFgE/l8y FYLvpEWt/1nz52LE4zB5HL1lazneEVLeUhspxwYNjW8E9r4UnJRjNVGTEfLV+wDdzkj0 X/QwhWQB1Kt9RmMmRm79/iC4OoMB5f0H3T2xrvtMHes68NiGjhlOasCqJ8j9fZ+PfSVo t75Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=nM0rc7/LDh8NwvQblcAD/SfzUIDE9JpJzu1fXo/7n0Y=; fh=QU4FfD2SqSriZ2lDCblbRotPjA5km8rbCAeDowQShk8=; b=0AArs+rODi7ZgY3AYR9p2f6M7png7+mU+GPAeLurHa/DeYMU5sUxar6bZHnycPWYQ7 icDT3Tpu95EHyKZLu2JJbdqBHRJHPTHrnYPSYztEGzinn2TKuSPsqjzpQwZSyDXSqCO4 4gOIbGasmR5/9pZmVW3y3xSkjJtqqML00kGXqZh8cU5vJDZVRA/iTVRFHhHjage6/NlN BViGh5ziFpcXwRRNsDOtlIeY2GpuRQDF9TEBJx6DsyMhMlMhkbHvQf8HE3pLxCzKedpQ mRf/E+78Cin/YmwvvqxGk8sauBkBCm7nDbcaaOFMiNg1PQYdrqnPSJnKxA7PWKOBlvf2 CPOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S5I3NQIF; spf=pass (google.com: domain of linux-kernel+bounces-4101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4101-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b10-20020a6567ca000000b005c66ca527ffsi2105588pgs.846.2023.12.18.08.53.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S5I3NQIF; spf=pass (google.com: domain of linux-kernel+bounces-4101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4101-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 08979B22196 for ; Mon, 18 Dec 2023 16:53:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01CCF498AB; Mon, 18 Dec 2023 16:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="S5I3NQIF" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 9763C1D148 for ; Mon, 18 Dec 2023 16:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-50e2168ab09so3927615e87.0 for ; Mon, 18 Dec 2023 08:53:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702918401; x=1703523201; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nM0rc7/LDh8NwvQblcAD/SfzUIDE9JpJzu1fXo/7n0Y=; b=S5I3NQIF0tv4DlQny6DDnjgV47VIlda/Cc9tRRCORfB1YEqbspvUZXqLu/kam2tG36 QA1kOWrqQpAJVsIAg6kKm/C869/o8fDayqIQ2U+GfR7BLSUlXQLfbC9CFJKc/WufWmkx wD6176nz8XEnZEbnm/YqxKAYKnaOF74/z9gqw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702918401; x=1703523201; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nM0rc7/LDh8NwvQblcAD/SfzUIDE9JpJzu1fXo/7n0Y=; b=rQl0VOYy51toS0/w8DyXWNnL3vwGi/5J7spGhVysMCs5FVWjBzvjVqXAE5XMGrNhoP abthg6HJ4cqyPMV/s8aT+vjWSdxhAcjndEOq9Z43HCWyfK5UwVW8WAq4RlfUkOSm/+HD z/AFb5FYd/5n5V6zBMpcY3joFVcdmtxoLGtitL7hIRQ5G0TxQzF8pABFCmDv11S+mRla AZT2Ph/FUcL4gQV08nB8xzNQP5qtknGPK0esMk7Xoj8Z+ZBLDVeGAy6ppGeNHyVRuJWE HJd50UdoKck6iOk/I24UBryuCMWg0wwMLDfKZd/2MYa9Jo7nglAFoMizqerbrrLuZO2g CaFA== X-Gm-Message-State: AOJu0Yw9fInHOGj4axbIw2udMJN6J0GUb2l7h9zdU3YNLq6iOXfqbCZJ QPL04R560uPPlGc6gJyr3sHfwpO4z3mSTlLOeZU2yYU+ X-Received: by 2002:a05:6512:2206:b0:50e:356b:f6b8 with SMTP id h6-20020a056512220600b0050e356bf6b8mr1868019lfu.123.1702918401414; Mon, 18 Dec 2023 08:53:21 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id br29-20020a056512401d00b0050e03392a0bsm2010801lfb.171.2023.12.18.08.53.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 08:53:21 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-50e1f1086fcso6039e87.1 for ; Mon, 18 Dec 2023 08:53:21 -0800 (PST) X-Received: by 2002:a05:600c:3b03:b0:40d:174c:9295 with SMTP id m3-20020a05600c3b0300b0040d174c9295mr213133wms.3.1702918048764; Mon, 18 Dec 2023 08:47:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231214123752.v3.1.I9d1afcaad76a3e2c0ca046dc4adbc2b632c22eda@changeid> In-Reply-To: <20231214123752.v3.1.I9d1afcaad76a3e2c0ca046dc4adbc2b632c22eda@changeid> From: Doug Anderson Date: Mon, 18 Dec 2023 08:47:16 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/2] drm/bridge: parade-ps8640: Never store more than msg->size bytes in AUX xfer To: dri-devel@lists.freedesktop.org Cc: Guenter Roeck , Andrzej Hajda , Daniel Vetter , David Airlie , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Philip Chen , Robert Foss , Sam Ravnborg , Stephen Boyd , Thomas Zimmermann , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Thu, Dec 14, 2023 at 12:38=E2=80=AFPM Douglas Anderson wrote: > > While testing, I happened to notice a random crash that looked like: > > Kernel panic - not syncing: stack-protector: > Kernel stack is corrupted in: drm_dp_dpcd_probe+0x120/0x120 > > Analysis of drm_dp_dpcd_probe() shows that we pass in a 1-byte buffer > (allocated on the stack) to the aux->transfer() function. Presumably > if the aux->transfer() writes more than one byte to this buffer then > we're in a bad shape. > > Dropping into kgdb, I noticed that "aux->transfer" pointed at > ps8640_aux_transfer(). > > Reading through ps8640_aux_transfer(), I can see that there are cases > where it could write more bytes to msg->buffer than were specified by > msg->size. This could happen if the hardware reported back something > bogus to us. Let's fix this so we never write more than msg->size > bytes. We'll still read all the bytes from the hardware just in case > the hardware requires it since the aux transfer data comes through an > auto-incrementing register. > > NOTE: I have no actual way to reproduce this issue but it seems likely > this is what was happening in the crash I looked at. > > Fixes: 13afcdd7277e ("drm/bridge: parade-ps8640: Add support for AUX chan= nel") > Signed-off-by: Douglas Anderson Since the patch fixes a crash, has two Reviews (even if they're both from @chromium), and doesn't seem controversial, I didn't want a full week and just landed it in drm-misc-fixes. If anyone is upset by this then please shout and we can revert or I can post a followup patch. 3164c8a70073 drm/bridge: parade-ps8640: Never store more than msg->size bytes in AUX xfer