From patchwork Sat Apr 29 02:38:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 98379 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp532806qgf; Fri, 28 Apr 2017 19:40:58 -0700 (PDT) X-Received: by 10.99.61.130 with SMTP id k124mr15449293pga.68.1493433658787; Fri, 28 Apr 2017 19:40:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 202si7297884pfx.159.2017.04.28.19.40.58; Fri, 28 Apr 2017 19:40:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166158AbdD2CjZ (ORCPT + 6 others); Fri, 28 Apr 2017 22:39:25 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:5901 "EHLO dggrg03-dlp.huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1164198AbdD2CjX (ORCPT ); Fri, 28 Apr 2017 22:39:23 -0400 Received: from 172.30.72.54 (EHLO DGGEML401-HUB.china.huawei.com) ([172.30.72.54]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AMR33293; Sat, 29 Apr 2017 10:39:00 +0800 (CST) Received: from [127.0.0.1] (10.177.23.32) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Sat, 29 Apr 2017 10:38:51 +0800 From: Ding Tianhong Subject: [PATCH v2] iov_iter: don't revert iov buffer if csum error To: David Miller , , , , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , LinuxArm , "weiyongjun (A)" Message-ID: Date: Sat, 29 Apr 2017 10:38:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-Originating-IP: [10.177.23.32] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.5903FCC5.001F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e0ed15828799c7e5aff04e73e2ee414a Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The patch 327868212381 (make skb_copy_datagram_msg() et.al. preserve ->msg_iter on error) will revert the iov buffer if copy to iter failed, but it didn't copy any datagram if the skb_checksum_complete error, so no need to revert any data at this place. v2: Sabrina notice that return -EFAULT when checksum error is not correct here, it would confuse the caller about the return value, so fix it. Fixes: 327868212381 ("make skb_copy_datagram_msg() et.al. preserve->msg_iter on error") Signed-off-by: Ding Tianhong Signed-off-by: Wei Yongjun --- net/core/datagram.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 1.8.3.1 diff --git a/net/core/datagram.c b/net/core/datagram.c index f4947e7..0e6a9a9 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -768,14 +768,17 @@ int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, if (skb_copy_and_csum_datagram(skb, hlen, &msg->msg_iter, chunk, &csum)) goto fault; - if (csum_fold(csum)) + + if (csum_fold(csum)) { + iov_iter_revert(&msg->msg_iter, chunk); goto csum_error; + } + if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) netdev_rx_csum_fault(skb->dev); } return 0; csum_error: - iov_iter_revert(&msg->msg_iter, chunk); return -EINVAL; fault: return -EFAULT;