Received: by 10.223.185.116 with SMTP id b49csp2632010wrg; Thu, 15 Feb 2018 15:03:30 -0800 (PST) X-Google-Smtp-Source: AH8x225a2cllAzBxhtUabXKkAKJ+38ov5ETIFzL338D8Tjm6AVhsb0S9qwOsX/brC1rI7ri9uX5V X-Received: by 2002:a17:902:6b48:: with SMTP id g8-v6mr3942101plt.151.1518735810605; Thu, 15 Feb 2018 15:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518735810; cv=none; d=google.com; s=arc-20160816; b=gHwAmS/t6UY1gMKO8B8V9Go5pR9gk6dqE6ZhWq6Hucof+Fd0PThHoh4J0jg84yd3jo CJJ4YYqqp0MaAVNT+m014/LS6JTKxk8+Ac1APHkl1ooB09qbDnHUpjQTx8yos/JDazrI L4b6WbreGSBN1NuIhozWbrNVnc42tk/RCguzpPf2B5W2+OOybK5cwtWTEWeyXnnh5Edz TlsYqRs61aiWRFAcaQ8H96PMArnMP/k8Hlu44f3f78krkNUULx+kQAmMoAvPooihi62x uqy/fZVS3u5r9jRA4hdZi2EPsV4qHIFU7MBlMJpAq1vNPixPQgN4zMF9gwa0sYkk8jpG Kzpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LpZReAYB2gy+n8L+lbA/BnCLqnexoBC10r89rdtc0QA=; b=mLv/6k8mG/YHkbmS2tIyR+n9t952Xr51b3V/3siz80yVaC2YwOGLDCjcmddzRUc9ul KmYXeCkkDuvj9mUL8DXIubopkysNSBZ74NsWoHqXXjaNDJaSSJk2LCYvTpu/4m+JaOoM AZQ+98AOa3QZYIiS6TnQs1xP4y8h3ZvjHbC2B/G730KsvMP9cHxPrmUzvUKaBm9GJl2m l0KRcl2Q4Y5I7IVjTheYGa8lhQpMPlHR7EkTELGXZ9D4OiciT9YEGihDH0rBrO135VtC 9nAJ2pmZWCWOp06ey1f0+6Ur7MByrow9jBUVmVQ4iNoGnDfusuRfAfnHY5CaX847+nBU zXMg== ARC-Authentication-Results: i=1; mx.google.com; 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 t74si222137pgc.649.2018.02.15.15.03.15; Thu, 15 Feb 2018 15:03:30 -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; 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 S1165037AbeBOPeH (ORCPT + 99 others); Thu, 15 Feb 2018 10:34:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57058 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165004AbeBOPeE (ORCPT ); Thu, 15 Feb 2018 10:34:04 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7F3C7110C; Thu, 15 Feb 2018 15:34:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Theodore Tso Subject: [PATCH 4.14 102/195] ubifs: free the encrypted symlink target Date: Thu, 15 Feb 2018 16:16:33 +0100 Message-Id: <20180215151710.794958655@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 6b46d444146eb8d0b99562795cea8086639d7282 upstream. ubifs_symlink() forgot to free the kmalloc()'ed buffer holding the encrypted symlink target, creating a memory leak. Fix it. (UBIFS could actually encrypt directly into ui->data, removing the temporary buffer, but that is left for the patch that switches to use the symlink helper functions.) Fixes: ca7f85be8d6c ("ubifs: Add support for encrypted symlinks") Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ubifs/dir.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1216,10 +1216,8 @@ static int ubifs_symlink(struct inode *d ostr.len = disk_link.len; err = fscrypt_fname_usr_to_disk(inode, &istr, &ostr); - if (err) { - kfree(sd); + if (err) goto out_inode; - } sd->len = cpu_to_le16(ostr.len); disk_link.name = (char *)sd; @@ -1251,11 +1249,10 @@ static int ubifs_symlink(struct inode *d goto out_cancel; mutex_unlock(&dir_ui->ui_mutex); - ubifs_release_budget(c, &req); insert_inode_hash(inode); d_instantiate(dentry, inode); - fscrypt_free_filename(&nm); - return 0; + err = 0; + goto out_fname; out_cancel: dir->i_size -= sz_change; @@ -1268,6 +1265,7 @@ out_fname: fscrypt_free_filename(&nm); out_budg: ubifs_release_budget(c, &req); + kfree(sd); return err; }