Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp365829rbb; Sat, 24 Feb 2024 04:11:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTVNuQoHK5Qy93kTO+fNdftCTy6QvzUBgJhWiS2UqMW5/pvPy+U7+bEZFQtJQ8WXed0T7Rds/Agy1z5JPbhV7KkaUjOsKPqMkKMK9QAw== X-Google-Smtp-Source: AGHT+IEcw2c3iYB0KSAF9uWsQAitpZQ4x9fPJkuDFeZkY9xQp4JkAGIbY2GUQa3Kx7POO/W9F61G X-Received: by 2002:a17:903:230f:b0:1dc:8c21:6be7 with SMTP id d15-20020a170903230f00b001dc8c216be7mr307460plh.27.1708776714562; Sat, 24 Feb 2024 04:11:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708776714; cv=pass; d=google.com; s=arc-20160816; b=cD6HLIUyDN8diMZYP938ZFR2BevdB47eRXg9KpoWfVZ6z5qmOBcBRxwUVtGKIPz0/Y EYhzJpqfFF7IvFAU2TBDBF+KK83OYJFFbpilhEgaR8qEYrk/1k0YVbEuOiAXDD9/qJOB 73uLahzIWISMGEIFf7wFROqVFu/iK3fm+p/igFuNLaTlfeBlXt6RC/UkL3h2Q8BOoyIJ HpsoADtn+3y0dSNHvDXlEnQhXQlIBPFMGp04y3ZlQtiKClhPDLek+vmtXtmtz9fUgMeZ yUBHcK1cTEEVJNcN9K2imGbKfH4EvfrihMf7GquBOoFZpxy+20ECO0Az4swH8eOmPNll fv5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Qzv97TQUqNBLJKHPHKcMLZcr/sd6raU0oHRWjSGFSqo=; fh=JgjOWoST60RCJRmMUAJiV3cnmecwob5E3xNCqYpyi0w=; b=EuPQ7eXH3p5e/51tgco+qJDvWglAXm7eStxYZuxl3fQLDi8kQ+Ks9gjbbJLL8cPZO4 9fg+r/pQkklFuESeg+9jwWY2VpfKHefVw5rmBtaFUBEMT0n/+qMRvmeOxyO6RQuXKPW/ lTVa6L3q0Yx9jeYqJIoUwAEll6QPUtBqFXbFykWOoDfQudFyRxp2NY5/X8mWcvlgLwGh 1I/9dvY1qASg7VG4ZIrNZVUC3GDkTg2vBqaArP3Vg6b3eOrfDDe/oDMB8zrVBj7KPU/I Eg+p+UurC6kYqMFL+b//98PK+ykCRtpthkwo2J9vIZ8/ZSKw4d2mlpHlWVpBzFV74S03 uyIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jMYusG9z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79629-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79629-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n5-20020a6543c5000000b005cecb6a1027si831930pgp.702.2024.02.24.04.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 04:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79629-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jMYusG9z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79629-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79629-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 34C29283C17 for ; Sat, 24 Feb 2024 12:11:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0872F3C47E; Sat, 24 Feb 2024 12:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jMYusG9z" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2276D3B79E; Sat, 24 Feb 2024 12:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708776706; cv=none; b=g6mp9N6YA9LyJ0eLeBnfB68huIqTHCRp9x0rHD9MQzp6Ez6iUKGVB3JumZ1E2jWPR7wUaWNpM6R3+ESpAzSd+6dfLMDOYLNJOx+mYQZHGE7eEUySXXo5Fzq7dQ4gHI4qHlobnL28fKRvytvB9obZCoFajIuY+uKx+YOa+r/oqZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708776706; c=relaxed/simple; bh=rpYOVLIlw2+edCfnGPgTidNvVsmfYwWsDaMoVPZVr8E=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IF+Dzp9vRoFu0re0AfrHOjd9SgktBxy6UKRWtAWexklJCjPQeEtxKpNiH3xEif5GMkBRWa1s+fo3/lWz2T9Q7g4LnhFzn00PldxDa4KHyOiVX2MsYI19ikHO1IUiHxymHWSQYps8gPviuT9PXP2Lm0S66Bgb59C0SW895ZjGABY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jMYusG9z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4786FC433F1; Sat, 24 Feb 2024 12:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708776705; bh=rpYOVLIlw2+edCfnGPgTidNvVsmfYwWsDaMoVPZVr8E=; h=From:To:Cc:Subject:Date:From; b=jMYusG9zU120ZBb9vkTnb0qG6A/UiiTaSGVoqNWGurOliBSjvBWVryKy64I+HsV5g ec3yKfFqRpoRkYCyzp4fmpQBvd82X98XRoJZkGt7l80ESU6NovDz6G3SC6R/pxcjUc WWjMesOnL+QL2nUL7rjaJWRaULmaM1/SpDkMNvRO+40HJwmmBWjpOeG/icgHV4kxiJ hfFiCLEyaufNjEirGF2iX50SNMN9EOKoqhZlQC8Waqcb+QJMWMVctgvZMtdkSsdkPY ELCFD8sW8eK/DziA6ATVbxz5xLI/fod5LI0n/s1SzCx+mTXh1wxBX5fFb6ehxdx/9b lZc8XbGFs7ang== From: Arnd Bergmann To: Jonathan Cameron Cc: Arnd Bergmann , Lars-Peter Clausen , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] iio: avoid fortify-string overflow error Date: Sat, 24 Feb 2024 13:11:34 +0100 Message-Id: <20240224121140.1883201-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann The memcpy() call in dlhl60d.c triggers a check with clang-19: In file included from drivers/iio/pressure/dlhl60d.c:11: In file included from include/linux/module.h:17: include/linux/fortify-string.h:553:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning] 553 | __write_overflow_field(p_size_field, size); | ^ It writes into a two member array from a loop over a linked list that likely has some indication of having more than two entries. Add a conditional check there to avoid the overflow. Signed-off-by: Arnd Bergmann --- drivers/iio/pressure/dlhl60d.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/pressure/dlhl60d.c b/drivers/iio/pressure/dlhl60d.c index 28c8269ba65d..a43ecda849db 100644 --- a/drivers/iio/pressure/dlhl60d.c +++ b/drivers/iio/pressure/dlhl60d.c @@ -262,6 +262,8 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private) &st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES, DLH_NUM_DATA_BYTES); i++; + if (i >= ARRAY_SIZE(tmp_buf)) + break; } iio_push_to_buffers(indio_dev, tmp_buf); -- 2.39.2