From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751422AbdHXKs2 (ORCPT ); Thu, 24 Aug 2017 06:48:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:59759 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751182AbdHXKs0 (ORCPT ); Thu, 24 Aug 2017 06:48:26 -0400 From: Michal Kubecek Subject: [PATCH nf-next] netfilter: xt_CHECKSUM: avoid bad offload warnings on GSO packets To: Pablo Neira Ayuso Cc: Jozsef Kadlecsik , Florian Westphal , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Michael S. Tsirkin" , Markos Chandras Message-Id: <20170824104824.2C318A0F3A@unicorn.suse.cz> Date: Thu, 24 Aug 2017 12:48:24 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When --checksum_fill action is applied to a GSO packet, checksum_tg() calls skb_checksum_help() which is only meant to be applied to non-GSO packets so that it issues a warning. This can be easily triggered by using e.g. iptables -t mangle -A OUTPUT -j CHECKSUM --checksum-fill and sending TCP stream via a device with GSO enabled. While this can be considered a misconfiguration, I believe the bad offload warning is supposed to catch bugs in drivers and networking stack, not misconfigured firewalls. So let's ignore such packets and only issue a one time warning with pr_warn_once() rather than a WARN with stack trace and tainted kernel. Reported-by: Markos Chandras Signed-off-by: Michal Kubecek --- net/netfilter/xt_CHECKSUM.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/netfilter/xt_CHECKSUM.c b/net/netfilter/xt_CHECKSUM.c index 0f642ef8cd26..9a007153ba7f 100644 --- a/net/netfilter/xt_CHECKSUM.c +++ b/net/netfilter/xt_CHECKSUM.c @@ -25,8 +25,12 @@ MODULE_ALIAS("ip6t_CHECKSUM"); static unsigned int checksum_tg(struct sk_buff *skb, const struct xt_action_param *par) { - if (skb->ip_summed == CHECKSUM_PARTIAL) - skb_checksum_help(skb); + if (skb->ip_summed == CHECKSUM_PARTIAL) { + if (unlikely(skb_is_gso(skb))) + pr_warn_once("cannot mangle checksum of a GSO packet\n"); + else + skb_checksum_help(skb); + } return XT_CONTINUE; } -- 2.14.1