From patchwork Mon Oct 9 16:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 150191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1974676vqo; Mon, 9 Oct 2023 09:11:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEty6rZ/Xq+RQVi5oFo9IFTkUFSZg/nyHIupWN3KWF17l1UwV4qqwLUYbAYFmH8LIj2XeWG X-Received: by 2002:a05:6a00:2d01:b0:68a:6d34:474b with SMTP id fa1-20020a056a002d0100b0068a6d34474bmr17489013pfb.15.1696867888533; Mon, 09 Oct 2023 09:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696867888; cv=none; d=google.com; s=arc-20160816; b=d9B6Z0IC92jlhNRltitsuQG0CTp4VBydHYuEJMlYYINO0ZmU3Mh4BARREh1pPTRJjM QYrF4ZCtdFw/lPfxSkORoZOIG8KHvx+yW2wDih7/rSmrRQV3vq1FniyJl5xiYtf7PUrt 74ziiyEqHRPPqgpMwyhHelyCLjhMJOnX/GVhF1iR3IfGaujTzIVqx+ITRK2ossPhtZcZ kHxxoneARsox8RAq2Wm7Ngo8qbilQvLurdyLdB2Xb+ckv0ouD/68nvmVDACCnPNBh1u4 eeYB69K+PBaXleK0FI/CYSjWll5arG7hJnWzDt/MGzezp/eQ1ZEpS+rPblyCJziITaJY DF6A== 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=OlqtVYWDwFjsVmMJ3ynK5zOk4WfBZOLfWnDThZr9WAg=; fh=GMgy7SXIFE1qs5Mr+Bn+qfZVRq19Fw1tWfyePLILfks=; b=TZmYfbtNAtbClsoLMEZgJAf6yEXvd5hEypOs3veE/KNRCXUAqsgRE4GAMSwwTw6Cro Tj2Qgeje71X/M2se7hglOobwk1cCYJnihnKpugqk58i10JfgTx1MUJf9TgXXD8zA1u8L 3qs2FI+zmORDriZ0HDcfE37LVT7oXfQjkdFXTyc215kdYs0KGczhJ1d+HVGIcP3X4r4P cTHj80PdWALH8PQI8cn+Go7Uptw7c1ZDH7QVfWsMFgCxga2rTMVqlbdIBPGkZBYIJLXt FYuKr9zDgkbwrHg6YrJFEyjXwpPML9PGoUaNaf3i5TOsGYoAK9RlIuBKioGIhmoLprJZ tyMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="QhQEe/CT"; 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=chromium.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id q13-20020a056a00150d00b0068e4037c5f7si8148985pfu.388.2023.10.09.09.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:11:28 -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=@chromium.org header.s=google header.b="QhQEe/CT"; 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=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2A08F8087513; Mon, 9 Oct 2023 09:11:25 -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 S1377149AbjJIQLJ (ORCPT + 18 others); Mon, 9 Oct 2023 12:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377725AbjJIQLE (ORCPT ); Mon, 9 Oct 2023 12:11:04 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCB18FB for ; Mon, 9 Oct 2023 09:10:44 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c7373cff01so41765965ad.1 for ; Mon, 09 Oct 2023 09:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696867844; x=1697472644; 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=OlqtVYWDwFjsVmMJ3ynK5zOk4WfBZOLfWnDThZr9WAg=; b=QhQEe/CTuqCxJIOfPoZ8fgkBgmbjjUyK0QmInLlIZqMsaWy/32ToAP+gcFQQ0j2Ps1 UGKW2dIFDkDpvTsduwxaQBUHgd4/2TXYXSycHbdy3CBciPhHOpdLgvp2kubCfyxR08VW /wYOTcJUI686YQRESn6Wk4T2aFuTKQcVYsISw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696867844; x=1697472644; 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=OlqtVYWDwFjsVmMJ3ynK5zOk4WfBZOLfWnDThZr9WAg=; b=ktSvPblPQyXFojTT0anUp23fEcU2QdlfslbkIHVe36t9PAYwR18GyH8euTFLqxbb74 V3loFrUsjvo83D4Wi1racAk//IUO8y5RZloYeikJ2Uy8qbEZLVKs1sT64lAqqHp5cMuX O9dbUH0mAjw7f83nNJ/kzHSkiQkl250W/1LG0aD9k57Es4esDcX1ieaZYObrN1KaLjix q8nQJQrdyCUckDouHh3y9P50e3/AJR6Rwh9OYMBeeC57bwokOjuviO+HiVEth20O3Yea RVWb5hxjuGj0krsX7lpbyhoAyDiYXILvFyqsXd7VJ+L2LSxhCjIaOsMqTpKZ4nREH2eC L41Q== X-Gm-Message-State: AOJu0Yw2iolT1AGV+fnqooQPQ/9502ZisxxK3ojbMTXiP5v5pw+2DFBi vTvN4FlcIB7+SUpReTkvUpjkXA== X-Received: by 2002:a17:902:e54a:b0:1b5:674d:2aa5 with SMTP id n10-20020a170902e54a00b001b5674d2aa5mr19275942plf.13.1696867844107; Mon, 09 Oct 2023 09:10:44 -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 t19-20020a1709028c9300b001c5eb2c4d8csm9765942plo.160.2023.10.09.09.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:10:43 -0700 (PDT) From: Kees Cook To: Christian Lamparter Cc: Kees Cook , Kalle Valo , "Gustavo A. R. Silva" , linux-wireless@vger.kernel.org, linux-hardening@vger.kernel.org, Jason Andryuk , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2] wifi: p54: Annotate struct p54_cal_database with __counted_by Date: Mon, 9 Oct 2023 09:10:35 -0700 Message-Id: <20231009161028.it.544-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1323; i=keescook@chromium.org; h=from:subject:message-id; bh=YzjePAWoD+DSEw/PjSkFzQTncEdbJTF0SrU+nTfsVaM=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlJCX7vlAstYYRr8Z0mnQUxiZDkskkZO9CJ+b9t NQY4DZg256JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZSQl+wAKCRCJcvTf3G3A JipyD/4sIWmxi4BQzwpXVms+RWPCLNRlL9RbPY9/6KGp/spGVvhfdxb7V5cwLlX3GDeUD4zWExn GL7Yshbfo9iR3OiRxGmXof9oOVdJ6rhNsdi/HaGLCJxqZp6UdcoXN1F5bAybLPkF0R9JykkW9Ea M/jd8F1k/G6thhfd19vPkqDHxueFyxdiOPlOS6NuaICkM6neQU6M09h4xn+Vv7RFvMjZDe9x/Qe sDOrFQa2QZZ1mU1Q+XVnTxdDpnw958GqUGOHUOHpx/qnaGINbJVa4zghSsD69C4T22b+izuJHyV cX9u+G3yKOZwwU4k4t1eOFqX3lpuhpSXWcnDgLbGgp/Srxgqvcav8uXHmR8W3clzEJdtMHn0tnF MMsim49cLaji7VkQ6bMHWQa/JKA3bbsCSplAtYKKJ9kzjzmogKelO/hGnJZCp5owdHvB5/FPlVR ftsmoa9PUhBYum9S5Bzn32x4oSqUgbJSzcV/PTBGJJvZuhgX11pq/CpboblX430xR9cwLXIcCb9 zwBrkfxpegvYmUWwoVXb9czxB1ud+1nKRAJnNE6urfE4ZwNMoZeRSJUMGzbIIL5V9qAQ9dZlEVZ lbvq8Dhe0C5f/7rQZ19uHWcvxM5w1hyFShmp9LmlkNMc3PUdvSmJ59onewKaqMANKH0HSMow/fm sGR2+E1 nI8wezkg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,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]); Mon, 09 Oct 2023 09:11:25 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779038650100094651 X-GMAIL-MSGID: 1779294943189209474 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 via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). Add __counted_by for struct p54_cal_database. Cc: Christian Lamparter Cc: Kalle Valo Cc: "Gustavo A. R. Silva" Cc: linux-wireless@vger.kernel.org Cc: linux-hardening@vger.kernel.org Suggested-by: Jason Andryuk Signed-off-by: Kees Cook Reviewed-by: Jason Andryuk --- v1 - https://lore.kernel.org/all/20231006201719.work.356-kees@kernel.org/ v2 - use the correct member (jandryuk) --- drivers/net/wireless/intersil/p54/p54.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/p54/p54.h b/drivers/net/wireless/intersil/p54/p54.h index 3356ea708d81..522656de4159 100644 --- a/drivers/net/wireless/intersil/p54/p54.h +++ b/drivers/net/wireless/intersil/p54/p54.h @@ -126,7 +126,7 @@ struct p54_cal_database { size_t entry_size; size_t offset; size_t len; - u8 data[]; + u8 data[] __counted_by(len); }; #define EEPROM_READBACK_LEN 0x3fc