Received: by 2002:a05:7412:8d23:b0:f7:29d7:fb05 with SMTP id bj35csp466550rdb; Sat, 16 Dec 2023 17:06:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6X11BOjWnpEs8y10BTlUN1gJLcsw9GgzYB9NpJAxvBLbZAQMAyaHzRDp8CyIuYsS312mK X-Received: by 2002:a05:620a:13c7:b0:77f:2b5e:8dd8 with SMTP id g7-20020a05620a13c700b0077f2b5e8dd8mr14945894qkl.5.1702775187818; Sat, 16 Dec 2023 17:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702775187; cv=none; d=google.com; s=arc-20160816; b=dJgUE5ZbXZVJHbfVHyWnDYWI5oTyRdRAcDOV5dCNF7mv8R966KEi2G0QYmJ2PBZf1u oSFtUSz0eYdfAK3iMFLTxAdLOkuYfcZBim1nAxGQAJmBzsG8e4ogPrlSkEDLa3k5aoBD RoqI1cexlXDwIzK5vgtNtqBy2CjtnbsOCRECEX33K8RpoDD047MvzH7dojaoyNfgBgQU pzZNDn+FjtcvEoi1ILD88dPupgyq8IzOlE7XIuQi9F+aX/bPD053ehBPfP0KhUPYpOpt u///34grA6aLi9/rDZuEL43tOHzUv3HKQAbApF5hcOazSylznUdXUvJjeylvEKOxP/4d ErPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:dkim-signature; bh=k4WycKPSFzunUdkSJRY1N3XmhnoQWoEYL5xkeoe24vI=; fh=lINkvKh5SPWn+5cZk+UB2rJ1W1zpyROIMfMDxghNLnw=; b=jzbJRrSmkrl94h0CqeoVqYSUFV11irAqyXOrjzNcoVk9PL/03l6SqdGJFOW5chgtYa LQygvVlcNbMfkNfOc7Ow9piKyXKSdlGzOPMqXvOrmZtPg4vGHfFOaooqgsYZHdSVxoUv W6g6FwaUYHeCoyPYnZCUYT/mLo8wDRZ3l7OnZOERhstsk89OYA4tW+Y9O2r9lqJX0Jak 1aZCNnAgZsBaWaf+P3sQ3tQZY3bPc7Ocn6/EOpcSD5upMq3wkNNx1c1SnOU99xDRCorZ Ms+cjDbXUlcxqcGzXzvD8qGTCoH7iumvSp1T9vCXWd7TvdYYN3gJG/9G20BvQXZUnK6S pXnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=amZUIfDT; spf=pass (google.com: domain of linux-kernel+bounces-2423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f26-20020ae9ea1a000000b0077dabd5db13si15281009qkg.484.2023.12.16.17.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 17:06:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=amZUIfDT; spf=pass (google.com: domain of linux-kernel+bounces-2423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2423-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 932F61C216D6 for ; Sun, 17 Dec 2023 01:06:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B78391865; Sun, 17 Dec 2023 01:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="amZUIfDT" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 6647E17EB for ; Sun, 17 Dec 2023 01:06:18 +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-f44.google.com with SMTP id 2adb3069b0e04-50e2786e71fso934005e87.0 for ; Sat, 16 Dec 2023 17:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702775176; x=1703379976; darn=vger.kernel.org; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:from:to:cc:subject:date:message-id :reply-to; bh=k4WycKPSFzunUdkSJRY1N3XmhnoQWoEYL5xkeoe24vI=; b=amZUIfDTyJkLgazRup7wqFQS11NgBMNH61g3pUbyHBxO/XWFj1EKmR1Om3tByV2WAq i9+GdH3hc4tUgiWvb6OnLqfxshTeNbm3iCbsJzL+/kivFZfGtWGn/g9RFoSvINXxHaus qu/V3UqzMZq3zzA+nRcr3Pdqdjtol80Be1hsY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702775176; x=1703379976; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=k4WycKPSFzunUdkSJRY1N3XmhnoQWoEYL5xkeoe24vI=; b=jZq2aYhXE60H4bB02vNetssJ5vi5ZfdAcW9TUhEjdXOwtobgqvC8x2f7sTwH1Tk6id SCdGgcod3bLSJqzyI1N0+FUgjO+DTanUbHXlnCr/R3a2Z6zvtdORrm/icLpC/Yhi4KYb ySopLi7dLqDYPqaqaE0hUnLXCZLHuCeq5mImXBAmNFQqATyAAtgitUNAHiNrzUcnzSWW eJdJ2szChcAnXVQ/+WRJBcQNcK1NDT8Q/ElZ3oxnRjzUInisXQyQyfuKuzMbr/JfFc0C KQwGmvAt+AwVe4lQnVmB0B3piXzl8ug8kT0kO++17EpOo8oDMjxZYBi10w5YS1r0RB/1 9P8g== X-Gm-Message-State: AOJu0Yz4Ww03jySv5SHLI1AJTcVbrfNN9vY+LTUqy7hqfqHL7mq/N6OD OCoYhBorZfm9pb9vVj1A5n0Fm5ci6v1urWz4JGlRgw== X-Received: by 2002:a05:6512:33c2:b0:50e:1a9f:3c36 with SMTP id d2-20020a05651233c200b0050e1a9f3c36mr2788651lfg.15.1702775176464; Sat, 16 Dec 2023 17:06:16 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 17 Dec 2023 01:06:16 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20231214123752.v3.1.I9d1afcaad76a3e2c0ca046dc4adbc2b632c22eda@changeid> References: <20231214123752.v3.1.I9d1afcaad76a3e2c0ca046dc4adbc2b632c22eda@changeid> From: Stephen Boyd User-Agent: alot/0.10 Date: Sun, 17 Dec 2023 01:06:16 +0000 Message-ID: Subject: Re: [PATCH v3 1/2] drm/bridge: parade-ps8640: Never store more than msg->size bytes in AUX xfer To: Douglas Anderson , 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 , Thomas Zimmermann , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Quoting Douglas Anderson (2023-12-14 12:37:51) > 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 channel") > Signed-off-by: Douglas Anderson > --- Reviewed-by: Stephen Boyd