From patchwork Fri Sep 22 17:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13396289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B2C3CD484E for ; Fri, 22 Sep 2023 17:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wMt1P5Jw0K3WQL4hxUt59m9xYvNkGjJrS2pyYoRJ7uo=; b=ku0fycfO5/Di+l 4RV2YAAxozNclmj/D5FyHwp8af07lWEXOjK7LspaqfIo82+dRNHVcZYwdAT4t0oH9qdCejA9eAaB2 eiGH12TuTPOLbothA7LXG2VGMgtQYYiRC+MRGKdjnIPei+3fPUmfj4QZcXQHtPEglsGQtbqtpVRI9 GVqdVD60g8xQXNfYQRplsaGXCwEz4VmS7L9EdcHLyYJbdtz4WZ7RtaMdVFrLGQHgPxf9gxgyETcZd jw434HczYtlnEv6TZGF98vRaTqOCUzy797yYmt1dCJ37Cb2YYBxPfoMisgdDtcsCSVOKYRomvsSdP jhgrv1cc1g+o2e+XqjVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjkKE-009Yl2-1H; Fri, 22 Sep 2023 17:52:22 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjkKB-009YjE-1d for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:52:21 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c5bbb205e3so23398905ad.0 for ; Fri, 22 Sep 2023 10:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405137; x=1696009937; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+vS2A/5dfe44fdutyd/MiPveuUUECUoSz6xv9hgdL9I=; b=coXyrS9yQGXfCA+DLDZ0Lx29/vxh1pMp1kQ7G666+thmhWxOpRzs98XLrrqJ7lEjFP xvf8Q4WHyzaSEpEUklFUZFZFYSkncnyQ9DY6UviOLfhtE2z1I0SF7NBIZto4h/CLm5Yg obe5RipFEupZUDW60NGlFPH2xo9IB0wf6e1OI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405137; x=1696009937; 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=+vS2A/5dfe44fdutyd/MiPveuUUECUoSz6xv9hgdL9I=; b=XWd0UtCRaWQNkt3bzUt8xBCogUgkNeXShLpxh0TwFdwEMxExA+uJyuBhup+MpsYdYt MNQbRyW4M706L3TDsCZ138fCBkZ8klx7Eua+kE4O6LRt6Z8QMn6v7n4ctLIpzZwTI0RP 2R9WIpBsHDTPQWpBKyoS21t8rI0S3P34bKuxwxz3pm+qwatLsUjyB7KMkzkFMFFayfV/ viztU4Jcr0V2tEaJxPy0g8s6F6FDusAFB7W/q3etQkjRGFOqb0+WqRVn5lQwuDk+bjMW qX1Q2KgDv0dv94aQxVePx0p/TPKyVmXZsicgA99hjDg33BCdANIp6TpjTZKjRb4c+1NZ qgIw== X-Gm-Message-State: AOJu0YzWUoL2C4thx3rfXnxlTUHjjnZEA0dZOhghFKGtzFO/ACQXGvud SHHj9xhu49+as45t3bfv8dZFsQ== X-Google-Smtp-Source: AGHT+IFPIMsBddESEV+xOT00BhEEOms1XoGEZoRj82rSsZ2HtFooQgjZAAkVZk20RkrZp+QDDYHM1w== X-Received: by 2002:a17:902:8649:b0:1bc:6c8:cded with SMTP id y9-20020a170902864900b001bc06c8cdedmr113191plt.67.1695405137609; Fri, 22 Sep 2023 10:52:17 -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 l5-20020a170902d34500b001bba3650448sm3770726plk.258.2023.09.22.10.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:52:17 -0700 (PDT) From: Kees Cook To: Krzysztof Kozlowski Subject: [PATCH] memory: atmel-ebi: Annotate struct atmel_ebi_dev with __counted_by Date: Fri, 22 Sep 2023 10:52:15 -0700 Message-Id: <20230922175215.work.122-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1297; i=keescook@chromium.org; h=from:subject:message-id; bh=F2UmaICz1ZTVLb3quzX04fcrOpSbHmBx25EYuMmk16s=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdRP0nnZBp76GGrjxSd3FerVZS4q3b8aU5/c2 uN1YtxC8fOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UTwAKCRCJcvTf3G3A Jo+7EAChYPLRXO7X9nu9DEjWcNXCDEwK+/GRj855SWig73fP9fl2tV2PrcgDrC5LYyxuBpgGKYn x4Q6Vq+o80FOTdfMfJbZmmT9UVRojn1JY/y2UpRhEL475+ARS+IMf2fb1hO1bra2VPZhwfr1Rcc BN/3E75dldOHjy86D3B1SuSaRBATOQj7ZY/ID0Dnc3n2z4EQPF7jhXBNwA25DA8N37VdWsD8N/l F77FKDmnqOoQIFQS/wwyACE5Ivl1tkyB6RoXD2AU7TGDa0CnKZ0JCHSQn178K5DMd1xZEgBIIju s5EvBmv8TrzTpG88MwGp/gxEuotr23xn48cm5svdgl393nGbJZokdzrRQxaD4oiUKirMfZuqRHl vlG4rbuP6U8HsBAcNCFI6xo//gccjTSMdDTqtRi4cCfgJPuwHnJQ+J3EffL067Z48pDPdS6DJZ4 Eoq+pEGY8sPX/NAwFYJ+J7W8juJKWxNi544rahU5/6+QdjHnD48mVdG0DsFTEPA8fEzGqwD4Fir KH1cMmB7Ig96TfJWl1Rw85uRglKKFjrH9MuH+6XGXCypjqlo7KWHPKhHZcP2ty0rYKVGM2OW7fr e3h0Pkk2ZUbrUha6RZ5apKyCesPgWEbSt09RtpcJwGa0yrORQW80+5zJ4vghwfJKtnyucqa73g6 z/RJ3ag hxTiMUUA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_105219_541259_8FD13694 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , linux-kernel@vger.kernel.org, Kees Cook , Tom Rix , llvm@lists.linux.dev, Nick Desaulniers , Claudiu Beznea , Nathan Chancellor , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 atmel_ebi_dev. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Krzysztof Kozlowski Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/memory/atmel-ebi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c index 635966d705cb..ec6100bc94c5 100644 --- a/drivers/memory/atmel-ebi.c +++ b/drivers/memory/atmel-ebi.c @@ -30,7 +30,7 @@ struct atmel_ebi_dev { struct atmel_ebi *ebi; u32 mode; int numcs; - struct atmel_ebi_dev_config configs[]; + struct atmel_ebi_dev_config configs[] __counted_by(numcs); }; struct atmel_ebi_caps {