Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2273797pxb; Mon, 11 Jan 2021 05:46:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZjLStituNW4DmnPctzIF1n/tYVxEWXpv3D+3GN6JO1o+Gx9bK3Ju/050imMg/Lsm6qXzn X-Received: by 2002:a50:ee1a:: with SMTP id g26mr14291874eds.68.1610372799686; Mon, 11 Jan 2021 05:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372799; cv=none; d=google.com; s=arc-20160816; b=pbobo/kS2uw6+44ggGjsnYIX65CCT4/OKNgh0JLgG5Ak3W/VywN4bqtA1ahSwbmVSW QgTsSWurBbcy57/4xJ8xVBK8uK/d05v9s+RrCOEr1SQQwunx6P3TQHsUPL/QwdF8ufiO XMh8+MfOyurdM4557fII6CqKT2riT7sBbwpnN7Dv1kANmFhB9JCcbwiF+QkuS2qqZlDN YVszYXCAS5VlYy5q/aHcMp7KbvWBmtBZU3LLj89Yeym/vf6da0OY2ELf86keb2LWPb4q fgERdKLJ1gNJWKwu6IV5HPEV06VtGxDNgjlXLQQ+0aUOoZjUw0SF1EsfOg/JJFi4BOU5 ARcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/uQxhaUgK21hXM00bjnIVsdgE1VQ6IyOjnDs/7aZzJ4=; b=YdiBlC7OV3MuC5EapNl/K87savFYIlQlxsh3pELp+hF2hlcvm1/IVKVd9cppIdTNCz G2dS6j9pUCl4auWZ57NX0W9icIfUfdSjcfKYsUxMK4TShdVNaL4KvGgRAJR+32UKq5Yv c8SDWZh60aBZ12bnbd2yeE+OsUwdCjRHpNO4h1C6e3uKAo2FA/vtTSvWqKHr0QBaEjpV dlf9CJoXAa1iN70qrpcGCld1SXyhuXScxYLIlESPsI86PH1nmU6gXkwWMO+i8fFW9rY3 Dm2MeydCVugufAVUebzh+7w9MW+QM9Rr6I54Ip6xi27fW0Mzs+f0v27qD/tmquYzD7gB pXgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VErvCGoz; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d92si7062739edd.33.2021.01.11.05.46.15; Mon, 11 Jan 2021 05:46:39 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=VErvCGoz; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387718AbhAKNnW (ORCPT + 99 others); Mon, 11 Jan 2021 08:43:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:58908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730792AbhAKNL7 (ORCPT ); Mon, 11 Jan 2021 08:11:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF7EB2255F; Mon, 11 Jan 2021 13:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370704; bh=6R25EZ9NDxWxuLAw08CwEgyMKSZFbQhVTswTkVPgFZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VErvCGozU8V0l5YTIfLkIGeo+Cnzq1bcd5iYbjKKuXH6HJZV33TXfkzOjuk74oLI5 6sHwf9aPoaShR0qMosa74oGCcIkMv/XfjOubXzgd/W+pjJ+iLX+sjmg9MI83njoQJ4 bK4AVFtgGYNYwOUBDMd2kGLQGkkzhzTWb6j3LIPI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunjian Wang , Willem de Bruijn , Jason Wang , "Michael S. Tsirkin" , Jakub Kicinski Subject: [PATCH 5.4 31/92] tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS Date: Mon, 11 Jan 2021 14:01:35 +0100 Message-Id: <20210111130040.648412742@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunjian Wang [ Upstream commit 950271d7cc0b4546af3549d8143c4132d6e1f138 ] Currently the tun_napi_alloc_frags() function returns -ENOMEM when the number of iovs exceeds MAX_SKB_FRAGS + 1. However this is inappropriate, we should use -EMSGSIZE instead of -ENOMEM. The following distinctions are matters: 1. the caller need to drop the bad packet when -EMSGSIZE is returned, which means meeting a persistent failure. 2. the caller can try again when -ENOMEM is returned, which means meeting a transient failure. Fixes: 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver") Signed-off-by: Yunjian Wang Acked-by: Willem de Bruijn Acked-by: Jason Wang Acked-by: Michael S. Tsirkin Link: https://lore.kernel.org/r/1608864736-24332-1-git-send-email-wangyunjian@huawei.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/tun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1469,7 +1469,7 @@ static struct sk_buff *tun_napi_alloc_fr int i; if (it->nr_segs > MAX_SKB_FRAGS + 1) - return ERR_PTR(-ENOMEM); + return ERR_PTR(-EMSGSIZE); local_bh_disable(); skb = napi_get_frags(&tfile->napi);