Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3690410pxb; Sun, 24 Oct 2021 08:38:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrtNLvfHdr5kzkmISK1GQA5WRYwG75ka1j7iCdHtWUUwJ2hsFVvlc8a7GUAWBTtezcQI9j X-Received: by 2002:a17:90b:234a:: with SMTP id ms10mr12953466pjb.201.1635089918398; Sun, 24 Oct 2021 08:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635089918; cv=none; d=google.com; s=arc-20160816; b=vwQTGDi1bzkcuTcPsOxU28KWjZZGoTnnAbKu2VS2hsqQNYrY9oWon6OFvMKX9f4JvP KmJthfYLvqkDIEgtu9ve4WvE52v1XkGDTiQP7IL0xLhMMTwqBTX/npcE3bZ48SnCN7oK dedpdxHH7xaKA7fIp6Xgp9lgwoh6WHSjr3xS44oqLTIfj/mo3Pwj3OVOjaRLpDsZ2gQ+ mPLz016G4+H4v28J9Axjke34PjfVQF/0SwbUPMK/IwKb9S6AARZW+XNsmBQlx6kKu15L 5Ovpo6O7KAU6LLcUvNQ0SgskbHDU8h34VSwhfXopW1Oa/LDRUcLSfUcVW2JIogkTBy3u DLnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8ci/xhYPZR9e9UWmXQi7hAkc36PIq0f8k5stqRYk7mo=; b=o1+wP8ja5JvB0+6Zq6DcOD45QFFoSgnpslo3OR0x5VLlWqVprv5BeLz+kLRi4LowLH CeOobRdr9FB1Xxxl4NrFwedGaUXoVSJ3KL2qcjYzkgaXmgBNhcMhLcB6WkzxDPnG7f/y wot5vVgCGONk7DJ8yc5/ZVO/9ueVJbLQNID8GfCN+3GsoJLSrPcrL1tvHob2zVW2rPP3 i9z9VgeT+Lw+vWHfNPWsZv8fLbPS3SUHnY8DXSE3AP0ZvcSxDI8L+W9T5lg7qFMs941c q4z8Q6zr5BMXRWfsa2JQOvXycFqbOt5AX+CKYjseChu1sNSsQiFzqclJc8Ox0Y7s6K2B Cv/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RjQvHCu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si23685889pjc.80.2021.10.24.08.38.22; Sun, 24 Oct 2021 08:38:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RjQvHCu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231440AbhJXPjj (ORCPT + 99 others); Sun, 24 Oct 2021 11:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbhJXPjj (ORCPT ); Sun, 24 Oct 2021 11:39:39 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E443C061745; Sun, 24 Oct 2021 08:37:18 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id t1so5682652qvb.1; Sun, 24 Oct 2021 08:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8ci/xhYPZR9e9UWmXQi7hAkc36PIq0f8k5stqRYk7mo=; b=RjQvHCu6f7eSjRB8qg3psq+nfMVQG+ZruM8AVXCA0/rpVpO4InHat1m+YQCmTINfBz Ol440Kw1avJdVjbwIEwMNTOkIOuPpD7tLmxZJYrDYDCckCWXEqPa6eG5L7gly1NdJGSh lV09I3pU8hkWQgWY9kQoNThAZQuxGPJWNRPFccc1+zHzcvITW9wHejg1TiXIKswDKqJv e8cymnnYPtOUT3NHrFUQx8OOl78aMcD/qmsBqgs0UHoJUq9uVsm9h4iJXQoskzoytcXQ AUtzXIRqWMT2MPHd+S6sf9Q1iDsIfxt4uB/NbKHX+zZv3MYttyyMH0Oa4lIiXWQmS+Rj m6xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8ci/xhYPZR9e9UWmXQi7hAkc36PIq0f8k5stqRYk7mo=; b=FBgSCxgO8FtrZlhi6AJTlSaFwXYtA0w/D4xJ81GFQv7FxlNRruSeC5aJ18iOxoQ7jw hHM6PdCWYMM7thlQTwj3ex+mCsW4ISDqfXhcgxs3SotGrG8A2TqhdxusuDFDwFI4Wd7R SOz5a2xOmpKG8cuT879u+XaXLM3tgyZc/TVJ501BLryGToq+wgdjyAyAccPgrNpHbkTc oZbt42YranzvCs/KtkwGSnnj5Kft9zPoR9OZBjKtsc/LN1nCt5ZbKzMSOLq3Rqlnu3ER Jy33eZ/QSb9OOF2gq1PFC86M1G8UoqycV16GOqnD/hoNU7r4gakCNbiZgJcEofufofjK WqJA== X-Gm-Message-State: AOAM532nGE91/O0uSzkIEIeOYKqy6fyvn+Zr/Pg4105Z0B7Qk/3LZnt7 iJYs4GgALIlu0HQEAHIw60YkGjSnnx6jzIyIFbk= X-Received: by 2002:ad4:5403:: with SMTP id f3mr11208276qvt.31.1635089837684; Sun, 24 Oct 2021 08:37:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Willem de Bruijn Date: Sun, 24 Oct 2021 11:36:41 -0400 Message-ID: Subject: Re: [PATCH] gve: Fix a possible invalid memory access To: Christophe JAILLET Cc: jeroendb@google.com, Catherine Sullivan , awogbemila@google.com, David Miller , Jakub Kicinski , Bailey Forrest , "Gustavo A . R . Silva" , Eric Dumazet , John Fraker , yangchun@google.com, xliutaox@google.com, Sagi Shahar , Luigi Rizzo , Network Development , LKML , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 24, 2021 at 10:58 AM Christophe JAILLET wrote: > > Le 24/10/2021 =C3=A0 15:51, Willem de Bruijn a =C3=A9crit : > > On Sun, Oct 24, 2021 at 7:52 AM Christophe JAILLET > > wrote: > >> > >> It is spurious to allocate a bitmap for 'num_qpls' bits and record the > >> size of this bitmap with another value. > >> > >> 'qpl_map_size' is used in 'drivers/net/ethernet/google/gve/gve.h' with > >> 'find_[first|next]_zero_bit()'. > >> So, it looks that memory after the allocated 'qpl_id_map' could be > >> scanned. > > > > find_first_zero_bit takes a length argument in bits: > > > > /** > > * find_first_zero_bit - find the first cleared bit in a memory re= gion > > * @addr: The address to start the search at > > * @size: The maximum number of bits to search > > > > qpl_map_size is passed to find_first_zero_bit. > > > > It does seem roundabout to compute first the number of longs needed to > > hold num_qpl bits > > > > BITS_TO_LONGS(num_qpls) > > > > then again compute the number of bits in this buffer > > > > * sizeof(unsigned long) * BITS_PER_BYTE > > > > Which will simply be num_qpls again. > > > > But, removing BITS_PER_BYTE does not arrive at the right number. > > (* embarrassed *) > > So obvious. > Thank you for taking time for the explanation on a so badly broken patch. > > I apologize for the noise and the waste of time :( No worries, it happens. Thanks for reviewing code. > > BTW, why not just have 'priv->qpl_cfg.qpl_map_size =3D num_qpls;'? Yes, that seems more straightforward to me too.