Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp287945rdb; Sat, 19 Aug 2023 01:35:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJYK4y6QNzgee3rj3DpS6ZNyejcbm7s5T+x3chd/kP17SCEUFh8ldz04BC4SrLm3ZSHsPQ X-Received: by 2002:a92:c00f:0:b0:349:67b0:6045 with SMTP id q15-20020a92c00f000000b0034967b06045mr1949592ild.3.1692434137526; Sat, 19 Aug 2023 01:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692434137; cv=none; d=google.com; s=arc-20160816; b=fp16Th9Eadd5vNXXNfClcF3SCkl4833HyW6OA+Firyzo6jusGJjPPsRB7a+xwRpUPA Ehw68SA9VwcPR9IgLaoy0srh/IyYrFcYMyFkFabSJ9yUgi2tbN2n3xwf4JSYdmcE6+7p 28m7t6Kae7t4jMo9euZtkYwWhP2Lcn51CfyuNjs3PMLBpP6FqtFPKTRxRTCmikBkUJfY YKAfhTyPqkcYw6ZOyj6qManHNXv9nUfn2PcsTrlGVgywk8HXmSAjcPMFf1lu/DRcu11d VPrXgsWxMp+9jI6wirr8501toHJs3HRW5Eyy79oev7H1R5CgqkkKPhAT/ZlfWlG+RuMv qmxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:organization:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=bt1JnArteXd6GUqL52tc42Z/9aVFW4Hmtij0pphTcm0=; fh=Wa2YFVemrDL3ZGE/43DSUVrlsidVbNclnUj8RiDR6D0=; b=qr/bX4xW67lafq0wYzcxfJ6d/yRyvUc1UuEmdM0sBUaneXwTUzP01443R0SneJy10h slbNyJe+AR4iv1mEglMn3BRToz/n67aYoG3y1zmbdqzKED4UGtvs42nsOXBmKDJ7R+qE lvJyJ5v98JTGCOWaZrbIS1zlJJ8wTwqz75JygUP9rHj/FEAiKHt185F89wmS8I1eSvYa kLUqnajClAIBXPVI4fmbJxTZfUVOGMgFyVyyH9Ruo7KB/pzTOwggKKzsTxq/P8feFgeH RhvIwA0jlN/qSiJB/aIAHjLx+J3u+Yxc5VmRdOfSZ6DHBCMU1E+Dd48HE1wJN834LaRA o1Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IeaDQ5ER; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v10-20020a63f20a000000b0056383a7ddbcsi2957617pgh.103.2023.08.19.01.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 01:35:37 -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=@kernel.org header.s=k20201202 header.b=IeaDQ5ER; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 440B55B96; Sat, 19 Aug 2023 01:24:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354482AbjHQSiE (ORCPT + 99 others); Thu, 17 Aug 2023 14:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354536AbjHQSh5 (ORCPT ); Thu, 17 Aug 2023 14:37:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7552D58; Thu, 17 Aug 2023 11:37:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8B97465E4E; Thu, 17 Aug 2023 18:37:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE641C433C8; Thu, 17 Aug 2023 18:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692297473; bh=J1tPV6jQIewMY9GqKdF7CJ1Ugw1zr8eM5AVuLf/L0g8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=IeaDQ5ERihR/mIysXnv/euGcikJX6N1dufHVNiLHh+YxAVAIQ/8/IQaLAt3aWCy00 nh+0CbFcyLMPCGk3gpdDbk2VuPLV7pib8vvzSgnNmIsHfIh75rPwzjDyom955V72Au 2TPoMD5w6+CAX40KY4dWbtqLJQpbH8X2CCMZhbDfIG/z3+NygYUCJZ1BqjfQ+1wg63 li3/Z6cNFwZIsbm1cCoZBa6AVLemYj9aBf6IdBDMkY6lOiFC0K8OA4nFTcHSUS7ki6 wS2rczHZlyEbAfAlmD8UAJCtcNPvXDHRzfrKqAWxBjIrE0VY56idLvrmC3Fv/lun6J YMP91lQ6DFSog== Message-ID: Date: Thu, 17 Aug 2023 20:37:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1 Subject: Re: struct_size() using sizeof() vs offsetof() To: "Gustavo A. R. Silva" , Kees Cook , "Gustavo A. R. Silva" Cc: LKML , linux-hardening@vger.kernel.org References: <74e8cf91-d095-33e3-c548-34d80b691089@kernel.org> <202308161913.91369D4A@keescook> <09b4a2ce-da74-3a19-6961-67883f634d98@kernel.org> Content-Language: en-US From: Alejandro Colomar Organization: Linux In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------Xh7qrg5HpYoyXwFXOw9K6fJj" X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------Xh7qrg5HpYoyXwFXOw9K6fJj Content-Type: multipart/mixed; boundary="------------ThNUh2l6BvNzlwUntttNYjTA"; protected-headers="v1" From: Alejandro Colomar To: "Gustavo A. R. Silva" , Kees Cook , "Gustavo A. R. Silva" Cc: LKML , linux-hardening@vger.kernel.org Message-ID: Subject: Re: struct_size() using sizeof() vs offsetof() References: <74e8cf91-d095-33e3-c548-34d80b691089@kernel.org> <202308161913.91369D4A@keescook> <09b4a2ce-da74-3a19-6961-67883f634d98@kernel.org> In-Reply-To: --------------ThNUh2l6BvNzlwUntttNYjTA Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Gustavo, On 2023-08-17 18:05, Gustavo A. R. Silva wrote: >=20 >> - tp_c =3D kzalloc(sizeof(*tp_c), GFP_KERNEL); >> + tp_c =3D kzalloc(struct_size(tp_c, hlist->ht, 1), GFP_= KERNEL); >=20 > I just sent a fix[1]. >=20 > Thanks for reporting this! :) :-) > -- > Gustavo >=20 > [1] https://lore.kernel.org/linux-hardening/ZN5DvRyq6JNz20l1@work/ Please CC me in that thread. I want to know when the patch is installed,= to prepare my own against that tree. Cheers, Alex --=20 GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --------------ThNUh2l6BvNzlwUntttNYjTA-- --------------Xh7qrg5HpYoyXwFXOw9K6fJj Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmTeaPcACgkQnowa+77/ 2zIl5w/+OKSRGZm51bd3xnO2rIs1JY0VYPGOkZw27tBxPTE2tGOJs+A6gnLL5ZLw K8f4GrCOb9Edhr1To+Li7mu1dQ0nyWgmHr3gOslUT7w1z5x7pRGGhMPVRzAf9f+Z DA8EPt1/OIhL1UVgraGkSArFTFo2dYgJ3eADMwfHNc7w2nUEqtL6wJAjTqayYMTj AzYxTpwG0yP1Kg2FZ7U5ddUfm/mJDoXfbsc9emCcYVHhaozZfvEjOLaf3FrzxOnh sFDHcdccYk7WTVxsVAd3S8L7OlIeQKN7S7lTYt+xR72yWKr0Oz05XWCWV5Qg0efT XCGDE01ux24dkI8xJaEwxUUoG2kAsxHgB0NrJClCUBYayj0GS9hSNiVdJxcNBqY+ zhHvufnyCOnpzptd/7beIe/cqio1uS/WXV4DEC3MNVAsGLCj6fC0R1v2dDpV5Mpo cwXiQidg9sGZuznUTyV20WNbCHBZ4QalODkhbNQHtSQZ8422SXfQIse0EUYoGxoE qJLGazO2bQJRa9+wka94s+d9GL9ey8govd9vHZY+oI7XsvYIjAcOrBM1R4n3KGqz a4BmCqhZs3lYEE9xiWz6VBC0YXJQQDci061q3yAf+3Sne2cm7ktzE+yQU3SHAsBy 3nd/pi6YkQZANQA9v9rnukPIULVQ1IehhyQ8hhR41kINAIqv54Q= =MET1 -----END PGP SIGNATURE----- --------------Xh7qrg5HpYoyXwFXOw9K6fJj--