Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp239588rdh; Sat, 23 Sep 2023 08:23:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5Dy8ZUO7BkQntaT+or0pdSbAWN5UYB+9MvbcO3ge7z3G9BDwMMb0GdElA+HD3ImlJyhLH X-Received: by 2002:a05:6830:11d2:b0:6b9:a84a:a393 with SMTP id v18-20020a05683011d200b006b9a84aa393mr2804297otq.37.1695482631415; Sat, 23 Sep 2023 08:23:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695482631; cv=pass; d=google.com; s=arc-20160816; b=bjfvisFNYVRT29TduMDSZOhV+X87omLj6hgxdmDSgsFEt4JTUsVPmx+ubiGuQU9/SO TjlmG0fSk9IQTqwbIHfP6qtFnHciANvt4W6Yar/oVqdYtnfwHgW51E+1ljzkHxL8C5Nq /oh5vOjzproUmT742gY6UAQLHq0tn2G9FfZ+VL1vnTPfBuaT7O1QebuHKmPoOCwJIsu4 3iHOJkv75cK/2k2xVpn0VomREuizta08Mq46PO/mHPyx+ZvSzGKVHzXh67M0TuRVfsks K3sjg3Lm585rCKlJlJGRYR1l7iH/SMtL0cDfgtHkUK8zBQ4RdRnWjAb3NiSaGdA+N919 vclg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:dkim-signature; bh=WZ/aGCA500ed2bcHIimQvNXpZhLASpaAWul68HLtyGw=; fh=g7jSnrRPWuhzOBWepNF++uWvlYtvjZCripCmKT0cSkM=; b=A6yQ7aToyaR+e7Egz8XI/5kLSRZCRx7P+MUZe76TQsWuccZu+z0Wu+yOCIJkkfn5Xg n232KrfTD6iMfbjDphkL7lGfnBHcpXUXxOr+dlCrPXGBNFwK82Vp34axzLtFf2Idq2/u cSG8/3U7ELhQqwS/ucn9nX2lwKkV84QABtrnMW6MBM5cuq1OWmGNOS7joQB4bryrDDlB mxKdTXnC/QOdQEB3KMXKbwMOMH+WuQXJE0xCqVNQEmWObepexY3oRpfWr0w/1px5W2yZ u995hcG3Js0Vu/MD0xze0OOEh3uC9Rt65+f3MK70SXzgwtg+uL4oESauV+vrqa8GVOvd /e1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=HIB8IY0k; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id a3-20020a63cd43000000b00573f89ac5a1si5890974pgj.102.2023.09.23.08.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 08:23:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=HIB8IY0k; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id ABBB083CDA63; Sat, 23 Sep 2023 07:24:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231566AbjIWOYV (ORCPT + 99 others); Sat, 23 Sep 2023 10:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbjIWOYU (ORCPT ); Sat, 23 Sep 2023 10:24:20 -0400 Received: from sender-of-o51.zoho.in (sender-of-o51.zoho.in [103.117.158.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62D3919A; Sat, 23 Sep 2023 07:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695478990; cv=none; d=zohomail.in; s=zohoarc; b=T2KBF4yIjalK1ZzDEEM0bNBS6lrf1rzPibf611WAnNH6Vj0xTunIPujntuCeRexyyq9CDzFEumukC8m7vfaN02SKx+VLV/ovHo0wG1yHKmHvFTEI1FxRCePdQ4U5jyMA8Gk0wCA7ekmYJ4QcWIpoIWY7uuE+IqAO09QNiWlZErg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1695478990; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=WZ/aGCA500ed2bcHIimQvNXpZhLASpaAWul68HLtyGw=; b=M77DzljXk6xpQujq654Kk9vs7HCjjuRSTg72l3/lw769poX2mZ9yZpNHro87Gr8TqivW9BHA3j1Kh8o33dWvSKmJg1kIzLn7pEHu5ufAnND563x63wSV8sPVHd+GYE7NP00a75Ng6t+45L+SevUlScckPUU8accni0XFdPUva4s= ARC-Authentication-Results: i=1; mx.zohomail.in; dkim=pass header.i=siddh.me; spf=pass smtp.mailfrom=code@siddh.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695478990; s=zmail; d=siddh.me; i=code@siddh.me; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=WZ/aGCA500ed2bcHIimQvNXpZhLASpaAWul68HLtyGw=; b=HIB8IY0kzqs3Ddq+mTUKr+78Mu8wosEADsTE/bbq6WTrTaXfoYwTkmn1GkjZYGNG uDSd7yQti2nKuCxcr4sz7/knfUb7kCndcoph2Wci1IZzz/cksZxUo5ziHtgHoKQGuEF MD7LhbGa+mGgOA9MFQI3O5JTZZpivQ5xB/zmussQ= Received: from mail.zoho.in by mx.zoho.in with SMTP id 1695478959143581.0852754386215; Sat, 23 Sep 2023 19:52:39 +0530 (IST) Date: Sat, 23 Sep 2023 19:52:39 +0530 From: Siddh Raman Pant To: "Kees Cook" Cc: "David Howells" , "Randy Dunlap" , "Al Viro" , "Christian Brauner" , "Jonathan Corbet" , "Mauro Carvalho Chehab" , "Qian Cai" , "Nathan Chancellor" , "Nick Desaulniers" , "Tom Rix" , "linux-kernel" , "llvm" , "linux-hardening" Message-ID: <18ac26bcc00.365acdab160974.4357076391181710171@siddh.me> In-Reply-To: <20230922175407.work.754-kees@kernel.org> References: <20230922175407.work.754-kees@kernel.org> Subject: Re: [PATCH] watch_queue: Annotate struct watch_filter with __counted_by MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail 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 pete.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 (pete.vger.email [0.0.0.0]); Sat, 23 Sep 2023 07:24:22 -0700 (PDT) X-Spam-Level: ** On Fri, 22 Sep 2023 23:24:08 +0530, 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 watch_filter. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: David Howells > Cc: Randy Dunlap > Cc: Al Viro > Cc: Christian Brauner > Cc: Jonathan Corbet > Cc: Siddh Raman Pant > Cc: Mauro Carvalho Chehab > Cc: Qian Cai > Signed-off-by: Kees Cook Tested with keyutils testsuite. Tested-by: Siddh Raman Pant Thanks, Siddh > --- > include/linux/watch_queue.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/watch_queue.h b/include/linux/watch_queue.h > index 45cd42f55d49..429c7b6afead 100644 > --- a/include/linux/watch_queue.h > +++ b/include/linux/watch_queue.h > @@ -32,7 +32,7 @@ struct watch_filter { > DECLARE_BITMAP(type_filter, WATCH_TYPE__NR); > }; > u32 nr_filters; /* Number of filters */ > - struct watch_type_filter filters[]; > + struct watch_type_filter filters[] __counted_by(nr_filters); > }; > > struct watch_queue { > -- > 2.34.1