From patchwork Thu Aug 17 23:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 136153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2070741vqi; Sat, 19 Aug 2023 08:12:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGliD82o19PDxAC2nELSJbY3MdptnaKrWcXnzYa447SyC+cG8U4oP23uPifEaJDgzscHiIz X-Received: by 2002:a05:6358:9924:b0:135:4003:7851 with SMTP id w36-20020a056358992400b0013540037851mr3085623rwa.19.1692457929904; Sat, 19 Aug 2023 08:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692457929; cv=none; d=google.com; s=arc-20160816; b=pwjpjhEoU2A08oCNTB1lyLieQKCGwz5WyzrDWc81M1BFYnTG5S99gGAxNpNtOAQWIw 0CPoCRj8f3d3GHvoazoNQEhVFt+QlcoDJa9z06Hp4PUdc6PAriXzXhGXjHzSy3xNvijI ppWZf95hL2G8vG7EYKLdZt5uasK2cqSio5FhUHLaD7Xy4h8zbFzNkLrsbyN1L7hB9v+P RnBomDMentH0LATcd//kkBsWYnlfLH/IbG7mug0/6WwXoPc2N3JfGiykEL5hz5MObaCS 9ArNnX4mgt2Bf27bv3pmw0geGnHgaDuCw0lFmACHFqNhYcdBnTUsxIb5qeWS8n/N43nx O2yw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KnDKyGKtXCldI9QXtpCv/6I5lmu0QC4pcInlXQTO858=; fh=XT8orUNE/WTzMbwwoZKophTjt8kLOBy6cvchNFSm37Q=; b=mX8hjDEg2R6ukf0ldEVAkWVmDiRcSlqQb9XtXDcl1/YWeeRe3qgt5VwXvb2MdINHjW LNHYgdof54sQn3qPVlre5e5Bu59aUzZhffiA1Ez54j5RnYdyLUvxje+c04EYc+FUzXGf 0n6USn4SP/fcKVw25Wr7aRo9oFe/Jxu0UEug6Nx84nqUmSW/NeTruN6ZHiB2osyKdGSB Q8optGKg27FbWI6IQViqYcUIrIlk3zm9ziU9lPM5oVX1/nIHwDD5cZwkQQysNLgbbDwG nPoTTdVyx4NlGwO9zmVyzcngZUkexOuzRstz1pvSiN05jgMcMGoHzH8qz3xfUmDWkoN/ 77qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DAWnaYSC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k29-20020a63ba1d000000b0056574d63583si3578300pgf.306.2023.08.19.08.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 08:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DAWnaYSC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D06EDEC62; Sat, 19 Aug 2023 01:46:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356310AbjHQX7f (ORCPT + 99 others); Thu, 17 Aug 2023 19:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356303AbjHQX7D (ORCPT ); Thu, 17 Aug 2023 19:59:03 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38DD22710 for ; Thu, 17 Aug 2023 16:59:01 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bc8045e09dso3003995ad.0 for ; Thu, 17 Aug 2023 16:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1692316740; x=1692921540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KnDKyGKtXCldI9QXtpCv/6I5lmu0QC4pcInlXQTO858=; b=DAWnaYSCcJsZ2VJyNMzhkr9UoSPe49NdfERuR/9MtkDayZn4oxbL0bdBJw+2iMhj4p Lfnut52cWciE2RYd6WqwqMkE73qCE3FMBqJtuUplIPAdNFGT2sciOaegXwD5JeA9wmBC wH+Nd56QJZy0nXGsWO1k9ZmYPEY10CEJMGfAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692316740; x=1692921540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KnDKyGKtXCldI9QXtpCv/6I5lmu0QC4pcInlXQTO858=; b=k5cKwg9VyO/8Q8AtXlbHjEP5hkP//CwhZtqDaJmPbhrzbuAGdDTBjGrjWDxyk9HBWq CQcNk8i3um6zy61q04Wed+uC5yMoWhF/4+dK6MEYbLAbL3wai/xRvdKj4eUHSLF2N8gb BeNZI0+L96s4nF5DD/7vJ98cXQIRQjSW/96PBPcnJRkulvToZOouqLnnY+DZbirAVG93 oqkYduYxwHE3ifXKVdK70/Mi0zS/6qx4aYWMhQz/Pz/6dk3S9b2JgkKvMBUOoXVzfnHz vatD76aOEWCwu2WyYcp7NI0S0eoAoF4xUmGbBwB8CtBxe4p/QbWjbJtuZcpeDAsr02bR yO9w== X-Gm-Message-State: AOJu0YzHLc1q+md+FvRx08YG9HiaiVXK8SNnvVe5W6nI2ynrZHEBAiAW HvUUZsLi/jqeqrDFGHihLg7wgw== X-Received: by 2002:a17:902:d386:b0:1b6:bced:1dc2 with SMTP id e6-20020a170902d38600b001b6bced1dc2mr897825pld.0.1692316740592; Thu, 17 Aug 2023 16:59:00 -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 e16-20020a17090301d000b001ab2b4105ddsm343739plh.60.2023.08.17.16.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 16:58:59 -0700 (PDT) From: Kees Cook To: Vinod Koul Cc: Kees Cook , Hector Martin , Sven Peter , Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, Ludovic Desroches , Tudor Ambarus , Lars-Peter Clausen , Zhou Wang , Jie Hai , Andy Gross , Bjorn Andersson , Konrad Dybcio , Green Wan , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , Laxman Dewangan , Jon Hunter , Thierry Reding , Peter Ujfalusi , Kunihiko Hayashi , Masami Hiramatsu , Yu Kuai , Greg Kroah-Hartman , Jordy Zomer , Jernej Skrabec , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 01/21] dmaengine: apple-admac: Annotate struct admac_data with __counted_by Date: Thu, 17 Aug 2023 16:58:38 -0700 Message-Id: <20230817235859.49846-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817235428.never.111-kees@kernel.org> References: <20230817235428.never.111-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1268; i=keescook@chromium.org; h=from:subject; bh=+yUzAqwh85bIB2bobXU6XticjxS12rqU/iamdolC6VQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBk3rQ/2TY8D9mRgdw2CyM3qyEw53h74QZCcomFf /5CQW+uVY+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZN60PwAKCRCJcvTf3G3A JuA5EACo65ZRVDO2T369DZ8mHVU3mjAd/qj4wNjNG75A+15aqgtGCNtC6y1ULsuPGJRjpu+YGZP SfVM5TtRf0xD87KOcvyvFhAhPiCX72b/bgH9K0QC/ZaG1pKs6GWhko/TzVqRHfrpQsCvGik2Yzy /Ap7x9pHLr4VpCDYMvdQ14aFHpyOdx8aYtHDA1mIwxQ4TDTYiVQswfNl0mxvkRtEdJ0aF0c6FGj c9Wi2wkrXJHPrMQNxrQim9W2JlTKVKqRl6IyIWbLVtIEMGlyxG8ugMc6VyaVucZndxlIJN4xQ2U 4sKFedJC4XevUTeDtgLJljcdkZQYpR5uvtS3BwAjRtNvH8giuUMrCs4zKPb2YCLieX8/hx/nZsw LwLJVqdCPZkQpFt/V09vvrOi9GyNaOqsByUl/+H3p8MLDp7nfIh16KZMxacwYBLfAtNXeXxTA5o nHyQushjVS9VAp60zhFlRDfTvOWDHIwRoopc1a8UxDwov6pxVzEyIwLE4cIGB7XObcyon7BHN1p g7p84kopAehxM0BeoZMMZ9Y1NLeaTbLIf/zC46QyF5KBHtNgFBrK7VksizS80pxLQD4vfPM+FwY lETjtxkrjbwEOfezCh0YL2gfzl8DLG5uX9D15KXxo5RYGhkzXhDubRLrlu2qf5J+KDBnU3umWrb OEEXY2wqf3bd9Rg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774670766269790243 X-GMAIL-MSGID: 1774670766269790243 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 admac_data. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Vinod Koul Cc: Hector Martin Cc: Sven Peter Cc: Alyssa Rosenzweig Cc: asahi@lists.linux.dev Cc: linux-arm-kernel@lists.infradead.org Cc: dmaengine@vger.kernel.org Signed-off-by: Kees Cook --- drivers/dma/apple-admac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c index 3af795635c5c..ff46260b6ebc 100644 --- a/drivers/dma/apple-admac.c +++ b/drivers/dma/apple-admac.c @@ -128,7 +128,7 @@ struct admac_data { int irq; int irq_index; int nchannels; - struct admac_chan channels[]; + struct admac_chan channels[] __counted_by(nchannels); }; struct admac_tx {