Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5621751imu; Mon, 26 Nov 2018 03:07:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VK3z0uJ5aWWvuEgccKJ1n65zo0pZJqNLtQXjf0Qnv9xf4XEqlVSM9ywmYsncRnCVLhLc90 X-Received: by 2002:a63:4f20:: with SMTP id d32mr24344438pgb.47.1543230454119; Mon, 26 Nov 2018 03:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230454; cv=none; d=google.com; s=arc-20160816; b=iZraFzEwCLIA+jYfsFo9eNGs72VJokyXsPf7HZsklkRmd2z5T0GtFQjXuwvDO5h88E ZPBBBZriXMTQuYePmIx2e/0Fzna6gqdD6mBibMTY99/0wb21/YZTxOFl/XYxy7DaLKQT vGdZostnZFR0tnu7FWGMDt2erZod8/c0NQ7/MV6fhj8Q4z48LVwIFaSzLY+p6k4jTlpJ uE9yhdd7qp8Ip/5t3Um++3HhEukL8heSy8U4fTMFFyd2LUb5vf2gGMjPXsI7AaehEW65 5y0MJpyJE3UoQRwx+ul7jbUk31z7Mb1F9p19W8DMfNCrg3IJzOPrHL4QEroZ0cxoC+NH Eg9g== 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=KVLw80bIaz/WIEGlw9rQJDlhU3MLalwBKafKZD/LYQk=; b=nq8asV2XRe0Qs4R5y70v7doTfjctziaAW2/GOxoB0nkPKhWmOsGIi+QTHW6Gx0e3/U xZ2jzkfcl78psPrvLt1nYcfe/i7gDE+KMrcMJE0fQ95HiD11ZHZ3o+rBCZvi0Pdh64el gA6Ie5iDlg3psJxiNQkpffo0Qd8l/1jYT4eDFk/SMc7jwW61snMiRdqpAaKIuW0piUSU 25VkMs1pBenKRunQtGth4mFoOoJVcqompgNFHDm2Bab4wr3lM5UyF5VuTYJ9kwdGQmlE POtiDAPprzyl8Wtjpnxvp2ZMUEZ6e88aSUZ5ro9MaCBTZIAZijEGordVUqvssaV1wLya fmDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2W05bQP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e129si60818127pgc.333.2018.11.26.03.07.19; Mon, 26 Nov 2018 03:07:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2W05bQP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731665AbeKZWAc (ORCPT + 99 others); Mon, 26 Nov 2018 17:00:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:47490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729543AbeKZWAb (ORCPT ); Mon, 26 Nov 2018 17:00:31 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 5650B20989; Mon, 26 Nov 2018 11:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230405; bh=4hyPOgcu85TyUuePAvpL059wlKEAOzD3cZm4Suew0W4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2W05bQP7bOmd70mVzIPIHjxQMholvKgWnAqEBMwtcGZF5EdBUin30zfFlBB8339T rrRF5Hc+k/W1ITvsMTwcIT/cLr9vuVvY9GhDCyo2j/ZXiKMaXC6ZFf5PftzBy160RI /SQ/Ojy+gETHKb/K/InrW6LarPwIOyRfNARQlXu0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov Subject: [PATCH 4.19 117/118] libceph: fall back to sendmsg for slab pages Date: Mon, 26 Nov 2018 11:51:51 +0100 Message-Id: <20181126105106.496968704@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105059.832485122@linuxfoundation.org> References: <20181126105059.832485122@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilya Dryomov commit 7e241f647dc7087a0401418a187f3f5b527cc690 upstream. skb_can_coalesce() allows coalescing neighboring slab objects into a single frag: return page == skb_frag_page(frag) && off == frag->page_offset + skb_frag_size(frag); ceph_tcp_sendpage() can be handed slab pages. One example of this is XFS: it passes down sector sized slab objects for its metadata I/O. If the kernel client is co-located on the OSD node, the skb may go through loopback and pop on the receive side with the exact same set of frags. When tcp_recvmsg() attempts to copy out such a frag, hardened usercopy complains because the size exceeds the object's allocated size: usercopy: kernel memory exposure attempt detected from ffff9ba917f20a00 (kmalloc-512) (1024 bytes) Although skb_can_coalesce() could be taught to return false if the resulting frag would cross a slab object boundary, we already have a fallback for non-refcounted pages. Utilize it for slab pages too. Cc: stable@vger.kernel.org # 4.8+ Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- net/ceph/messenger.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -593,9 +593,15 @@ static int ceph_tcp_sendpage(struct sock struct bio_vec bvec; int ret; - /* sendpage cannot properly handle pages with page_count == 0, - * we need to fallback to sendmsg if that's the case */ - if (page_count(page) >= 1) + /* + * sendpage cannot properly handle pages with page_count == 0, + * we need to fall back to sendmsg if that's the case. + * + * Same goes for slab pages: skb_can_coalesce() allows + * coalescing neighboring slab objects into a single frag which + * triggers one of hardened usercopy checks. + */ + if (page_count(page) >= 1 && !PageSlab(page)) return __ceph_tcp_sendpage(sock, page, offset, size, more); bvec.bv_page = page;