Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4160540pxk; Tue, 8 Sep 2020 12:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgpuKW4KpGBGp73uANwv5fbqIgaegf4Rv5szxvtGJEtNkTANtKEc23wZ1optymMv+jkGk/ X-Received: by 2002:a17:906:4553:: with SMTP id s19mr26518074ejq.475.1599592414533; Tue, 08 Sep 2020 12:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592414; cv=none; d=google.com; s=arc-20160816; b=Auv3tIoJ4hxUw6Mzrz02OPrX+M9t+4hjBABS43IRwNxIrQuSYhB6wCHDjFhZe6Qwi+ OTTg+1fVxMaLhWIDU4ssKRte8ApmSDTIpnT+Ry+LGIThN+yumqcFY0SWzCWeZKgzbxoY KUxbN6Cc4JtsBKRCtQ5idRVZ69DqJV5V+dYM81Fem/bq4msybNiGsvAyVEN3lTv2Ab4D hGQ/6xGoIuMzo1NU2tVgPXta/S0T5JjO13cpOid7E1P13cs7vHJwraAEVDVvVBid4EtX RMd3PBS8vGnygVvQR57epD6fBstOAWgAj2tFQVQh1ZS9bcfS8VCTRlSqYLph+PjV110m tEag== 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=o5xW3tzmmjx2XnwbEB6CHzNikQ+Gd+8uoC1j8LQXHDc=; b=vybOIdzKKde9ITsQax/VSIk+5lccP8wCXaOjw7oZP6WUBXDSTqoPPng6myRJCRJs84 Z2MpsSWJ6eqYsL/cQaLEVrluuVc/EXW71MV4H3Gfz7whWxjdlPvzHq9EYRjNE6RFTGI8 NOvficRZJRJoJmKsguknPGA8e0/IAeOAdxAMttqtKgOlqTJKyQCywOP6zGUoKIsadeb5 S+1hk6qz6v2sVOLEyPWhHNPASssDJ5RaRSEyuilj6jEwnGYOWuSRFn61c/6STAiMj4f7 gythGqEvArWoS9BK393B5TOCRZW8NaRZAqdt4poYIuPeyDKl8X9eumk3gZpdRof350Kd M/Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=06eRAlDB; 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 v9si12701231ejy.486.2020.09.08.12.13.12; Tue, 08 Sep 2020 12:13:34 -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=06eRAlDB; 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 S1731779AbgIHTJn (ORCPT + 99 others); Tue, 8 Sep 2020 15:09:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:52184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731242AbgIHQGG (ORCPT ); Tue, 8 Sep 2020 12:06:06 -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 BEAE623D98; Tue, 8 Sep 2020 15:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579988; bh=LVFtUbN8kB/NzGTulFlYLIJ9VXAqtL2cKacFGNDEop0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=06eRAlDBSI/UnPP/TRnf+mWZtlgcmTGJ7ivtfKCo5hbmhdxWgwe7ahEggrftd4etY xcpqDR1yLQ54o2bnZ3mFfuLLmMXiLuMF1jHA5uINj5kJs6e2o/rTuucScZFzmqVPJj TRNXfBI5reYURPIZp+REhCDYpis6e3oiVr8+dlWs= 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.4 107/129] block: allow for_each_bvec to support zero len bvec Date: Tue, 8 Sep 2020 17:25:48 +0200 Message-Id: <20200908152235.182968463@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@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 @@ -110,11 +110,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) \