Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp678702rdg; Wed, 11 Oct 2023 02:21:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDnwfa+1HLJUZK/14Oo39JUM3fi1U94QTqVyDjVnwrNbPw6Ww92hqqLfr5ku0EYYEVx+h4 X-Received: by 2002:a54:4590:0:b0:3ae:18c0:dd8e with SMTP id z16-20020a544590000000b003ae18c0dd8emr21934506oib.27.1697016088433; Wed, 11 Oct 2023 02:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697016088; cv=none; d=google.com; s=arc-20160816; b=ivaPsYm5Q5pYOjARnB4hxkXNtECSMq9EfSQbOeqRPPlxvIq3mEYKj7I8aEhwG383M3 HgHOAYLVPyiGlPT4wQ1kH3+xOPS7DaeRKqT+NQhwL5TVTLJF+E/2wGVwxlmokwFrBreK gusySddfltwPOPfm9z5XabepYgEQOwmuyDVL8YSsATy7uWZE5QfDWq8PlyCUyeHbd0Cm 2VlqeUV86oVFc3usEYkOpUwVeNNWUvYc3J3kQI85TrvWUMkZNksCnxXLaMLtpxgO3+0Y +raV/vk1xm3b4t4n7R8p/SH0u9q1KF+vj6zDDcMyaNxgkv7e80WDF4+qWxaZ6lFqUt/w WJ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dkim-signature; bh=zc0uwtFFKCiY2kC8JbUCjnwB7hJgKvZEI8gwglN7NXI=; fh=iIeLVs63+KI6gN74lteRFlkh2rHp+DwcaTCSIvlqnh4=; b=JfxCx6nBHotXleUhZb8m3w3A00OPjices1M23CEeOIbbKQ1qyQNyWM8bX3R+a3Xzgw GDuREVSXyMMhO/bag5Ga02r2rTrVVbm6m3HXkUoXlbZF7iWA/D4BJyzflfzyJ9EHre+z rrSKeU7Qy/s1x+HAAUZGp/Jhwe+P8JwDZnPklS6YNak1YSSZpiQ5eySSxeGUZ+x/4fPm YKYNkAlpzcka5YAZClX/UKmf2/VNVrvRx7oWLn1KNb6/lwtbq+iYqbjPiIHPzZ7WpP9i d6WpbfES5Ov7usWVkT6lyR9wK/14yXqbq/Z/9hYhZEePSktxzOllZB0k9fn/O/BZ1wtW 5Zjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fdM2wih+; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u20-20020a634714000000b00578bb009dd1si14207032pga.809.2023.10.11.02.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 02:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fdM2wih+; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E9C1D80A90C3; Wed, 11 Oct 2023 02:21:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231375AbjJKJVW (ORCPT + 52 others); Wed, 11 Oct 2023 05:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230351AbjJKJVU (ORCPT ); Wed, 11 Oct 2023 05:21:20 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52EA691; Wed, 11 Oct 2023 02:21:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCDB7C433C8; Wed, 11 Oct 2023 09:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697016079; bh=3pErmMLXBZsb29R9HnOmK6xrUTNWs9hBhZaadCT77w8=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=fdM2wih+iuPvtBZe0BJvHVwvgUAopMOVwNYxPZOlg8MpaBPkMUtpJVjQtQ3Lsun4y UVz9KZ+8oYkNSgQIGqgooWUV1Az/SFWjilFP2Z/AtXCS19tIGBIo+a/hA9jIWiW49K I9/lXmL2HQ+mlH6i+eJG/jpbY0YAk4cPbC1/gpT1jlJ1mtb4oVkq19RV/thThyc/Av wu9zaieb2XZPXwxup6xAUNlzaryW7Fv+DxGKIX2LQ8le16etfIMogRb6QWfgyBzBts BZwmpglnHtC7ZUIDYJr2jD5iYAGbyd6QlQDma88y4PlC2ihzUTS/sVi2xTQIqB8JKT t3Ga2NLjlWsfA== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH][next] wifi: brcmfmac: fweh: Add __counted_by for struct brcmf_fweh_queue_item and use struct_size() From: Kalle Valo In-Reply-To: References: To: "Gustavo A. R. Silva" Cc: Arend van Spriel , Franky Lin , Hante Meuleman , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.11.2 Message-ID: <169701607495.2760941.7574229474626886892.kvalo@kernel.org> Date: Wed, 11 Oct 2023 09:21:16 +0000 (UTC) X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 02:21:23 -0700 (PDT) X-Spam-Level: ** "Gustavo A. R. Silva" 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 via CONFIG_UBSAN_BOUNDS (for > array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > Also, relocate `event->datalen = datalen;` to before calling > `memcpy(event->data, data, datalen);`, so that the __counted_by > annotation has effect, and flex-array member `data` can be properly > bounds-checked at run-time. > > While there, use struct_size() helper, instead of the open-coded > version, to calculate the size for the allocation of the whole > flexible structure, including of course, the flexible-array member. > > This code was found with the help of Coccinelle, and audited and > fixed manually. > > Signed-off-by: Gustavo A. R. Silva > Reviewed-by: Kees Cook > Acked-by: Arend van Spriel Patch applied to wireless-next.git, thanks. 62d19b358088 wifi: brcmfmac: fweh: Add __counted_by for struct brcmf_fweh_queue_item and use struct_size() -- https://patchwork.kernel.org/project/linux-wireless/patch/ZSRzrIe0345eymk2@work/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches