Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp300076rdh; Sat, 23 Sep 2023 10:52:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcu6eQ9h5Ihj/LFPCYQdy/HaT4ts4q3/V8rlPnfc9+Ik1YTFpZBeuwcMqanXIpyaxetRoW X-Received: by 2002:a05:6808:1381:b0:3a3:9df9:1928 with SMTP id c1-20020a056808138100b003a39df91928mr3784759oiw.17.1695491522613; Sat, 23 Sep 2023 10:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695491522; cv=none; d=google.com; s=arc-20160816; b=qt0/cgsn0/Vgf++NEa+RCDxFpednbkV28q9OqzAWKegwjB5Okwz/f8F+VOmWc48llJ +NEmbWRYnx1qFcNw8zjVIdtaNSsxuIW979nwwuqpfVEMzCaacTreueqhgQVTZSpS/Qt8 4gg6UEovarM0Kg5Aaacu3AeN7Wc5dgelFco6W6unYL85iJsU9REE0KcSKsujXeOiGFET VdBU0Yq4sxa9BSUhWjiPvX1G4tNSMRXsWPUVz5C+R3qZSoN4a2g5+VDco0Hq7F+1pUFf /2Bmh+ZZ3DMd245+VBQMPgDoZMuI+qHW2UTOHc2NtRLZKirOwCwMr1Z9oLycucfxZQQx EYjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=AbimSB8hk16DzrgoId36w3oQpvvCBjP8s4L3OrChrwk=; fh=CO6nlSHbhP7VPCT6RM8aURiQ7k4smhBtSKGnSfk+Lt0=; b=bq1p/dlOf+1AwDlX+Rq7ytmSfv4XPk4nvOBp853v9gOiOsfMQEXAPNr4nYV/NTghG6 oR4VmOCM+148ewV2j1IOWzjh9++3l4RoD1NOR1YgGIHqPQHVt286kV/+H7Ud3WMvbv1J e3415hizFOdRJj2dIe6CC9uLfVxLsv7nM9c04lzOk7SEjdd5ItAJEw7iSZovgXgGajpu 7QvmqT4lNfK/EBEXMQf8/X3/a0QOkX6FzlcqvOM418vcuKe1161LHNLRAS6O1AMh8Jv/ mecq4xdKJ5xcr9URUPoQdIN60Q+DSXs47w6RyzzYDZw7942OHvQIXHZH9Xkf0E0OIlwd Qf0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=FSgtHip3; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f20-20020a637554000000b00578b785d46csi6517388pgn.193.2023.09.23.10.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 10:52:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=FSgtHip3; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 77EDF820178A; Sat, 23 Sep 2023 03:37:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbjIWKht (ORCPT + 99 others); Sat, 23 Sep 2023 06:37:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbjIWKhs (ORCPT ); Sat, 23 Sep 2023 06:37:48 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88AD719E; Sat, 23 Sep 2023 03:37:41 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2A71621EAB; Sat, 23 Sep 2023 10:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695465460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AbimSB8hk16DzrgoId36w3oQpvvCBjP8s4L3OrChrwk=; b=FSgtHip3luYCViGZovKVWsHSPN0VX2a2blYy/xC+gqljYG62O/00ZSVnxCb0Tnizaowt6M LezeQ3fcFIUZiyit2CGchiEsyPdYXt4NBvB1/tjN8Ag+NTcFlEhNOHT9r/Vz5K6R2sUBQI w4bZ+ENmioLZxoKlrjXoqImMMoQiIWs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695465460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AbimSB8hk16DzrgoId36w3oQpvvCBjP8s4L3OrChrwk=; b=xhxIYPE9h96CaZ6x5yIY2m892UkJzxh08cQvg40aBnPpu+kMrOkQaDFSZlyQ08OXb7Xq0W J61W5S3knZddCaBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EDAB31390B; Sat, 23 Sep 2023 10:37:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IS5ROfO/DmUmZwAAMHmgww (envelope-from ); Sat, 23 Sep 2023 10:37:39 +0000 Date: Sat, 23 Sep 2023 12:37:39 +0200 Message-ID: <87fs35b2fg.wl-tiwai@suse.de> From: Takashi Iwai To: Kees Cook Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] ALSA: usx2y: Annotate struct snd_usx2y_urb_seq with __counted_by In-Reply-To: <20230922175046.work.766-kees@kernel.org> References: <20230922175046.work.766-kees@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 23 Sep 2023 03:37:51 -0700 (PDT) X-Spam-Level: ** On Fri, 22 Sep 2023 19:50:47 +0200, Kees Cook wrote: > > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct snd_usx2y_urb_seq. > Additionally, since the element count member must be set before accessing > the annotated flexible array member, move its initialization earlier. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Jaroslav Kysela > Cc: Takashi Iwai > Cc: alsa-devel@alsa-project.org > Signed-off-by: Kees Cook Applied now. Thanks. Takashi