Received: by 10.223.185.116 with SMTP id b49csp84306wrg; Thu, 15 Feb 2018 17:06:39 -0800 (PST) X-Google-Smtp-Source: AH8x224YXP18NvDcxp/IHB3ktFBnjf6ecavcmHkLCoLxgjAc2OHVXog0jAuNN2yZBucRdEQWpe3q X-Received: by 10.98.61.93 with SMTP id k90mr4378289pfa.133.1518743198919; Thu, 15 Feb 2018 17:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518743198; cv=none; d=google.com; s=arc-20160816; b=j0lma4sGpgJMW/CeSvAM5+jNP6ecJC1rX80FCM7zpXp5wbOPRk3rqyLe24ZH4M4InH PqdCeJlnYdPfbQES1uVXqMz6/yadofQcaiWqiHd8Sh3o2HxTihqAC2OHg/nwDi0oW7qQ oGgtHnlZ9LIGbJEMe9WEOSgrF7OUXpSipcQjFspCdqYTyr46kt94+u7PzF8Ge7/zttP2 ZIEP5vNcSbooG3k72dM8RMAGbF0l9CGTHcRu+D68/oi5n1Jz5q4TJbbYn/BLp8mcCrPk /i+Zg0lOeNyyS6HfkuOR6KykXtEHd3M/ZISkzX16IAty/8llfoIhWdagFJgvL0M2nSTt UK3w== 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=mvGFAPP/yRCn+y1x3vuGQlzzNMKm8xEgGRUj8dGTDAI=; b=evuv1Ars6lRJw8gEulKq4n5DmVUBq9vHWGDX7Xha1fJAmn2HRaGgL27ACfotnG2bou Q7t+5cOot02fpqCbe7N7XUzRptY+A5ISEUwoC6/hAof6DzyFffM7dq/N4qW34FapzhP5 hIMYxJHc3JS6FmO48htSvSw8X4F0ADkHRKcpWR/IPxwAzfezotQV8n8fUttIwcI6PQex NgrCyXGgvlNITHAMc4es4ctmYkdxl9OHm7idinhy+W7J/he5oWD6YAtHqzDJjVvQjtG7 ABOCk2LSQZ8zwKP7bwKXoFM7pgyN6yREsqkLCUp+F97hxmXP3Aumtiu8TLuHHyIvStYh 9p9Q== 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 e4si3357949pgr.627.2018.02.15.17.06.24; Thu, 15 Feb 2018 17:06:38 -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 S1424274AbeBOPmy (ORCPT + 99 others); Thu, 15 Feb 2018 10:42:54 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33450 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424246AbeBOPmv (ORCPT ); Thu, 15 Feb 2018 10:42:51 -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 0F2D1F97; Thu, 15 Feb 2018 15:42:50 +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.15 095/202] ubifs: free the encrypted symlink target Date: Thu, 15 Feb 2018 16:16:35 +0100 Message-Id: <20180215151718.347947986@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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; }