Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2565932rbb; Wed, 28 Feb 2024 06:03:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/3rbHY3TFucf2DNBbFkMw0qwnH/UWCmq/u7hEP9TsrCUf01ymWB9+OXKiRrX+MBswkBj7exnDaddJ+qx1lOh3hz8xuamE57kwTkgdGg== X-Google-Smtp-Source: AGHT+IEokWOdLkMpWSuWRyYVnRm4ImCtBp13B8xRm/YYCjL8noKdlcHn7pLzHnZs5Z4cT/u1ZKK6 X-Received: by 2002:a05:622a:110f:b0:42e:64bb:351f with SMTP id e15-20020a05622a110f00b0042e64bb351fmr3418568qty.13.1709128982484; Wed, 28 Feb 2024 06:03:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709128982; cv=pass; d=google.com; s=arc-20160816; b=0xjrZ99OGMyn2jhKTdt3nOL1IRfONio8K7qceJ/znZtiIePN4WEGFFAQp0m9JcYVzG NWF9FiS6XIXq5i6ZWlvKzQGWR7aTKGRiO8IjSwJppamaXY3f9ggu2WLImmalLdTq0UNK BB+QwsenN5aTK3uovm9fBGXjNm0FxHzCrvmRZqJMbCqG3ViAcEoyiNhaMwQ9qkygQiGn yGd5PYXxbj8fJM36lwZ9RltcooJJsT+oIJnTh7/3FgMz7PlydrQs57QHSHb4Bvy73Gsu fSlkxMX2bAeofgmMqsXPGhuwqndMvNgOgi3xs0Scf4LwOQJEmkXVOHim7AF3kkNS5/co wW5g== 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=xH9acuERQIKw/8heDBUpo4U/2frlzxk4m6jGxz4xtvk=; fh=sxnzREYXJhlsZGY86QZhPxY7ThZOXEaQPxfaonHtC+M=; b=RPIhrXh5gmJIp6Nn7vMUwAwNrpAAyVcW4+JgWqk/oIlyezFvkZ1sKYm57bfFjFWwhW fTbRU6BtBpEiSdlm7YYRphvbKbjyNHwk+DpzkLd5HJ8pKvZZ3a+VAULT0idqwuRK4FjE Gf9sfca4R2RJ8eOYooW4dxj6A6DCyuq0cBAj5Ra8bpQ3Rl6C6axHPTYuZ5FKAVJu869+ muQPJ1WIZBC52tKeTVrYSN3ABNsOKW/NNeOSV+mf4eU5LyhFJgQCEENCkNj1Ue9AOHNX gSqyy4vFQwoi7UnTbgp9wmEW/pJJKhp3OHw3S4hPuIusrIGwG9/CAv0sj1XOnQTNfp0f 4tkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JZBoBpj1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 x10-20020ac8538a000000b0042e3c93b998si9421336qtp.608.2024.02.28.06.03.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 06:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85150-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=@kernel.org header.s=k20201202 header.b=JZBoBpj1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85150-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 74ED11C26488 for ; Wed, 28 Feb 2024 14:02:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B4A6155307; Wed, 28 Feb 2024 14:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JZBoBpj1" 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 3A8F0153509; Wed, 28 Feb 2024 14:02:06 +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=1709128927; cv=none; b=Lc0uNjoOyvQhj3iiL0KfSIupofmtfestWrdbubBQHA+Y/nH2SkpOFXAwTb7fyErX8V4T6XwrANfM/GfKLhEHUs23vTEdSxV4JAUUPct1fH2Z4RrbyVhTUWdsIrczp6Z+vBX82KaKZf4HC5CcNHMRpJTIgPCfXtO9qEkhDQCC0ls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128927; c=relaxed/simple; bh=v8piWjx7eAY0lLoFwqlEm66435Li26xyEz8YoqwyhTQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iq9v7toUprYqnLGkT58ueoMcGEi3VQMTEulX5KfW/e4hLEvCKZjXA0VjBOygl0Yotp8QvTrwqDKev5y0WJzL66A6uUaE1jgO+EmFMWTf+scxDfsg35sBqdLJFNEImUfqh3wx1904ZrUbBBl0ctiMA1KE2z96D9cEAYgf2MWspVs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JZBoBpj1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64A7EC433C7; Wed, 28 Feb 2024 14:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709128926; bh=v8piWjx7eAY0lLoFwqlEm66435Li26xyEz8YoqwyhTQ=; h=From:To:Cc:Subject:Date:From; b=JZBoBpj1/3w8VbLj0n2spVtSh9Dn90lTiUjQBWPhL/llNwsZWE4FEIKZ1O+aK9EmG QUioOYYCKmXIVuqLd+ypwjYC0LVp6d/ERGta+GreOP2rrS8vHWLhWyxPFX5DAbWwbB UPx+2kzf9c3nvuCjJ6ldRRPAtAU8cL0l2mlKAqJnM8eyJAeuZMuD5w/GxDY4JcnmC2 0ELr6yF4y7gnIT4Crly95B3nVW+ABTy42C7VsM098zO682kt34TyQ23PWoVnOINgmI +oLRC5b+LE+IGNPHo8/r/aVWzg/+BhY+jKYt/5jmW/9kBOk/Z8kA+q+DhtiV8Ms4G1 NVlMMJx5m9ikQ== From: Arnd Bergmann To: Kees Cook , Jaroslav Kysela , Takashi Iwai , Nathan Chancellor Cc: Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] ALSA: asihpi: work around clang-17+ false positive fortify-string warning Date: Wed, 28 Feb 2024 15:01:45 +0100 Message-Id: <20240228140152.1824901-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 One of the memory copies in this driver triggers a warning about a possible out of range access: In file included from /home/arnd/arm-soc/sound/pci/asihpi/hpimsgx.c:13: /home/arnd/arm-soc/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); | ^ Adding a range check avoids the problem, though I don't quite see why it warns in the first place if clang has no knowledge of the actual range of the type, or why I never saw the warning in previous randconfig tests. Signed-off-by: Arnd Bergmann --- sound/pci/asihpi/hpimsgx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c index d0caef299481..4f245c3956b1 100644 --- a/sound/pci/asihpi/hpimsgx.c +++ b/sound/pci/asihpi/hpimsgx.c @@ -576,6 +576,9 @@ static u16 adapter_prepare(u16 adapter) /* Open the adapter and streams */ u16 i; + if (adapter >= ARRAY_SIZE(rESP_HPI_ADAPTER_OPEN)) + return 0; + /* call to HPI_ADAPTER_OPEN */ hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_OPEN); -- 2.39.2