Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp405012ybn; Tue, 1 Oct 2019 23:29:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyg0zbITRuZMbN0MCmqIiE+18N87t+MLTk4jwNwodnuSixrGLTePl1h2X2U1PLAlpPvTOKC X-Received: by 2002:a17:906:3e96:: with SMTP id a22mr1633906ejj.268.1569997758243; Tue, 01 Oct 2019 23:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569997758; cv=none; d=google.com; s=arc-20160816; b=0yMzeBVPMo5YTjr9Etzmmuq6P2FonjBhl9WoZLl288L6rwyHmQYWrCMvAp492GD9dR oE/6lHlbZXcWHwwM0og3xu3BuS2cKA1JL7hW7b4QMZvDgmgNMS6yBLClKcUcEP2YBcsO 80dDNVg9UFmiTkdhso7REZ9B9La2rNwa2P/WKtr6Zf1emau07Rkr+RyJeS50r5vJQwkw Js73ZqOhzfhoTETUQiEFf9yo4oRUTmFGEQtDhcutNUwj+h5SlOpa6hCIi+5b5C4oBYY7 fzi1QN0jQj9aaLRK++3GGh/rfYm4dSHtVsT1s7GhHMBSmLx/QhnC7LHutUmMSk0UjqXX ydDQ== 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=e9p4J4BaljBnvb8iL5qJbI50hWP/oXRCGuzoku5hLqw=; b=EP/noWMW5bVXTDgplzkHKJKyVb6FhsYoKS16jgZIQPySdzpd5C+LkjfcDAQTDEw2JR y5mokwwUc+gCtFQUZ8iDPKqcodr64Fpvzp5ZFz3AsLdnWbhdOGnpu/B47YRSIdBg4qA9 0APfO7//l/pBvb1kDter02m4p1PtsrDwkyghRgBlzxeWty7dZtu5WRkDXUhy0O8CZW1T v7wQhO/8a9/1PCbo1EYbbNKLRNByXt6Gq0HD41jk2tRrHs3yillMruZ+RnjwBamNWVlA VCd5rkzFrve+AIQBvAeYUAXMzu7ND484s27NYO4ZOeBPE18Z7gSv4TDsmmHF6BTzArL+ BaTQ== 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 qu18si10107526ejb.80.2019.10.01.23.28.54; Tue, 01 Oct 2019 23:29:18 -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 S1729746AbfJBBu4 (ORCPT + 99 others); Tue, 1 Oct 2019 21:50:56 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:55480 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbfJBBu4 (ORCPT ); Tue, 1 Oct 2019 21:50:56 -0400 Received: from localhost (unknown [IPv6:2603:3023:50c:85e1:b5c5:ae11:3e54:6a07]) (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 E58B51530FB4F; Tue, 1 Oct 2019 18:50:54 -0700 (PDT) Date: Tue, 01 Oct 2019 21:50:54 -0400 (EDT) Message-Id: <20191001.215054.2217306306286086981.davem@davemloft.net> To: dongli.zhang@oracle.com Cc: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, sstabellini@kernel.org, linux-kernel@vger.kernel.org, joe.jin@oracle.com Subject: Re: [PATCH v2 1/1] xen-netfront: do not use ~0U as error return value for xennet_fill_frags() From: David Miller In-Reply-To: <1569938201-23620-1-git-send-email-dongli.zhang@oracle.com> References: <1569938201-23620-1-git-send-email-dongli.zhang@oracle.com> X-Mailer: Mew version 6.8 on Emacs 26.1 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]); Tue, 01 Oct 2019 18:50:55 -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: Tue, 1 Oct 2019 21:56:41 +0800 > xennet_fill_frags() uses ~0U as return value when the sk_buff is not able > to cache extra fragments. This is incorrect because the return type of > xennet_fill_frags() is RING_IDX and 0xffffffff is an expected value for > ring buffer index. > > In the situation when the rsp_cons is approaching 0xffffffff, the return > value of xennet_fill_frags() may become 0xffffffff which xennet_poll() (the > caller) would regard as error. As a result, queue->rx.rsp_cons is set > incorrectly because it is updated only when there is error. If there is no > error, xennet_poll() would be responsible to update queue->rx.rsp_cons. > Finally, 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. > > The symptom is similar to the one fixed in > commit 00b368502d18 ("xen-netfront: do not assume sk_buff_head list is > empty in error handling"). > > This patch changes the return type of xennet_fill_frags() to indicate > whether it is successful or failed. The queue->rx.rsp_cons will be > always updated inside this function. > > Fixes: ad4f15dc2c70 ("xen/netfront: don't bug in case of too many frags") > Signed-off-by: Dongli Zhang Applied and queued up for -stable.