Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2794195rwd; Mon, 29 May 2023 00:31:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dLspxSn51iS3F9oaU4XsJ2QU7bf/2OWSFaiAzulvPCb9QdJpzvVeY7S/znfNEB8BSRwMI X-Received: by 2002:a05:6a21:6711:b0:10c:4a13:a5cf with SMTP id wh17-20020a056a21671100b0010c4a13a5cfmr6633517pzb.6.1685345506295; Mon, 29 May 2023 00:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685345506; cv=none; d=google.com; s=arc-20160816; b=O8yQcxd+Ey8vpzuonzB0pP7Ur9N7DwFTAkpKZbK31CiXFgdY8kXbW0MhXT1VtVNnwI csdi+y5MIYdFesSFk2OrjNkyADUB09NHW5F1swKma1ZuwEC/vCFhy5Op+3ig7L7MSfdW fh8cNz5EL6sTzCwEEqEUXaP6+HL+rEOCDmreAfFtJzVfQtTbRA5G9O2zY4jaf+pKoVLr hgzcmWS0L/CIDbbqIrvuk8JzRWMz73HkRFKmV/7gNpVAWOKnFFleyzu61+Tf+FZBD1KY QgJN9d266Cks3efrXoTzpKC0/vp/pbrsoCB4Lpoc0W2xTZJTOwDT8CVW4yQ78INaI32Z D1aw== 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=7dbJswxuikSdGXOWoUBNPK1HqbQyPIndcOVtASk695c=; b=qTOrT+FxlRiQAMNyyrWx8ir6VoXSSaV1+UBkSvmFGkzURjrljc7T1tH+pT/BxyMWxj IwrVzBArWAygYfzdt8Xq/UypbaTSmj4/SVUXKzpGezfbiPOnbfZP6JHh/G9gKW8L1r+G G7waELbQS6IF6EPXNnZ9nRt4lurx/4KXeMKXQSrC0Ju7M/lacgtcUXOSppuqTN48l2bN RKDCUJq+sAzKnY859D+sreNgAF2wS+RpPdDd+K5daMyIL9uEJkXM3E+0QlMhNx62PxB7 L8diOM0pn1OdS7cYZHzuwC95ZDCwxWmStUsnZTHR63y8zGi63EKHf5VFrsD/zcaPWG9U 9fKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=d3e3ndgd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t69-20020a638148000000b0052c910d862fsi8857188pgd.244.2023.05.29.00.31.34; Mon, 29 May 2023 00:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=d3e3ndgd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229958AbjE2HZW (ORCPT + 99 others); Mon, 29 May 2023 03:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjE2HZU (ORCPT ); Mon, 29 May 2023 03:25:20 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E92CA7; Mon, 29 May 2023 00:25:19 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2af2602848aso29915771fa.2; Mon, 29 May 2023 00:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685345117; x=1687937117; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7dbJswxuikSdGXOWoUBNPK1HqbQyPIndcOVtASk695c=; b=d3e3ndgdfD6fKBWEdpcCFSfICCQiSidpzlKnI/vYKnkIi4znfmdBzgcBTXv776E0tS uMXUFP+7uojCP3A0cxMlt9p71bELw+AoqDWf/O+Fnecp+6y5MXbMSTpW+bm9CJAIvQPl 8IEpA7OZtWb0VoCgiMJdR49quBJaJXnvRE+mLuX1pMTyTgmdNOLF5v1hnlZvoq0cKriC XOBsBQ1pHVVzGwhXSHkKOoENz03VO3WfMdhOuLuLAOvDPgkb8Lk8DUEiPMbykLDENjMu q6l1vCOJe7Cl4LVJEVP2N36t5abtJPiZ2ShxtrCgVQYK7+1PF2o+som5hBD+ZGFzPFNf wLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685345117; x=1687937117; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7dbJswxuikSdGXOWoUBNPK1HqbQyPIndcOVtASk695c=; b=fS9CAZQ/gCW9vXgAEly80zyX35QJsNFsirVBKc25ippklxVetNN6gNPRcM/0C3uOmd sTBbCVM5kjEE7hfOzldOqieXfcIsmQtVq2INLouexYc+myj+i0ghV3ERmQlzLk9U+VIi xZqT4BcngKhuMWOfCGOQO5TVyDD0FL0YmrjikDkf4zOzhERkyuOY8ChvnjpJveYH84ow +wezfFj7NGWOl3mwDqmezSp/rJA6JSBkx42xjXI7mcldAOZPd3+FYPiKUNkU/YT8eEqv 5UOgxmLCk9sDDxe9zIRC3C7dC5EQb90p8+nfsVxtO++nyP4IF8+HvVKRtKryqBW03bV8 nVbw== X-Gm-Message-State: AC+VfDxjfG7LU1UBoFcDiJaIdmJLxcAPF5mNbWGGxj7Kl0BbM/B0nEkV FeOuOsM5uYX3a1gGWAdmmsFOr4aTIp8W72WegTE= X-Received: by 2002:a05:651c:d0:b0:2a8:b7e9:82ee with SMTP id 16-20020a05651c00d000b002a8b7e982eemr3451083ljr.1.1685345117194; Mon, 29 May 2023 00:25:17 -0700 (PDT) MIME-Version: 1.0 References: <20230526054621.18371-1-liangchen.linux@gmail.com> <20230528021008-mutt-send-email-mst@kernel.org> In-Reply-To: <20230528021008-mutt-send-email-mst@kernel.org> From: Liang Chen Date: Mon, 29 May 2023 15:25:04 +0800 Message-ID: Subject: Re: [PATCH net-next 1/5] virtio_net: Fix an unsafe reference to the page chain To: "Michael S. Tsirkin" Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xuanzhuo@linux.alibaba.com, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, pabeni@redhat.com, alexander.duyck@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Sun, May 28, 2023 at 2:16=E2=80=AFPM Michael S. Tsirkin = wrote: > > On Fri, May 26, 2023 at 01:46:17PM +0800, Liang Chen wrote: > > "private" of buffer page is currently used for big mode to chain pages. > > But in mergeable mode, that offset of page could mean something else, > > e.g. when page_pool page is used instead. So excluding mergeable mode t= o > > avoid such a problem. > > > > Signed-off-by: Liang Chen > > Ugh the subject makes it looks like current code has a problem > but I don't think so because I don't think anything besides > big packets uses page->private. > > The reason patch is needed is because follow up patches > use page_pool. > pls adjust commit log and subject to make all this clear. > > > > --- > > drivers/net/virtio_net.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 5a7f7a76b920..c5dca0d92e64 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -497,7 +497,7 @@ static struct sk_buff *page_to_skb(struct virtnet_i= nfo *vi, > > return NULL; > > > > page =3D (struct page *)page->private; > > - if (page) > > + if (!vi->mergeable_rx_bufs && page) > > To be safe let's limit to big packets too: > > if (!vi->mergeable_rx_bufs && vi->big_packets && page) > > > Sure, thanks! > > give_pages(rq, page); > > goto ok; > > } > > -- > > 2.31.1 >