From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 29012C433E2 for ; Tue, 8 Sep 2020 19:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC56F20759 for ; Tue, 8 Sep 2020 19:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599592919; bh=zb4/Ed/CxmNBIRBj9N2X/WrV5NCUuq0RWYDcGIO4sU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TiUL7AaE9hDjXMSioWd3EQfP01vSMWblzn8kEdrukN5yK8RzmtR21FzUu+FeBIR2y QnhgPjU0lc+m7pDatKwnrL8tHIYYq7ewlqUSuvAdtHFg/hckHV4RQsuQ+VDmrrEgrC E0u3WudJ4QxcH5TQgZPlvE3wBJSpdWx5AU54qlqE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731995AbgIHTV5 (ORCPT ); Tue, 8 Sep 2020 15:21:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731104AbgIHQBf (ORCPT ); Tue, 8 Sep 2020 12:01:35 -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 399DF246E9; Tue, 8 Sep 2020 15:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579615; bh=zb4/Ed/CxmNBIRBj9N2X/WrV5NCUuq0RWYDcGIO4sU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IWp0ASp3TirVwPFddDTtOieHEmtU7XJpr28mOa4VwpODxx1qu9b+Tuy5KeTUeNb/N a9ZKN/W3V/ljKi7YJIp77xQbNb9uMF4L1XmrEJmCGxhMxbQ06VHaPqOBWrY2hNkQCH UX1eFnPnBgu8qsbm05mrkSKQJ91BJAIb428jMNHE= 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 5.8 152/186] block: allow for_each_bvec to support zero len bvec Date: Tue, 8 Sep 2020 17:24:54 +0200 Message-Id: <20200908152249.023861290@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152241.646390211@linuxfoundation.org> References: <20200908152241.646390211@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 @@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(con return true; } +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))) /* for iterating one bio from start to end */ #define BVEC_ITER_ALL_INIT (struct bvec_iter) \