From patchwork Wed Feb 28 14:01:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 207875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3364223dyb; Wed, 28 Feb 2024 06:03:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUk/DGRoU6OD7kVYppCUWmROxi0yQqd11tdoiXvOz+jgipF/EQtDMyabY0JrgfUfIx8jTb9ULa/GoP/R8nvK3gPm8HbdQ== X-Google-Smtp-Source: AGHT+IHuYL+SUzPrwaSgPSipt6/mrnPMzZPLr6Ar4LthOVjRKv9MENw44Y5VBeBO5yjv5G7rg0Q9 X-Received: by 2002:a05:6e02:1c46:b0:365:88b:3fc2 with SMTP id d6-20020a056e021c4600b00365088b3fc2mr2192261ilg.4.1709129013320; Wed, 28 Feb 2024 06:03:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709129013; cv=pass; d=google.com; s=arc-20160816; b=sisdGerY5dUCeS8ezxK74PNr29tCcJr3vmnhGdn6Mn3O+kanvzjvYIFZ35Ca2NTB5j nuV2LdXtP4GaXTI8pubN8jYTGcEKexWUsXbMuKp7PWl64VaHv3E/42fv64J4Rcl8opIR FtWOfi/nhiFHEE487e3Zm9jQ2DZQ/1uLEeLfEIi03flMKpPoNMI5WLGd4po7CVnd3cRX GKaMG4+jZoL0iakRppO6f7tsCNDum6tqCNk0jEGxZy65BT0YwYtERjEzAWAgefpg5Gwf Fq73X/qIeyTnUbzsCx4WiXWChGHrAsSMG00tYVVbKYYiY47R/nsclvz+P6ZU1uc1ljdf MHNQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85150-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l13-20020a056e021c0d00b0036421ce7752si3078189ilh.201.2024.02.28.06.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 06:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85150-ouuuleilei=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=@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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85150-ouuuleilei=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 AFA7F289075 for ; Wed, 28 Feb 2024 14:02:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A6881552FD; Wed, 28 Feb 2024 14:02:10 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792151664212211777 X-GMAIL-MSGID: 1792151664212211777 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);