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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F174C433F5 for ; Thu, 24 Mar 2022 14:22:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F7B284082; Thu, 24 Mar 2022 15:22:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OO6Z6iZ8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4632E840AA; Thu, 24 Mar 2022 15:22:40 +0100 (CET) Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E96C28406C for ; Thu, 24 Mar 2022 15:22:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-2d07ae0b1c4so52092267b3.11 for ; Thu, 24 Mar 2022 07:22:37 -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; bh=oSnHBioey5Uct2bHCvEOGa2zKw/zyJWtD/8cqzauspE=; b=OO6Z6iZ85R3QL2cKwKoUaDeyoYVqLgJ6qHL2j51zwZ6+kwYdM74yuq8LGEHusRdnJW XdG55TJdRsFws9nU6IVizGxPPC0uvwVrsU567wWDHi5Qd2aJJen0NVP0hT43Byx5IRSJ 0H2QEPLUoGSDKd1YE2b/2dSqvm+WZD5oQKpxIv15xFnrZUQThWUuwGGMEuFiOoXuGBap se/EbnN6qqULWUX3TEafAnjYHFPIWd+Nv/OO4DhLQBKkwwtmgVoPXh+dBrpbqE+ILzp1 54IlpUIem+ta21rShGwZL7UQPlPreov4KbL6tYK4JiFj7hkTRocY47iMKZKJdXodcotb FEkw== 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; bh=oSnHBioey5Uct2bHCvEOGa2zKw/zyJWtD/8cqzauspE=; b=C0Pco6wiOcV3BK7dOj/LsfPfRMk07pBeEZ1HAlQNQTHAasdC2bQE84mhkrSZpXlT1T ye0FHj+PPBS6sct800waXWZt+UWgvQrPWB+r/ByDmLk0XwjOXprxZQN5t8KB2RVcaTsi Rpcb02NZeglAcK2AQIiF+MKEn5TEvUZpivsqVzFCiawN6sG93BqD8Xq4yJ8s2TdNjm+R tq0wG3iG9PdErRyLCV0I4wRVPj42sSQA0fAT9IqMlAyYp76taAdJj8Q5cfEeIxQtmWD3 gYrvt/6LbGjv9KJHs/0Z4A8XK93zAwWR3OicEPQ2CR9xFi9GnzUlwDb/OYo9v1NDbGGS vo/Q== X-Gm-Message-State: AOAM533dcBs0R5FH2dGy4nPU5nPns3Zq04tEf4fz31sMyDtBEKAGo0+p my0fGzN/LHOFzujww+SEF9zeI2Z1wnErV1uUmGNAlor/Ztkviw== X-Google-Smtp-Source: ABdhPJwWEhuLEDIwJAbdR9L316sJw4Az5FqaO0p4YKnCiNHf92JYX72/Wsn9y0graU4hHlszu4hmy0k+lmWVAhwgSjs= X-Received: by 2002:a81:e90c:0:b0:2db:d63e:56ff with SMTP id d12-20020a81e90c000000b002dbd63e56ffmr5265113ywm.60.1648131756744; Thu, 24 Mar 2022 07:22:36 -0700 (PDT) MIME-Version: 1.0 References: <20220320114118.2237795-1-ascull@google.com> <20220320114118.2237795-5-ascull@google.com> In-Reply-To: <20220320114118.2237795-5-ascull@google.com> From: Bin Meng Date: Thu, 24 Mar 2022 22:22:25 +0800 Message-ID: Subject: Re: [PATCH 04/11] virtio: pci: Check virtio common config size To: Andrew Scull Cc: U-Boot Mailing List , Simon Glass , Alistair Delva , keirf@google.com, ptosi@google.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Sun, Mar 20, 2022 at 7:41 PM Andrew Scull wrote: > > Check that the common config is at least as large as the struct it is > expected to contain. Only then is it safe to cast the pointer and be > safe from out-of-bounds accesses. > > Signed-off-by: Andrew Scull > --- > drivers/virtio/virtio_pci_modern.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > Reviewed-by: Bin Meng