Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp646769imu; Fri, 11 Jan 2019 06:45:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RIa2OxPR4a1jA1Buhkg61zHJZIRObX63X8pXVsWXgrAgC2/QzZvxZEvkG0yiM3RZnXeDd X-Received: by 2002:a17:902:4124:: with SMTP id e33mr14900577pld.236.1547217910919; Fri, 11 Jan 2019 06:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547217910; cv=none; d=google.com; s=arc-20160816; b=eknkLofIs+VoKpgIVmVZYgpAju5mlq2m47uSzvi16dmy4eY9suklIp29eqz7DmUD6n 3lhlfJcm2ByxwCa7PU1z9UjYEsOxJAikBz5JYFfC8KkSPa009sXxXkyROApuLf7/tm4P f3V0m4wFETG8QHtfVJsPmhQOrt+6vS+cSVMtZkC23eZJ4xhoC+3rgWAtd9JH7/Y+6r8d 9N3ChWUWqOxB0fpgVyZUhXBa41ZHwbKyq5R3Hd1GyuuzugILFB+Wlydeuvn9YvH2B/Uq wfhQD0mHsvdlrHZ3wpsf6fS2V971a/Q4iSd9dGs8ZBpw5fhkDVyc7tWi+h6IcyECBoal UO/g== 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=uOA4CJBVGvd4SxhYCadoloWQtSlZL8wBZuwEY3qBKQ8=; b=RZVmw/oD7DB1ZfwMbPf27OCXNcbp48zmMhxrbZJkYCubfMTu2GTKhty4cpFw+yjYpX Pyv1cNzmvtzTlxYo7eg7rtFxXxlKi7qQ55RVCfvsvyBrIMcuRkWUwE96Z5qO5OsQlYko xP7fQ3aIY+evnqNFBW7x24l/28diY57C+sO24+YgBK5aIc+7ovHOr76zreqG0kleushf xsD09WTuJ15iQB2suIY9naj2f/eMrKI/RN07fr0qeNvfifSlg4RjdFyu/zA8RE4/9Gj8 +bK/LrkKr7f1pmGOZqYkBu3haHkMIeX7N7GuODyeXziBn1veFCH3Y2fYZx5/tBbYHXKc G72w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RBQnaCvS; 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 z4si17700200pgl.16.2019.01.11.06.44.55; Fri, 11 Jan 2019 06:45:10 -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=RBQnaCvS; 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 S2404319AbfAKOnH (ORCPT + 99 others); Fri, 11 Jan 2019 09:43:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:35922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404301AbfAKOnE (ORCPT ); Fri, 11 Jan 2019 09:43:04 -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 4E02B21848; Fri, 11 Jan 2019 14:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217783; bh=1D8TkShLYW6ENovu7APZc2oy9XjBfolH59cw/olME/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBQnaCvSbU6pwiAG8Rk2C0/yFAi2fJvAiNFfFmbuNN9qy/mvlv1bY9Zv3/NQqwmvO VviuhzRe78d/LhQUwptWpWZelvVzRo+LYHhYJnC8IqNkjUQYkLXUW4rdymighsuTZn fbSpdHvDe3l9GAT/+ekYtEC1xJhcpSvOTXgYc1HQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Averin , David Teigland , stable@kernel.org Subject: [PATCH 4.20 32/65] dlm: memory leaks on error path in dlm_user_request() Date: Fri, 11 Jan 2019 15:15:18 +0100 Message-Id: <20190111131100.759223120@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vasily Averin commit d47b41aceeadc6b58abc9c7c6485bef7cfb75636 upstream. According to comment in dlm_user_request() ua should be freed in dlm_free_lkb() after successful attach to lkb. However ua is attached to lkb not in set_lock_args() but later, inside request_lock(). Fixes 597d0cae0f99 ("[DLM] dlm: user locks") Cc: stable@kernel.org # 2.6.19 Signed-off-by: Vasily Averin Signed-off-by: David Teigland Signed-off-by: Greg Kroah-Hartman --- fs/dlm/lock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -5795,20 +5795,20 @@ int dlm_user_request(struct dlm_ls *ls, goto out; } } - - /* After ua is attached to lkb it will be freed by dlm_free_lkb(). - When DLM_IFL_USER is set, the dlm knows that this is a userspace - lock and that lkb_astparam is the dlm_user_args structure. */ - error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, fake_astfn, ua, fake_bastfn, &args); - lkb->lkb_flags |= DLM_IFL_USER; - if (error) { + kfree(ua->lksb.sb_lvbptr); + ua->lksb.sb_lvbptr = NULL; + kfree(ua); __put_lkb(ls, lkb); goto out; } + /* After ua is attached to lkb it will be freed by dlm_free_lkb(). + When DLM_IFL_USER is set, the dlm knows that this is a userspace + lock and that lkb_astparam is the dlm_user_args structure. */ + lkb->lkb_flags |= DLM_IFL_USER; error = request_lock(ls, lkb, name, namelen, &args); switch (error) {