From patchwork Tue Jan 19 12:30:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 12029893 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8841C43219 for ; Tue, 19 Jan 2021 14:12:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C06E12313B for ; Tue, 19 Jan 2021 14:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387512AbhASOB5 (ORCPT ); Tue, 19 Jan 2021 09:01:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56746 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393138AbhASMdB (ORCPT ); Tue, 19 Jan 2021 07:33:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611059493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lEJP/GTD2F7xeOrpz7tftxb2cGM9XX10WDfz1YKvxjU=; b=QYvUNl7NhbLAWAk8+U2aLTYNEf3gnyvDrGKXR5/WL/TH7e11NpK6+Ui4LHWBiwow9shFLA JNHGe1u/cdzmNkHvguk2CWAFXf4xBCTC3QfRddty5veAtQT53s+QfTVa/e3dxzZKOjVtpx 9qd+G8ZEjAJdg0JZB68Az81C5bVKm+M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-bi-u0zy_OqmjY15JZmcfGg-1; Tue, 19 Jan 2021 07:31:31 -0500 X-MC-Unique: bi-u0zy_OqmjY15JZmcfGg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F7838066E5; Tue, 19 Jan 2021 12:31:30 +0000 (UTC) Received: from gerbillo.redhat.com (ovpn-115-139.ams2.redhat.com [10.36.115.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 880B161F47; Tue, 19 Jan 2021 12:31:28 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Alexander Duyck , Xin Long Subject: [PATCH net-next] net: fix GSO for SG-enabled devices. Date: Tue, 19 Jan 2021 13:30:32 +0100 Message-Id: <61306401471dcfc6219d5c001580769c2c67377a.1611059420.git.pabeni@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The commit dbd50f238dec ("net: move the hsize check to the else block in skb_segment") introduced a data corruption for devices supporting scatter-gather. The problem boils down to signed/unsigned comparison given unexpected results: if signed 'hsize' is negative, it will be considered greater than a positive 'len', which is unsigned. This commit addresses the issue explicitly casting 'len' to a signed integer, so that the comparison gives the correct result. Bisected-by: Matthieu Baerts Fixes: dbd50f238dec ("net: move the hsize check to the else block in skb_segment") Signed-off-by: Paolo Abeni --- note: a possible more readable alternative would be moving the if (hsize < 0) before 'if (hsize > len)', but that was explicitly discouraged in a previous iteration of the blamed commit to save a comparison, so I opted to preserve that optimization. --- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index e835193cabcc3..27f69c0bd8393 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3938,7 +3938,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, skb_release_head_state(nskb); __skb_push(nskb, doffset); } else { - if (hsize > len || !sg) + if (hsize > (int)len || !sg) hsize = len; else if (hsize < 0) hsize = 0;