Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp978995lqm; Thu, 2 May 2024 01:15:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrVPyZTwi3N7pu9nF4LNjlVXPo+WyyXIvrs5MgGaekNrQFLPz3kPeQ8pOCXpx1sSgueSZOF1VEM0xIxHR6BpPb0eL9I5zJBSPE9IznKA== X-Google-Smtp-Source: AGHT+IGHNzsVQdR2Shx5Xza3laDmblniUqg+ZyGxvkgAXrhRuOgeaiRS0fg9HpMKeOMftl1p+wIE X-Received: by 2002:a05:6870:d8d2:b0:235:3d0:2bd4 with SMTP id of18-20020a056870d8d200b0023503d02bd4mr5319103oac.31.1714637731013; Thu, 02 May 2024 01:15:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714637730; cv=pass; d=google.com; s=arc-20160816; b=kRIv8gR2IS+DfxnZEWeFaVgoerNvcmu3ntBB0QWNiGl2EZTz5AhZsPWrHOYb/8ezZk cWOhajDDzIjGHrY/yGppL95nE52zYmdlkURHczd12LvX0tm1QR5LZduNypPA5t4YTlED dno3lkn54audsKBONLCH6shXixwSrz4dWNY7320PQQg+ftP109Fi3ytG8odpmN9/Jl66 gAzAxlbDW5FcDbrzjcrmYuFUG5hbqD9mKZM08B/HfBSxpCHpuZ2TBiG/VR/OBVKI5evW GNHrvo2I2pSFb/xDLemDokmBmqUToLVxT5HskYu4ZRNv7Y5JlqBAOP0N0KocuLaPASuU dRvg== ARC-Message-Signature: i=2; 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=ksrXWA++hq4uo5b14CGOhlwMbP35YcH8qiFN3VUhLdo=; fh=WA209u2SR7o+rmui9vEFPdks+BzMkOWDb2fKXBa2rC0=; b=orgHn+uBrxfHSgunVCCxvTF/Weifs79gZxsDUqzqfiLHJVgboxtHDLQ3Z/PjUZk8Im g7MbzbiqSeeJvl0vQfH/lNFyPIrm9QTEl6IUYvraJiDkEtNLapJLTgcwi8UTCeyFd4VP aVvmSMMfWgCWtbMywUKFFnkoaxiEixqNzfKCxQatYODbvcw5vSU+vcfM23YIit7UNENy qeNOTUoPMSm4IVgh9UJ0cUnYGg3iIiPnT6RvhnDZjUOyhn0kfFDbGj4WhEroadrwGqj0 SYap4p5SnHfcAarG4pe20FOM5luTcYWWQ/7YAUtNaPA8hGbJspd6N2qSEd7tJJSvsrjE cvdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kBbCqZEh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-166102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b29-20020a63715d000000b0060cdd1697c3si551319pgn.511.2024.05.02.01.15.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 01:15:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kBbCqZEh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-166102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A03F328303F for ; Thu, 2 May 2024 08:15:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F23F42E859; Thu, 2 May 2024 08:15:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kBbCqZEh" Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (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 AC89128E11 for ; Thu, 2 May 2024 08:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714637724; cv=none; b=SziaPzbSLFBIAPtueXamHxRWIcujTzPRGGqO/dr2Aof8bQNOasCq/IZXDILgkKVVq54TV6HQvjNsfqluNsK1oLYeF+tKiB3wsK8rno4mTKL8YSPJGB1b5KU+1sUeNpk7An/ftvbL3ME6mFAX9osSYzRAKVZjZT5AHB/JZjA0JUk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714637724; c=relaxed/simple; bh=ZtDqgAXYiT02MT1jYbSADdleWVaaJVqj8qyuZIZtBv4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=LF4m9YLwTITiKSOfOgmixXJsn3gwN89jpWVpSQFLuUH2FE4x2IdFRcmr/prgzfOV6gs6P1DYqx+t0WMkQ2yowEAIKX5rM8REbDyri22b3xJhRvELK5IFj+hPhmawjZTv9Duvu8Q8Q3uO0WR2XPIGEZbmgv9HoS0V+ZSLZ4NJ8Gk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kBbCqZEh; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-61be4b98766so36287907b3.3 for ; Thu, 02 May 2024 01:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714637722; x=1715242522; 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=ksrXWA++hq4uo5b14CGOhlwMbP35YcH8qiFN3VUhLdo=; b=kBbCqZEhM0nejAJkj8NYj39JbSxBU4YYdj1UTkMZVMZ3K8fErst+LxSsrEKtXsOTo9 ytKMNBqdxiYqXB64azeTE/+J8QV23O3umjFtAzJ3LHQY6jTUwfoetAN8MAJTGJyDIqxa I3MN3HW+b0Jz9t8j6m7j20ZhL75R4ymaHmG2cOyc0asbcYbJBsM2roqk/WBq7Q6H9pFh tKd3G7SplytuMIt3pZyIeDV0EQ8zthG41uAy9UP3tL4CBQzrM8UdXlISITWpNM6g+LNY aDxvOosPgdeXktCnzp0emM+2x31EK4AXx9nkmbofEMs6MeBi3oqgbswh5Lw6Iyhjvl9Q An3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714637722; x=1715242522; 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=ksrXWA++hq4uo5b14CGOhlwMbP35YcH8qiFN3VUhLdo=; b=eJcZqV2RgNDFZT1p9ILOj3sTIo5UKB8ljZcSkx8e5mAcHqqtlMd8rV78rgZpQIkf7b cwp5p8D4yMaFwzcRo92vPqkdlExJ3AzmEqRcc8MHrZ2tL/CAj4c3tlk+RpDutuO/d02c b9xWyo6djpyZROojZT1PMHdAMNW4/ZSA4IDdN1D5ek7TGpmkSUsZXQRFlBcIb8qFUVdt maxZXRIjs50VYGfs14PdqsCodqafauFxZVTzDgnaDWG6/ZFMgok5NRAcG6etjkTGcMCa O2Fec4/IlM1ZvvHFmo+jxtwBSyHLBuQxNFhxz0hwBCjDPv5YgmWTjbEzkzMJi50omTv+ 90Zw== X-Forwarded-Encrypted: i=1; AJvYcCUvUR7jcfzTSaiG608oRUHyRIDBqa4RmCPwew5wv/Z04nnqQTZj5twXKTMRjJ8LchSC0ALfX34pgPwLe5c2+V0K0q9pzPD0BwJKl9oi X-Gm-Message-State: AOJu0YxFqjxH09AMgrvwYfEtggAwZYf02M4GC1Yd6gGkKcOpw/IfVuas oXrUgFmBWJTsPb+/KtfYX7Hs18DPpXtLXKP3dvMdUcwNBQJ50j2ldvM6bHD0gAnel+PgH50Ld8t hRgBdlIwdMDnlQqDNjfmTJN+awIRGUcENlXndRQ== X-Received: by 2002:a05:690c:6d93:b0:61a:c4a3:8a5c with SMTP id iw19-20020a05690c6d9300b0061ac4a38a5cmr5471921ywb.44.1714637719772; Thu, 02 May 2024 01:15:19 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240501154251.3302887-1-dianders@chromium.org> <20240501084109.v3.1.I30fa4c8348ea316c886ef8a522a52fed617f930d@changeid> In-Reply-To: <20240501084109.v3.1.I30fa4c8348ea316c886ef8a522a52fed617f930d@changeid> From: Linus Walleij Date: Thu, 2 May 2024 10:15:08 +0200 Message-ID: Subject: Re: [PATCH v3 1/9] drm/mipi-dsi: Fix theoretical int overflow in mipi_dsi_dcs_write_seq() To: Douglas Anderson Cc: dri-devel@lists.freedesktop.org, Jani Nikula , Dmitry Baryshkov , Cong Yang , Hsin-Yi Wang , Brian Norris , Sam Ravnborg , Neil Armstrong , Javier Martinez Canillas , Joel Selvaraj , lvzhaoxiong@huaqin.corp-partner.google.com, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 1, 2024 at 5:43=E2=80=AFPM Douglas Anderson wrote: > The mipi_dsi_dcs_write_seq() macro makes a call to > mipi_dsi_dcs_write_buffer() which returns a type ssize_t. The macro > then stores it in an int and checks to see if it's negative. This > could theoretically be a problem if "ssize_t" is larger than "int". > > To see the issue, imagine that "ssize_t" is 32-bits and "int" is > 16-bits, you could see a problem if there was some code out there that > looked like: > > mipi_dsi_dcs_write_seq(dsi, cmd, <32767 bytes as arguments>); > > ...since we'd get back that 32768 bytes were transferred and 32768 > stored in a 16-bit int would look negative. > > Though there are no callsites where we'd actually hit this (even if > "int" was only 16-bit), it's cleaner to make the types match so let's > fix it. > > Fixes: 2a9e9daf7523 ("drm/mipi-dsi: Introduce mipi_dsi_dcs_write_seq macr= o") > Signed-off-by: Douglas Anderson All right! Nice work. Reviewed-by: Linus Walleij Yours, Linus Walleij