Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2475654yba; Mon, 15 Apr 2019 12:25:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjBUtvr41XJYk9vTpiigkkA2mQVeN+a7E/yEHqKZCmQVppLN5/YWRdnGbAXmUMpUQwGtuo X-Received: by 2002:a62:12c8:: with SMTP id 69mr77935430pfs.184.1555356344817; Mon, 15 Apr 2019 12:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356344; cv=none; d=google.com; s=arc-20160816; b=f2MqFigJ9t/7tVViOnyIR0OCnz36t1QSEbmZN5y5JW/IufuTs5H12trLalhIElYik4 pNEKkEmog2iKqGhHbEGIHjKwo0U81pwvggtR0r5ZHd+Ip4Ngw7C9nOg3wq4Ty0TgKu3t tUEVqYIl3YPeecXfIudzmTZ0bDHRXN43AxgRU4xcMFWc2yXm0rmFaT6nImR+r8YC8mHV glGz2yFUOK98O7GiNaNOqKyfJFSUZyty2R+hP73kMe7nb7MqOWTIQYscFBkNONsneOD+ TbAFvraF9cedH8oHrhv+j89grB3WDJbmZxgFW64zuAnDd9G1BhOjJSxMaMsVrq9s9KM+ t6hQ== 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=DwpCFfYzAVD7ECNvLFvEbvMlHObrHfBZfnaXu0dfQBE=; b=vQOGLT9WYTOxSNEnIiHNbEuUOiaEPOTLBYOkx3RN8ZTi9CQ7l9djXu3KbAET/06R3E G/FqpGrvaoMgkcsvBgkTTyADihPP5DTfVCI7JKYU8tPIj2FfTjjaIofdoL3Exb61Y0ww N7vwvWh0tvIgZCbQeJxg8+/n2FIvxR3YJo2XWTm3zrhw6X/0fUPiRKQhxCbBx+B/OtcC PR/R49MatfLI3AVrOBgJQi/Vi5V0AmVJzkhknKbRhoUz7GMwGnmcZJacN7/qhlu5Wf04 mXntd19Ko6Nt4fE3bbIbbCBpiqLDdRNm4GMF1sR66lY/LiH4LbIQnu/De9sEcoNlJOYC t25w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y8d6RlI7; 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 c10si45292499plo.216.2019.04.15.12.25.28; Mon, 15 Apr 2019 12:25:44 -0700 (PDT) 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=y8d6RlI7; 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 S1729308AbfDOTHo (ORCPT + 99 others); Mon, 15 Apr 2019 15:07:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730252AbfDOTHl (ORCPT ); Mon, 15 Apr 2019 15:07:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 4A2442087C; Mon, 15 Apr 2019 19:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355260; bh=WVeBqYPgdfpR+mnim3L5Wgt9NBJzLhKP1/afZf0EBUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y8d6RlI72ZTDGU1bHCgqO8JbvRdh73yitBVKMeLNIhydszt5gPAH56rd9KpoeFtqr DnmRqQxElUhYGdK7AK3So85VTjZcOIcqqjjaY8g5VSY8d08BwwleuGiHxZztXI1Xd5 g5HRS9F4jj0R2r714Y9EQNy65kxC8cWbSUD27MFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linux-block@vger.kernel.org, Linus Torvalds , Chaitanya Kulkarni , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jens Axboe Subject: [PATCH 4.19 071/101] block: do not leak memory in bio_copy_user_iov() Date: Mon, 15 Apr 2019 20:59:09 +0200 Message-Id: <20190415183744.225068525@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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: Jérôme Glisse commit a3761c3c91209b58b6f33bf69dd8bb8ec0c9d925 upstream. When bio_add_pc_page() fails in bio_copy_user_iov() we should free the page we just allocated otherwise we are leaking it. Cc: linux-block@vger.kernel.org Cc: Linus Torvalds Cc: stable@vger.kernel.org Reviewed-by: Chaitanya Kulkarni Signed-off-by: Jérôme Glisse Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/block/bio.c +++ b/block/bio.c @@ -1240,8 +1240,11 @@ struct bio *bio_copy_user_iov(struct req } } - if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) + if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { + if (!map_data) + __free_page(page); break; + } len -= bytes; offset = 0;