Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2448743yba; Mon, 15 Apr 2019 11:52:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuFc/WjpDb9OJGZdQO8afMck92Dy1nP2X0L8IdGqDC5o1EQvDQs2ysPDhXPPmsQYWv1i7d X-Received: by 2002:a17:902:9686:: with SMTP id n6mr34435346plp.282.1555354320653; Mon, 15 Apr 2019 11:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354320; cv=none; d=google.com; s=arc-20160816; b=fwdf64mE++yMo2XknJfVRM71r32qbTGA99qNnk6ZvmtpuZD5dw+cyooS6PDGhAKaUV ToMqAlrH9cZWpUSS8ZTA82hc+rnOAt08R3R6P0PwPwxTquuk2mBWcbbGwh8QIqH0RXKG enC6ong56OFMsJu6UpDysEkN2o1PLmuf8SIxpKRlE8rodn6RvUPV4TdDmxcAGtPPCHKT +LUpsKIZAHjkhZh3mOfTefh3hP+JmCerd6BmLjOnrWkqnzRhq4Frej4RifnRRCjG4Zt0 o3j3lz0iYu5/Nl48MEsv329qye9s5yaO7ZTMnI8Z1D0DDUxtE//piTjToyHkqxugJNEh ZxBA== 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=e8HjlH8Ee9V32FMvFS6YmWHtDtwxJfgjU48jLXcafzA=; b=vrZRabvVX4QCRmo5S43T093rtX59UsZL5tecBdDOTHFs4QoPxor7EqNyzfa44FmpoO SLhzKbE12s0VC4xWUBpJ/J9L1GCoNZN8ZdBizM3WUAag4Q5yfLk5kJqWgd0ChfXjehnh cofbvXbyrOMfXnv6JdvKEMQxBm1ddudTFH5LhglCb5dcWV6GUpDbA4+H3AtdgnBnDnmA wXZDizG1EcO9958MveZkmvue5DWHkes0ZCCpdxAnhJkEd04HZVRJcCZDBGkjPKIIVm4K M4UKcysYKcHMyjCXHlezzbS02GllMxMOJg5ZaJ+pNetxlcbckwdYl69Ui2At+AhEyrC1 kcFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=etk5T76q; 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 k62si14064162pgd.444.2019.04.15.11.51.44; Mon, 15 Apr 2019 11:52:00 -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=etk5T76q; 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 S1728150AbfDOStW (ORCPT + 99 others); Mon, 15 Apr 2019 14:49:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728930AbfDOSrb (ORCPT ); Mon, 15 Apr 2019 14:47:31 -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 4D734218D3; Mon, 15 Apr 2019 18:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354050; bh=AaFJdHDvY2sLZwdmupTFILn7/nJyfVg0HEQoEEYhxGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=etk5T76qY3drPaf7RCbLYvk+9qAiGQ6I5/ePQqYwGTLXMh4DZdnAQNlt6nHHo7kbc DWFJtCxhVx5NMBIimNEryE1HkyXdlt+Vx3y4yonj0HcQFj5WnFmk6cZBlKkv2EVT7i YFIQQIxj6sbzkoSFQVgz9C9P5Gdji+LZyuCZafiI= 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.9 68/76] block: do not leak memory in bio_copy_user_iov() Date: Mon, 15 Apr 2019 20:44:32 +0200 Message-Id: <20190415183727.982514505@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@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 @@ -1214,8 +1214,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;