Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4911289ybe; Mon, 16 Sep 2019 22:29:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqLqZYQNIxEyRyylj/lQYIFQkz4C3E70HlulNTjGhgytn4tnTVtzKH6brntrk7EhGAqtI3 X-Received: by 2002:a50:baab:: with SMTP id x40mr2875228ede.60.1568698156174; Mon, 16 Sep 2019 22:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568698156; cv=none; d=google.com; s=arc-20160816; b=BFqxSf3VKlqIYDEN2xFtGFKExo0zePT1OtEcQU1Co84qKmiyP1XNayA4+IzT5gqvC7 hQkKbee6wf2LzHLixMIsEusXl97Omzs82svOIBU709o+mWPLo+h/JLMLjxC9b/qfjBET gkKqumpeDY/vg6poqlVWjWYTCOInGi6oEyVMnEbjJ9fIjP1+kkqE4qLC5cm4QCsSJb2P ajdjJT3+KiR6GLwGOIFuYt3XisNbSfxjO/NGkd6nNXJmsGrFKfphVkxWeDLYNjzFq7o+ 5UlI3ovBGH5cl2/uwASqWx+1BYOSLmG4zSgkRzCC8fhBxp508RG5JENEYZBrrpBXVIV2 VOjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=n1SBt+uHOrf2NY80RC3mWzYo5Pi1aN9LLmOxk0LXvZM=; b=geJcWUQ/8D4B6mH+E1zEIojbk0bNgPGGLFDhBrFhRLJjA+iji2//s8cvf050irp+EV +KOUMbILsMoxh+ydMqKbeyaCg5Ul3XCyjwkbcxp8N9JEC4K/q9Wy6aDOHOcSWRzXVQFZ lzNP6WM3YaFAZdlNe4uzcsXwkChEHdMff6wwdvvN6edzlVAhoqgdT0YL5APx7OfzR9nn 6I9lrMdBaveAFvvzHGCJEVr3zGkCI6/h3IscroRQY7AMKz1Tckg+T+nazf76sN8tUBzK AucCIVisM1vemCOnmQUjgiUaYX5zj6P4qALa1u3UNfKoVbPAfjdzq4/KMk1CWkXy9isv SFaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j47si746492ede.117.2019.09.16.22.28.38; Mon, 16 Sep 2019 22:29:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388518AbfIPTrL (ORCPT + 99 others); Mon, 16 Sep 2019 15:47:11 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:50622 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727920AbfIPTrL (ORCPT ); Mon, 16 Sep 2019 15:47:11 -0400 Received: from localhost (80-167-222-154-cable.dk.customer.tdc.net [80.167.222.154]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 70FB6153F26F6; Mon, 16 Sep 2019 12:47:09 -0700 (PDT) Date: Mon, 16 Sep 2019 21:47:07 +0200 (CEST) Message-Id: <20190916.214707.1312089672859838604.davem@davemloft.net> To: dongli.zhang@oracle.com Cc: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] xen-netfront: do not assume sk_buff_head list is empty in error handling From: David Miller In-Reply-To: <1568605619-22219-1-git-send-email-dongli.zhang@oracle.com> References: <1568605619-22219-1-git-send-email-dongli.zhang@oracle.com> X-Mailer: Mew version 6.8 on Emacs 26.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 16 Sep 2019 12:47:11 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongli Zhang Date: Mon, 16 Sep 2019 11:46:59 +0800 > When skb_shinfo(skb) is not able to cache extra fragment (that is, > skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS), xennet_fill_frags() assumes > the sk_buff_head list is already empty. As a result, cons is increased only > by 1 and returns to error handling path in xennet_poll(). > > However, if the sk_buff_head list is not empty, queue->rx.rsp_cons may be > set incorrectly. That is, queue->rx.rsp_cons would point to the rx ring > buffer entries whose queue->rx_skbs[i] and queue->grant_rx_ref[i] are > already cleared to NULL. This leads to NULL pointer access in the next > iteration to process rx ring buffer entries. > > Below is how xennet_poll() does error handling. All remaining entries in > tmpq are accounted to queue->rx.rsp_cons without assuming how many > outstanding skbs are remained in the list. > > 985 static int xennet_poll(struct napi_struct *napi, int budget) > ... ... > 1032 if (unlikely(xennet_set_skb_gso(skb, gso))) { > 1033 __skb_queue_head(&tmpq, skb); > 1034 queue->rx.rsp_cons += skb_queue_len(&tmpq); > 1035 goto err; > 1036 } > > It is better to always have the error handling in the same way. > > Fixes: ad4f15dc2c70 ("xen/netfront: don't bug in case of too many frags") > Signed-off-by: Dongli Zhang Applied and queued up for -stable.