From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 245C1C001DB for ; Fri, 4 Aug 2023 08:29:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C925D4099D; Fri, 4 Aug 2023 08:29:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C925D4099D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1691137762; bh=2XqJu+J+UZeTjd8DCSfCSZw1uYjDHbQlnlgPsoKEArs=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=ejEmMbrt0e8wh/ZvK/Ghr4j2K+Rvb584zKUCeeOB46sVIKbOGKykh50D4qXW11ipC +xPOhYGVLJacmYUfZUW+JEAWXaWr69zYR3uVuKT9pZeWMAIAXf02WIqhwFn3VE09Rv ZWx6r+3JwF7E/EaLBK0kTEyRpdmmEQ/ZZV/W544AAIvM0M8B0aQPNjaHYIIYvi8Gwl XL2wZj9/zawiUar/5PfYguKqiUOMMOuB5WO1t7FEB5Z9+K0SQ+WQf315raqklhnJiZ S77/f3M2XcOiZweuaSCaBTPMqveCjGI5t9dpZ5PaBPy6VVyHAxmZQ3hYg+kjU82JB7 F1uYSqZHW5XDQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dlnqt6OiAXHn; Fri, 4 Aug 2023 08:29:22 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 815D64086D; Fri, 4 Aug 2023 08:29:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 815D64086D Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 159A51BF341 for ; Fri, 4 Aug 2023 08:29:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CA367400FE for ; Fri, 4 Aug 2023 08:29:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CA367400FE X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SgtBpMTl5Gpa for ; Fri, 4 Aug 2023 08:29:03 +0000 (UTC) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3260B40538 for ; Fri, 4 Aug 2023 08:29:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3260B40538 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68336d06620so1662583b3a.1 for ; Fri, 04 Aug 2023 01:29:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691137742; x=1691742542; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7Lzp3ZkP17GT5v8YT6Q8PsfBgtBwszbchO+h+FYy3w4=; b=AjStkuJiAF04HWDpoyqFS5VY9/7Gd0tKDNp/ec5R+o5AtMPOQY9ndNdqF6Ku+4nRB3 64DDFQxOZ5hYbT5A8Z1SxcqnFkY2+mktwT+66TKnK4VBjdX//5XRFzhUMkljusVM1OVa aFqyogRUgIJifSp7LtAQbff0WfQ35MkVSYu+v0quztZVdBuB+YHJQdKil3gnByDQ2ckY MYMHPfJoOl3s8k2eKHXhUmhpaCi0Gd+ZqRnTjLUV6lQ7RkhX+NQvn8DxAWHrguS/kp83 bGp587kZ61AKwGzKrY2XU12IF9128+0u48v30GcVr5ByOGxvAoG1hgP3d5EqwpjNb2Vf irOg== X-Gm-Message-State: AOJu0Yx3FbIIzFQ/AomxC6gTAwAvDveyCvHiyLFkIn8YcgKBA4rzx/+1 ZdUKHcvfd0D+PEOHEVIFnpqTRQ== X-Google-Smtp-Source: AGHT+IEb8NJZukwkOLv+8X4gGyv5xuEMYnojzUqQ9CiQkM6If6hOvgmAM+Cd3GLl5BacdLQgN3RxVw== X-Received: by 2002:a05:6a20:244f:b0:138:64d4:b040 with SMTP id t15-20020a056a20244f00b0013864d4b040mr1274551pzc.54.1691137742585; Fri, 04 Aug 2023 01:29:02 -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 v19-20020a62a513000000b006870721fcc5sm1101722pfm.175.2023.08.04.01.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:29:02 -0700 (PDT) Date: Fri, 4 Aug 2023 01:29:01 -0700 From: Kees Cook To: Alexander Lobakin Message-ID: <202308040128.667940394B@keescook> References: <20230728155207.10042-1-aleksander.lobakin@intel.com> <20230728155207.10042-3-aleksander.lobakin@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230728155207.10042-3-aleksander.lobakin@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691137742; x=1691742542; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7Lzp3ZkP17GT5v8YT6Q8PsfBgtBwszbchO+h+FYy3w4=; b=gz/zjWqM3uu/9WJf25raD3sRvhSeY7TJLSIXkLtJ5Q9CbU2Fg9UlZPPg31KTkF5Say h+zm8lyW0sWyiNhFbYjYNzovIj483N3sguC+1cDwqAfMGZm5likBeIBTtFQiZx7wjjw/ 6I+iYb810hAMUm38IIs4yM3G1df4qSUj79J1Q= X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gz/zjWqM Subject: Re: [Intel-wired-lan] [PATCH net-next 2/3] virtchnl: fix fake 1-elem arrays in structures allocated as `nents + 1` X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Larysa Zaremba , netdev@vger.kernel.org, "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Eric Dumazet , intel-wired-lan@lists.osuosl.org, linux-hardening@vger.kernel.org, Jakub Kicinski , Paolo Abeni , "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Fri, Jul 28, 2023 at 05:52:06PM +0200, Alexander Lobakin wrote: > There are five virtchnl structures, which are allocated and checked in > the code as `nents + 1`, meaning that they always have memory for one > excessive element regardless of their actual number. This comes from > that their sizeof() includes space for 1 element and then they get > allocated via struct_size() or its open-coded equivalents, passing > the actual number of elements. > Expand virtchnl_struct_size() to handle such structures and replace > those 1-elem arrays with proper flex ones. Also fix several places > which open-code %IAVF_VIRTCHNL_VF_RESOURCE_SIZE. Finally, let the > virtchnl_ether_addr_list size be computed automatically when there's > no enough space for the whole list, otherwise we have to open-code > reverse struct_size() logics. > > Signed-off-by: Alexander Lobakin I remain a fan of _Generic uses. :) Reviewed-by: Kees Cook -- Kees Cook _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan