Message ID | 20230922174935.work.699-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp38186vqg; Fri, 22 Sep 2023 19:15:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUpqj31RtlG10z7I9X7z6YF6fnOvccBx3NikY+QZrHu6G4f+U4Zeywzbau5WMLwbuDCM/G X-Received: by 2002:a17:903:443:b0:1bc:7441:d81a with SMTP id iw3-20020a170903044300b001bc7441d81amr892172plb.6.1695435311624; Fri, 22 Sep 2023 19:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695435311; cv=none; d=google.com; s=arc-20160816; b=ap858QNFgi3boyyPok5MYrIjsJkjJMaBQDmrW3lDG6gbZWXvB1VvwivOJNZjYcK0Mm wppTc9JjQNx29HmST1zfufiT3OwOIOH3H9v/cq7DKFpyn+rsCUShOVPftXV6fulILHgy pDzkTan8vJp0RvRyCn9FJpWBVmDvAh26ewbvgOwxNfg03uAmLVs6k+V8NzHv/LvlzMz/ JwgZe5LrS7N6avCanBqHMGkoFpE3+K4DUd14MlPCOdtkVJoM3ZR/WNAgi0YPgWLLV2W3 GgRQsIow2C0lLKaZVRoZKW7BykTIdOmkYr/LLzpt+7KVD/CtrOoLYxTmeXu209JHcAE3 GU5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2o1CYzB6+mJ2+hUW8zCgaKBLo7FrtBAUficPQDkUT8w=; fh=hyDU2Pf63zVDIl9dROD5ufiwq9TwhnyJsMkopT4IBqo=; b=HHLLnSgJJHsaiaW1YOJU0wp4sgRC445vUrqdPhT58libf9JBGyVHcKEVO6G17edL7z JDlkTZhSDhG9vmoBWp+P4zHjGAGWRceyKSXJMwNCI3IFuUvEjp6WOcfAFcvP4Pa6TBH0 QoydxVAvu/j0o+cweBHSeHhGL2vIib/6T9NDGAEYwmNVStMShUUGqQNzfDxwijibrMVq MAPqQe7suoiPcpzhJAsbEsNc1jn+rwaPw23uqa4ePb5QYPShvqi4cWkUc0oRKd3yIlOq 7hUzpPQdKopaE5a1rmqhusmEFXL7kzXjK9Vbep5mRZLOe3Qtn2Q8P1E2CK7iDRkOHvRV wujQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="AQPi46/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s19-20020a170903201300b001c353153012si4814373pla.415.2023.09.22.19.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 19:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="AQPi46/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 09D8683A0B9A; Fri, 22 Sep 2023 10:50:11 -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 S233230AbjIVRt4 (ORCPT <rfc822;pwkd43@gmail.com> + 28 others); Fri, 22 Sep 2023 13:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbjIVRtq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 22 Sep 2023 13:49:46 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AA00CDC for <linux-kernel@vger.kernel.org>; Fri, 22 Sep 2023 10:49:39 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-274c05edb69so1701806a91.2 for <linux-kernel@vger.kernel.org>; Fri, 22 Sep 2023 10:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695404978; x=1696009778; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2o1CYzB6+mJ2+hUW8zCgaKBLo7FrtBAUficPQDkUT8w=; b=AQPi46/AUvV70Ssazv2CulXfb4ZhI+PDQ638pfDYcyciO4ORXl1mU1DB0hMf7jXWxE tF5bZ6Nvptn5kKVtCGy4nnFhFYJdoEmgBasuc1ormUeFrySMCoHl923W4iMxS6aSW3RM EZ9nCogbuu4qH1hksz2v20QyoyZFhP8RYGEEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695404978; x=1696009778; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2o1CYzB6+mJ2+hUW8zCgaKBLo7FrtBAUficPQDkUT8w=; b=TqsBrvm/vMUh54oLyp9o6v8j0nuJdg0l+JHta1Ocf6OruFNCBKGfeXTxPZD77pM+2N aGMmDU7TE75GfHNysRN3vyhxcm39OpgVtk9ZXdGXkgF7vSjcsvMg17fIjAQ6VBo6sqBX 91+rgAaqIi8cNJ7fooI9eHHnR0bT/+A5wOLY8hg6F2kACuF6dOt3rS5Pefs2GnDR9v+F Q5sg2lliD5It3X4W919LSngdAieNiXA7d2HprxNJWmlwOGhN/7JUNPHp6lVYyIO7Cck+ 54/4efz7zqppAcmJX+qZExVaJ0m8Zs7wu4DM5ddr17j/y7P1kAS1EWPT8YDXx5ZuLDzS n9nA== X-Gm-Message-State: AOJu0YyJbyg/KQ6Hh3xXNY9IxsffiTcf8OevUykFSzVFJ/9VYcegkJw3 eIqmN5domgsOLvHAQf0GMYXVaQ== X-Received: by 2002:a17:90b:8c6:b0:26d:54de:b0d6 with SMTP id ds6-20020a17090b08c600b0026d54deb0d6mr377458pjb.20.1695404978555; Fri, 22 Sep 2023 10:49:38 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id dw24-20020a17090b095800b0026d533216e5sm5194253pjb.46.2023.09.22.10.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:49:38 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Michael Tretter <m.tretter@pengutronix.de> Cc: Kees Cook <keescook@chromium.org>, Pengutronix Kernel Team <kernel@pengutronix.de>, Mauro Carvalho Chehab <mchehab@kernel.org>, linux-media@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] media: allegro: Annotate struct mcu_msg_push_buffers_internal with __counted_by Date: Fri, 22 Sep 2023 10:49:36 -0700 Message-Id: <20230922174935.work.699-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1446; i=keescook@chromium.org; h=from:subject:message-id; bh=bN/ajVTfVuIiMGEGWWAcgGtceBsP5LcYYFGEKRmRbCI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdOw4ytUtDHEFA0oq/D0lIUJ3hczfQWyTFNqp mzZrHCMZV6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3TsAAKCRCJcvTf3G3A JpSDEACqurosT1uzHcOqbuoB7iJin9Tu8TQRk+o2p2ReQ1BEhMuyNvL1gVTecnUtek8OCFNH8F6 boRt8sZBndcQrwMtVGoM3lNwdoEndkQAJrPSUKF3nFwZaEbj5sILyoJLVXYTh+E5uJXbSUJPMqa JDCVjF3D89G2UUokDXLgSzNqMCEGxjz8pE11LDfwTWRhiBivcL36mVthUupVT1Shy+Soo2BpmIr pvW81aO8bXcvRLYIjKzlsidCVFgGkuD2ash8wMG6/KsmWfPbSTl2Tv21LyRMK0uPRAHigjT3Q6C nzHI09QduMSUnhW8enjTF8Wx+RPi1ZJsG3YKkOSgDzXGKoZ7UWb3z55zbXrrKh0uACw/Y4RUY25 3Yvxvo6iglrP/+LCCJ4zWT/xPq7VM8DLwHHL8iKq6Dsnpq7rXNDo9m337Z1T/1NCWglWqvb9riw //2HXkXLKzo/8hl3FykRaQCZI4oyRlddySyKCmWm5770Rr5odHDThDOih1gLm1DACoH1oP/yHCn CPKFABdnUuAgtYbjkni8LJgY449sh91SZKfreS1q3hemGpqMRMvalfl+BWUHIdTQclq3mG8CzEG ssQonfBsYP7J6xN2aIVJJYwZGFihQkocrlmxmsbxArwreUaA2g2gKqrpVgwwIFToVk+8ezi2i+I eJ3MP+O JCJIPzfg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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: <linux-kernel.vger.kernel.org> 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]); Fri, 22 Sep 2023 10:50:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777792776926387494 X-GMAIL-MSGID: 1777792776926387494 |
Series |
media: allegro: Annotate struct mcu_msg_push_buffers_internal with __counted_by
|
|
Commit Message
Kees Cook
Sept. 22, 2023, 5:49 p.m. UTC
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 mcu_msg_push_buffers_internal.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Michael Tretter <m.tretter@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/media/platform/allegro-dvt/allegro-mail.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 9/22/23 11:49, 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 mcu_msg_push_buffers_internal. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Michael Tretter <m.tretter@pengutronix.de> > Cc: Pengutronix Kernel Team <kernel@pengutronix.de> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org> > Cc: linux-media@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks
On Fri, 22 Sep 2023 10:49:36 -0700, 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 mcu_msg_push_buffers_internal. > > [...] Since this is a trivial change and it's been 2 week without further discussion, I'll snag this patch. Applied to for-next/hardening, thanks! [1/1] media: allegro: Annotate struct mcu_msg_push_buffers_internal with __counted_by https://git.kernel.org/kees/c/63eed8dcdf49 Take care,
diff --git a/drivers/media/platform/allegro-dvt/allegro-mail.h b/drivers/media/platform/allegro-dvt/allegro-mail.h index a5686058d754..c0c9013f1aab 100644 --- a/drivers/media/platform/allegro-dvt/allegro-mail.h +++ b/drivers/media/platform/allegro-dvt/allegro-mail.h @@ -184,7 +184,7 @@ struct mcu_msg_push_buffers_internal { struct mcu_msg_header header; u32 channel_id; size_t num_buffers; - struct mcu_msg_push_buffers_internal_buffer buffer[]; + struct mcu_msg_push_buffers_internal_buffer buffer[] __counted_by(num_buffers); }; struct mcu_msg_put_stream_buffer {