Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3546633pxj; Mon, 24 May 2021 09:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6GhUXseAjlG9QstypZiwM2gQs6hIPc84AWg4fl9d4vExaRHpdvSDvWJXtJ5/NuTxkr8xt X-Received: by 2002:a17:906:490d:: with SMTP id b13mr23766322ejq.269.1621872366612; Mon, 24 May 2021 09:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872366; cv=none; d=google.com; s=arc-20160816; b=YQFL13xLwQYWVdfD63veai8rbRx/lbjfqsGnV29bPJuTxRqfp6Twn1LwT+/QNkwTJQ oS3kvCUBxRJI+fkZNzFBJurnm9OSkANHbdvS3iCbxDtojmGhDAIsrdXKuFjmJwy1Gg1u bK7ea0bXi63sYw8/a5BjEPRrxWfSoxhqnTz24Z9IedAZq+PotrcYhbaJSijM3TadKVXk 69wjsZQTRg9Y6+sTab6mIKvGRmLA8Ok8kBYPpjacG6jGMF8NEAvtyjr0Na746eCw+niJ N1XWshR94/H/VwadfcQXtaU4obkW4EvCM0AMqDpuzyMWa6BcJUamVoQ5/jej3ezTuBR0 0gZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mmPpllHWuJNRkQ4Fn8dQgoLxL16pEpWAX89cNWlrUDk=; b=wVf8j9KZLQBxdTxTEoXJKPVoqTLaiELu9uLbI01z7PGMrslxqB3Jl+k6jfU1p0HCy2 9UNVmjW6rkeqJlv3uDCwau6hu73RjHsfzRAiBSnWQ/TGQ8FDGNWw/WyduKHffS9f48xm DdihlHnJQCnNcugp1enyAJ+so8gamSy/KjVVhSzKOm3mnEZPkfT5hlvQxjvKL+65dp3v NRLi7IJhedK7qwyAigw8ByPCyAJKLQMA1562Sk8Rbvln0ZhvDOD7EuWwSE6ItgDNCLhn 73QyrQzu94TooW6oCcAyFPKsGDhucvRtvYJ38g8SWV+6yHbGPWxanIWb3Az0MCEhOU2l nF3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tmCivFIm; 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=pass (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 g3si13334817ejf.16.2021.05.24.09.05.42; Mon, 24 May 2021 09:06:06 -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=@linuxfoundation.org header.s=korg header.b=tmCivFIm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236573AbhEXQEa (ORCPT + 99 others); Mon, 24 May 2021 12:04:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:40476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232548AbhEXP5z (ORCPT ); Mon, 24 May 2021 11:57:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B51C46195E; Mon, 24 May 2021 15:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871029; bh=bChgj2DjxmvGeQFc/40vVgbfRS/th9c56r8IUMxtNjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmCivFImF8AKeJgjH0W4kJEPvWdBBwM01LIi417XuHvk8uLuOZsI+ne/s4f+Yde4d IgjAaxRmDvOzrkXJBdecE1o1vac/uQ9fUJzIHg0cFET96KJLcDv9WBSDPrk8f+xAfD wNCMKZy+4qoqVOI0wC5lgB7XFFbAZZsLNAmhtBAg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aurelien Aptel , Ronnie Sahlberg , Steve French Subject: [PATCH 5.12 039/127] cifs: fix memory leak in smb2_copychunk_range Date: Mon, 24 May 2021 17:25:56 +0200 Message-Id: <20210524152336.172737530@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ronnie Sahlberg commit d201d7631ca170b038e7f8921120d05eec70d7c5 upstream. When using smb2_copychunk_range() for large ranges we will run through several iterations of a loop calling SMB2_ioctl() but never actually free the returned buffer except for the final iteration. This leads to memory leaks everytime a large copychunk is requested. Fixes: 9bf0c9cd4314 ("CIFS: Fix SMB2/SMB3 Copy offload support (refcopy) for large files") Cc: Reviewed-by: Aurelien Aptel Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1822,6 +1822,8 @@ smb2_copychunk_range(const unsigned int cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk)); /* Request server copy to target from src identified by key */ + kfree(retbuf); + retbuf = NULL; rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE, true /* is_fsctl */, (char *)pcchunk,