Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4077629pxj; Mon, 24 May 2021 23:20:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQKhUESMrwgV4nPf1isIdoxBwXXT7xvqlzdghhJHDvivTnH7Sq4xRCW+SaJkNWWZFBC0Iy X-Received: by 2002:a05:6402:684:: with SMTP id f4mr30915779edy.25.1621923656985; Mon, 24 May 2021 23:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621923656; cv=none; d=google.com; s=arc-20160816; b=Z4o2X8wWaRApCR11Non1jqtII7Svqm2ZzZ9jY3MweOUJWwtC0Do3awuv6aDxJ96E2A py/3SyVmSTY9C+nVCXy7n6ve/Km96U5gXzT1eW6ATtynKa2XHAOB0TxeLY75YZNkmmjx noDzXEGfFG+bNNKHpT+qMYeaOKNJwbsJEL8OEW2zHXv8BCyTYbGbxEV+HbN5AU1auRST 5YtCu8+GreQ57lbHUnRhjJRcN4Q7KbaFmxgV3IY7jzxI3hjTt9+GfvM9vkSweJ9Z3rMT sWTGVpLdnw6I7yi5lCHksBp7GAhVhLi5tEjxwuCkp01CxtaxLTtvnGq9U/cfiaNs8RO+ 9UJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=rP1fweoyRJtr6Mi6XlE6lVpYI+0VMhwzNpbtJBa3S1E=; b=TblR0J0mnPzv60iZ8EvVnBW1lVNZz5MfyykRYnXWuQ5eD4tnLX0xXI1J1SFykvoyIt BMChdnqzYSr6adf6ALq9G7X+G3wtWakH6PTEQURY/KyPrvYR7aZGNe1lKL4WAV9t8k6U gO0a7n3NHhvD5AQxIHs5OCN+hEd3KuddyrnHGiHj+fced3TYTV+CUVLjSe1vbYXyvlYz HbrK7TJqr7ule39PvrQk28f6PkbOl+eH78iEq0YYgJ1Y7tZ0e+DuuNCDwTWsnJykyb0m AMH+ge96wZUG5ojsWuQMeRgcPzzPKVCTrEtALGPinP1FMwvfFRC6M5RK1EY7pTb4iAY9 TXMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CI25JyNr; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx17si10885184ejb.61.2021.05.24.23.20.34; Mon, 24 May 2021 23:20:56 -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=@redhat.com header.s=mimecast20190719 header.b=CI25JyNr; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230453AbhEYGUq (ORCPT + 99 others); Tue, 25 May 2021 02:20:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40144 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbhEYGUo (ORCPT ); Tue, 25 May 2021 02:20:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621923554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rP1fweoyRJtr6Mi6XlE6lVpYI+0VMhwzNpbtJBa3S1E=; b=CI25JyNrQixwpKwXEYmEusbXSjmDWoFQmGMCBgFNsRzBlhsb/MfQAksDfr5+2miJa/8V/N VKk1G9iz8anJpitdL3KL2RaoupF/EXs7rcFFIfR6r2DIXadG+GU8pzLA39uf6qcB+wb7Yl NepbRBXYTR8XrS5xfmBag/D6P1JkTVk= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-UAF6zNzQM-yujyYhMhoJ4w-1; Tue, 25 May 2021 02:19:13 -0400 X-MC-Unique: UAF6zNzQM-yujyYhMhoJ4w-1 Received: by mail-pg1-f199.google.com with SMTP id q64-20020a632a430000b0290209af2eea25so20336564pgq.18 for ; Mon, 24 May 2021 23:19:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=rP1fweoyRJtr6Mi6XlE6lVpYI+0VMhwzNpbtJBa3S1E=; b=FhqyVZ7XgYHujx8ixOU3MjXqLhUjUjshtnTrkgGB4hcKQjoPDjX6Gu4BHS4M0Vh/6O Bc6qgCrnxSN+DuKw+o5Q5dQWzWujvJInIX0a5uP9CjY8RmVE4XcnxTkne4JCX1RlQa5/ DpHFC3ZD/Dlyqna7ijvRuWd905NiHRMaP3bhdF/axz7Yd3vOSPqdS/QGN75MP2mGcIK9 oPPJKm4R1S5JN7idI50xli2sNGYmNdXfl3gaQEJI05YoIKdJSmZlf7yTrUNX5aO/botb 1TgMXI5R7gFmTFB0D8EYMsj8k1kpYhdo+eIDN4KdINmbZJFrkg74Yt7FJoRQUFDVNmEr LghA== X-Gm-Message-State: AOAM532cMt+a/1YZBkAK4aG3uUOU3ywhwHbqWMwkdm9/ozQOa98VcMJL wgAiWtpoldyKV57igHHM4hhHhv3Y0z/ZS0h3kK56dG6nV7OSBBB6o8O0/lsSwymbfsEHkcE0ZrX 1mXLbcw+XTMbY+mgjqi2IABo90ypDzWKaE+qdyIhjKmQeB4FCS0ShiVqvHovgocP63rIzwky+R7 D4 X-Received: by 2002:a17:90a:3988:: with SMTP id z8mr29530512pjb.175.1621923551593; Mon, 24 May 2021 23:19:11 -0700 (PDT) X-Received: by 2002:a17:90a:3988:: with SMTP id z8mr29530464pjb.175.1621923551060; Mon, 24 May 2021 23:19:11 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r13sm12449973pfl.191.2021.05.24.23.19.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 23:19:10 -0700 (PDT) Subject: Re: [PATCH] virtio_net: Remove BUG() to aviod machine dead To: Xianting Tian , "Michael S. Tsirkin" Cc: davem@davemloft.net, kuba@kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210518055336-mutt-send-email-mst@kernel.org> <4aaf5125-ce75-c72a-4b4a-11c91cb85a72@linux.alibaba.com> From: Jason Wang Message-ID: <72f284c6-b2f5-a395-a68f-afe801eb81be@redhat.com> Date: Tue, 25 May 2021 14:19:03 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <4aaf5125-ce75-c72a-4b4a-11c91cb85a72@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/5/19 下午10:18, Xianting Tian 写道: > thanks, I submit the patch as commented by Andrew > https://lkml.org/lkml/2021/5/18/256 > > Actually, if xmit_skb() returns error, below code will give a warning > with error code. > >     /* Try to transmit */ >     err = xmit_skb(sq, skb); > >     /* This should not happen! */ >     if (unlikely(err)) { >         dev->stats.tx_fifo_errors++; >         if (net_ratelimit()) >             dev_warn(&dev->dev, >                  "Unexpected TXQ (%d) queue failure: %d\n", >                  qnum, err); >         dev->stats.tx_dropped++; >         dev_kfree_skb_any(skb); >         return NETDEV_TX_OK; >     } > > > > > > 在 2021/5/18 下午5:54, Michael S. Tsirkin 写道: >> typo in subject >> >> On Tue, May 18, 2021 at 05:46:56PM +0800, Xianting Tian wrote: >>> When met error, we output a print to avoid a BUG(). So you don't explain why you need to remove BUG(). I think it deserve a BUG(). >>> >>> Signed-off-by: Xianting Tian >>> --- >>>   drivers/net/virtio_net.c | 5 ++--- >>>   1 file changed, 2 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c >>> index c921ebf3ae82..a66174d13e81 100644 >>> --- a/drivers/net/virtio_net.c >>> +++ b/drivers/net/virtio_net.c >>> @@ -1647,9 +1647,8 @@ static int xmit_skb(struct send_queue *sq, struct >>> sk_buff *skb) >>>           hdr = skb_vnet_hdr(skb); >>> >>>       if (virtio_net_hdr_from_skb(skb, &hdr->hdr, >>> -                    virtio_is_little_endian(vi->vdev), false, >>> -                    0)) >>> -        BUG(); >>> +                virtio_is_little_endian(vi->vdev), false, 0)) >>> +        return -EPROTO; >>> >> >> why EPROTO? can you add some comments to explain what is going on pls? >> >> is this related to a malicious hypervisor thing? I think not if I was not wrong. Each sources (either userspace or device), the skb should be built through virtio_net_hdr_to_skb() which means the validation has already been done. If we it fails here, it's a real bug. Thanks >> >> don't we want at least a WARN_ON? Or _ONCE? >> >>>       if (vi->mergeable_rx_bufs) >>>           hdr->num_buffers = 0; >>> -- >>> 2.17.1 >