Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp324153pxk; Fri, 11 Sep 2020 07:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoQD5peskwZz0yvc2RxEeUmfCtx7luG04ygn6E6DZ1QIM6nhUM/S+BfPCypXKaCUraAgPq X-Received: by 2002:a17:906:4755:: with SMTP id j21mr2498847ejs.228.1599836231858; Fri, 11 Sep 2020 07:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599836231; cv=none; d=google.com; s=arc-20160816; b=DicYqG6IZwmfQt2ecec+Wl+3n7dTMoFSoPUGVQ6eTAFoHCa/jRwGr27EoPUfO69POX 8jlBg4DIGRA7gyEMnfu+z/R0c9VUGC7aTnL76AeZeaLSC/zse0CryeRhrlHLpnDzmFMn QIuZiZawv8lkDqBQMqJgJAFaUb7OIXAZ/YIFyogwlga/h2IVWSO2BH4khdO2Q9fbG9a5 Xydi2aX2kffZd7qsjSwit/IXQJnoYr4q5XdXouJwN6odIz67PVTpNum9H5PrItRR2Cgd RGlXZx3VV100AKDJRQ/VAV2XBFzEGMahlZJ3YNJLlNHlpLSDvGenHn4wPWzBIagmYY1O /bRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1wNkZpVUsIhrkkMQkn6tT9UvXSRGNXYA/jLtVDiDivQ=; b=Pe0N30f7GLR9XBhJqlV8Mz6OojUEIElxIFBb5ovKGEpyG+jsU5cgEtZXevzehNq9VH 5RnN37xejNrILOkXoOKtxIyxliXhvBPUWVNAgphOtOEMRXTakujmh2O3vZEmQtYT2UkU Re3Souirc6CouPSLzv3yFQ6zhG0AbJbWBh5rZQ3q6VhLt4rgXhPn9hb/j6jw8eekobVU wWTEwtPaYarywOPNKHB8zxx8pL3iGALGIFap3XSriTSc7plDb6bHB7OsxSG0DbkndYWp FIC/qFYVDIpyJSJxUMdTRr/Fp19JYXNRspA7hc2worSSifBdzWX1t166lvOof+hifeG+ F04Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UUPAuEEI; 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=fail (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 t18si1398157eje.652.2020.09.11.07.56.48; Fri, 11 Sep 2020 07:57:11 -0700 (PDT) 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=@kernel.org header.s=default header.b=UUPAuEEI; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726226AbgIKOz6 (ORCPT + 99 others); Fri, 11 Sep 2020 10:55:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbgIKNCU (ORCPT ); Fri, 11 Sep 2020 09:02:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05982222BA; Fri, 11 Sep 2020 12:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829040; bh=99r5w4O8248Tl0eMNSWdsulWkBEbz3tyeCLnihvggk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UUPAuEEI18yAiujrFZUszk9k299qFyQh72X7dUT8gM3SJGayG+tpnGST9HJJyq1OW jxp6ybY5ZriaX5TxqsNNzo9HvV61IsJiIrqflN1deTbxlP/mgdkWS9PqEHwf8V//Sa H8Sy4D7iHlCpXXFiaGWya19+E0erzHMBgJ40EsN0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Ming Lei , Tetsuo Handa , Al Viro , Matthew Wilcox , Jens Axboe Subject: [PATCH 4.9 43/71] block: allow for_each_bvec to support zero len bvec Date: Fri, 11 Sep 2020 14:46:27 +0200 Message-Id: <20200911122507.074597960@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei commit 7e24969022cbd61ddc586f14824fc205661bb124 upstream. Block layer usually doesn't support or allow zero-length bvec. Since commit 1bdc76aea115 ("iov_iter: use bvec iterator to implement iterate_bvec()"), iterate_bvec() switches to bvec iterator. However, Al mentioned that 'Zero-length segments are not disallowed' in iov_iter. Fixes for_each_bvec() so that it can move on after seeing one zero length bvec. Fixes: 1bdc76aea115 ("iov_iter: use bvec iterator to implement iterate_bvec()") Reported-by: syzbot Signed-off-by: Ming Lei Tested-by: Tetsuo Handa Cc: Al Viro Cc: Matthew Wilcox Cc: Link: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2262077.html Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- include/linux/bvec.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -88,10 +88,17 @@ static inline void bvec_iter_advance(con } } +static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter) +{ + iter->bi_bvec_done = 0; + iter->bi_idx++; +} + #define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \ - bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len)) + (bvl).bv_len ? (void)bvec_iter_advance((bio_vec), &(iter), \ + (bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter))) #endif /* __LINUX_BVEC_ITER_H */