Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp357970ybi; Fri, 21 Jun 2019 00:38:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyETnbkdusZGJaRsMT7oXEyPLlY1S7UBwsi4EE8lvOzAfSCqpYYzFhR9P1jqEZFITJUQ5OH X-Received: by 2002:a17:90a:8984:: with SMTP id v4mr4689138pjn.133.1561102725799; Fri, 21 Jun 2019 00:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561102725; cv=none; d=google.com; s=arc-20160816; b=Sa0Ak7d2B7mYwdhVL0097+fTzDokEev8TJ1TZEpIMDmqg5Po0DwnUw0PgX+w1kCFhr uSqa1vibtrEGu+J9/H4thMXqEAf/Ml3DOars/LYr9eEqrPBxutiJTaUUataqPMLvpEPh 67tEPivGlYyiMSw5GVZT41dpw454SkBqn3m/77PuEsbCtdahkfaL1DqGcJT274oPd/8H CBlXJrfnoxuR8nUENl4GA+c2NUir2+rqYJ8zPsXaTZRQqbYBPaKaSOS9y24PIb+vovHM oWD0c54yjDXKGfkPAoZqW/CIc1B8NhnZy+De5dHlsBhy67i2MAZ+ckaVFkeNfrDwy9oA J/AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:authenticated-by; bh=ER2owGgvMTkAyM99uCX5CtkWNy3Q7GhsUecyu1TtjZA=; b=0KNHxHJmYfbK62idSgrEtP8xxOk7O3BcZuRxmZaWBKO271asVYYSNNmAq7Yg4UTCpm O7gcCwnAEX6G1CqZL9xLbdwOfI9GBI+RiXDIoZaSNoQO0FXrRjhmggAAKAxrP7aLTnmx 089ahuFNCBGHTNg8vP6l+MGCowFAXrvBOsDeSOOQ0Tz8uMvRSPz2AlOS1ZPti8FAWYRs +90ewRQYuclLS5c8P7qW+MxpnvknoaeSBrjCAD2pFcxMMtS/CrI2u0tVMm2z9A84QZhl Vo4tmKenCUsusJ7TzwKF50aC8rmZsZ4vOPOUYczfYYlwipgBuYvvX8IYoMeMEiGJt7lW vl2A== 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 k16si1967506pfk.68.2019.06.21.00.38.27; Fri, 21 Jun 2019 00:38:45 -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 S1726210AbfFUHh4 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 Jun 2019 03:37:56 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:35733 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfFUHh4 (ORCPT ); Fri, 21 Jun 2019 03:37:56 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x5L7brVl030197, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcas11.realtek.com.tw[172.21.6.12]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x5L7brVl030197 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 21 Jun 2019 15:37:54 +0800 Received: from RTITMBSVM03.realtek.com.tw ([fe80::e1fe:b2c1:57ec:f8e1]) by RTITCAS11.realtek.com.tw ([fe80::7c6d:ced5:c4ff:8297%15]) with mapi id 14.03.0439.000; Fri, 21 Jun 2019 15:37:53 +0800 From: Hayes Wang To: "netdev@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" , nic_swsd Subject: RE: skb_to_sgvec() causes sg_pcopy_to_buffer() wrong Thread-Topic: skb_to_sgvec() causes sg_pcopy_to_buffer() wrong Thread-Index: AdUoAJuGWMqsusSOQtK6xG/aC4OtZQ== Date: Fri, 21 Jun 2019 07:37:52 +0000 Message-ID: <0835B3720019904CB8F7AA43166CEEB2F18A049D@RTITMBSVM03.realtek.com.tw> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.21.177.214] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Use skb_to_sgvec() to set scatter list, and sometime we would get a > sg->offset which is more than PAGE_SIZE. Call sg_pcopy_to_buffer() > with this scatter list would get wrong data. > > In sg_miter_get_next_page(), you would get wrong miter->__remaining, > when the sg->offset is more than PAGE_SIZE. > > static bool sg_miter_get_next_page(struct sg_mapping_iter *miter) > { > if (!miter->__remaining) { > struct scatterlist *sg; > unsigned long pgoffset; > > if (!__sg_page_iter_next(&miter->piter)) > return false; > > sg = miter->piter.sg; > pgoffset = miter->piter.sg_pgoffset; > > miter->__offset = pgoffset ? 0 : sg->offset; > miter->__remaining = sg->offset + sg->length - > (pgoffset << PAGE_SHIFT) - miter->__offset; > miter->__remaining = min_t(unsigned long, miter->__remaining, > PAGE_SIZE - miter->__offset); > } > > return true; > } Excuse me. The following patch could solve my problem. https://patchwork.kernel.org/patch/11000549/ Best Regards, Hayes