linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ilya Dryomov <idryomov@gmail.com>,
	Sasha Levin <sashal@kernel.org>,
	ceph-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 48/68] libceph: fix breakage caused by multipage bvecs
Date: Mon, 22 Apr 2019 15:44:56 -0400	[thread overview]
Message-ID: <20190422194516.11634-48-sashal@kernel.org> (raw)
In-Reply-To: <20190422194516.11634-1-sashal@kernel.org>

From: Ilya Dryomov <idryomov@gmail.com>

[ Upstream commit 187df76325af5d9e12ae9daec1510307797e54f0 ]

A bvec can now consist of multiple physically contiguous pages.
This means that bvec_iter_advance() can move to a different page while
staying in the same bvec (i.e. ->bi_bvec_done != 0).

The messenger works in terms of segments which can now be defined as
the smaller of a bvec and a page.  The "more bytes to process in this
segment" condition holds only if bvec_iter_advance() leaves us in the
same bvec _and_ in the same page.  On next bvec (possibly in the same
page) and on next page (possibly in the same bvec) we may need to set
->last_piece.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
 net/ceph/messenger.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index f7d7f32ac673..ef5216206bdf 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -870,6 +870,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
 					size_t bytes)
 {
 	struct ceph_bio_iter *it = &cursor->bio_iter;
+	struct page *page = bio_iter_page(it->bio, it->iter);
 
 	BUG_ON(bytes > cursor->resid);
 	BUG_ON(bytes > bio_iter_len(it->bio, it->iter));
@@ -881,7 +882,8 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
 		return false;   /* no more data */
 	}
 
-	if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done))
+	if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done &&
+		       page == bio_iter_page(it->bio, it->iter)))
 		return false;	/* more bytes to process in this segment */
 
 	if (!it->iter.bi_size) {
@@ -929,6 +931,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
 					size_t bytes)
 {
 	struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs;
+	struct page *page = bvec_iter_page(bvecs, cursor->bvec_iter);
 
 	BUG_ON(bytes > cursor->resid);
 	BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter));
@@ -940,7 +943,8 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
 		return false;   /* no more data */
 	}
 
-	if (!bytes || cursor->bvec_iter.bi_bvec_done)
+	if (!bytes || (cursor->bvec_iter.bi_bvec_done &&
+		       page == bvec_iter_page(bvecs, cursor->bvec_iter)))
 		return false;	/* more bytes to process in this segment */
 
 	BUG_ON(cursor->last_piece);
-- 
2.19.1


  parent reply	other threads:[~2019-04-22 20:01 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 19:44 [PATCH AUTOSEL 4.19 01/68] ARM: dts: bcm283x: Fix hdmi hpd gpio pull Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 02/68] s390: limit brk randomization to 32MB Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 03/68] net: ieee802154: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 04/68] ieee802154: hwsim: propagate genlmsg_reply return code Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 05/68] net: stmmac: don't set own bit too early for jumbo frames Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 06/68] qlcnic: Avoid potential NULL pointer dereference Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 07/68] xsk: fix umem memory leak on cleanup Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 08/68] staging: axis-fifo: add CONFIG_OF dependency Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 09/68] staging, mt7621-pci: fix build without pci support Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 10/68] netfilter: nft_set_rbtree: check for inactive element after flag mismatch Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 11/68] netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 12/68] netfilter: fix NETFILTER_XT_TARGET_TEE dependencies Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 13/68] netfilter: ip6t_srh: fix NULL pointer dereferences Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 14/68] s390/qeth: fix race when initializing the IP address table Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 15/68] ARM: imx51: fix a leaked reference by adding missing of_node_put Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 16/68] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init() Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 17/68] serial: ar933x_uart: Fix build failure with disabled console Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 18/68] KVM: arm64: Reset the PMU in preemptible context Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 19/68] KVM: arm/arm64: vgic-its: Take the srcu lock when writing to guest memory Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 20/68] KVM: arm/arm64: vgic-its: Take the srcu lock when parsing the memslots Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 21/68] usb: dwc3: pci: add support for Comet Lake PCH ID Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 22/68] usb: gadget: net2280: Fix overrun of OUT messages Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 23/68] usb: gadget: net2280: Fix net2280_dequeue() Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 24/68] usb: gadget: net2272: Fix net2272_dequeue() Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 25/68] ARM: dts: pfla02: increase phy reset duration Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 26/68] i2c: i801: Add support for Intel Comet Lake Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 27/68] net: ks8851: Dequeue RX packets explicitly Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 28/68] net: ks8851: Reassert reset pin if chip ID check fails Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 29/68] net: ks8851: Delay requesting IRQ until opened Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 30/68] net: ks8851: Set initial carrier state to down Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 31/68] staging: rtl8188eu: Fix potential NULL pointer dereference of kcalloc Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 32/68] staging: rtlwifi: rtl8822b: fix to avoid potential NULL pointer dereference Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 33/68] staging: rtl8712: uninitialized memory in read_bbreg_hdl() Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 34/68] staging: rtlwifi: Fix potential NULL pointer dereference of kzalloc Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 35/68] net: macb: Add null check for PCLK and HCLK Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 36/68] net/sched: don't dereference a->goto_chain to read the chain index Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 37/68] ARM: dts: imx6qdl: Fix typo in imx6qdl-icore-rqs.dtsi Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 38/68] drm/tegra: hub: Fix dereference before check Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 39/68] NFS: Fix a typo in nfs_init_timeout_values() Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 40/68] net: xilinx: fix possible object reference leak Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 41/68] net: ibm: " Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 42/68] net: ethernet: ti: " Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 43/68] drm: Fix drm_release() and device unplug Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 44/68] gpio: aspeed: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 45/68] drm/meson: Fix invalid pointer in meson_drv_unbind() Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 46/68] drm/meson: Uninstall IRQ handler Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 47/68] ARM: davinci: fix build failure with allnoconfig Sasha Levin
2019-04-22 19:44 ` Sasha Levin [this message]
2019-04-23  8:27   ` [PATCH AUTOSEL 4.19 48/68] libceph: fix breakage caused by multipage bvecs Ilya Dryomov
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 49/68] scsi: mpt3sas: Fix kernel panic during expander reset Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 50/68] scsi: aacraid: Insure we don't access PCIe space during AER/EEH Sasha Levin
2019-04-22 19:44 ` [PATCH AUTOSEL 4.19 51/68] scsi: qla4xxx: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 52/68] usb: usb251xb: fix to avoid " Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 53/68] leds: trigger: netdev: fix refcnt leak on interface rename Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 54/68] x86/realmode: Don't leak the trampoline kernel address Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 55/68] usb: u132-hcd: fix resource leak Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 56/68] tty: fix NULL pointer issue when tty_port ops is not set Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 57/68] ceph: fix use-after-free on symlink traversal Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 58/68] scsi: zfcp: reduce flood of fcrscn1 trace records on multi-element RSCN Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 59/68] x86/mm: Don't exceed the valid physical address space Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 60/68] libata: fix using DMA buffers on stack Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 61/68] gpio: of: Fix of_gpiochip_add() error path Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 62/68] nvme-multipath: relax ANA state check Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 63/68] perf machine: Update kernel map address and re-order properly Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 64/68] kconfig/[mn]conf: handle backspace (^H) key Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 65/68] iommu/amd: Reserve exclusion range in iova-domain Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 66/68] ptrace: take into account saved_sigmask in PTRACE{GET,SET}SIGMASK Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 67/68] leds: pca9532: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:45 ` [PATCH AUTOSEL 4.19 68/68] leds: trigger: netdev: use memcpy in device_name_store Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190422194516.11634-48-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).