From patchwork Fri Jan 5 19:30:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 856153 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aBRgjPsg"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oCQ5mjab"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zCvvn6tzQz9t7q for ; Sat, 6 Jan 2018 06:31:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=IELqmgxpFoR0SQh+yO50+YskGs8O8s+VdLWCO6wy/v4=; b=aBR gjPsgnVvru4pMJ6v2DyWbRZzwH0fCw5R2Pp6Ti4u1aHLfsgOe5ipoQ7XTLhyuSlQfjyQxiU9NlVFP EUyviO0sbO2ubPu7HBYTqVo84SIDk7EU+E4iRTpyawsEVxsMounZEDcNtzJWhtk0TiQ7L2DlWlErM 56Yk4B2lLxkeRmPd6g2Mwb0nEjmzfXhWFgYpfUl+ysHsqHZuQubLxzSn/lAUa2Kkcw/xSlGZJ4rT3 4/0pJtomiFi3rAos1kpu1bGNdTvBxs7fqySG23hbUgkWzrRsawTotjmgHv3Yj5G7YUCSjrDwqowUC 5RiNT+nwovJYXkKNCEEwRw9EP6/lZMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eXXh6-0004LO-2b; Fri, 05 Jan 2018 19:30:20 +0000 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXXh3-0003bK-2z for linux-mtd@lists.infradead.org; Fri, 05 Jan 2018 19:30:18 +0000 Received: by mail-it0-x244.google.com with SMTP id 68so2804237ite.4 for ; Fri, 05 Jan 2018 11:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LXniF7qK3cnOtUtjuJONqJAwGnlHWbwp5o5nsvVCADM=; b=oCQ5mjab6zNQzLmALkRMxcS9EGdMJvxfXiKayLqRnT/v0Tape629PvZOAiZCT/Mfpt kGvZIky0etUs5cEModHyPkczSKIig1VVJ8uTuR8dooIogFa6T7TxqjIV18J0IIr0tDsm vKkxdUJFZhv2QSDYsxT/ISilce2FaM2STcsNCQXv5zbUyBjvwszPXxq+xCrFiG5WMjgR MqCJKgj8dE9Z632JkPbD8vn1cCKsFthjhOcI6+V/eagtysOrsw6shzoMxoZkpri/iRlK UgOqYzG0Nhhq4vjPji2wnxzhiDAyn5sxhFGHAkcRBDtaeHVHeo4soT1oB8+1zOywt6jz H11g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LXniF7qK3cnOtUtjuJONqJAwGnlHWbwp5o5nsvVCADM=; b=o2kfhkUsg13c3QFpv1RxB2JRs80534jcsdZuaCeN06Gu0iHPuQDEAOQgv5OvThMH3s s5iOQYKt992D2DyM7Rk2El8y4C2r35NwJZHJ2NeT7k8WlETNdvAC77ziu8iBcb3npWNI H/odAbjlopStQuq9BdtoNnIjK47u7ImsKL39t4UfBNowEZyxwjIy5lbdNtj1Ali0yQeT 9vjMkiPSKNzq+VaOqvS7DWpiwti1ZXkR+qHq1S0+aTH1nuGnuyMP/xRoJcgPC4qAWsx0 5WKBTZU3lp2SufyEWRC/vXzOtfky6/ggt7TlBFBYfn6tE1PByTFGQ+WOZGSbT585v6If XSxw== X-Gm-Message-State: AKGB3mLjhpWV2iSkF0ievxEEnXaqDfd3NsiOPmVN8yPez9YGK85dkspv QcFloECimXpP4O8MqqKyiyLUDD0D X-Google-Smtp-Source: ACJfBovIwzxuOm7OJYrTxlZguRjNxVOv24BecKTRoZ56Xh5JBFNOElyTDbgUMpfoDHQwYAsdh0AYqA== X-Received: by 10.36.250.202 with SMTP id v193mr4379613ith.114.1515180606022; Fri, 05 Jan 2018 11:30:06 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id y64sm3066238ioy.25.2018.01.05.11.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 11:30:05 -0800 (PST) From: Eric Biggers To: linux-mtd@lists.infradead.org, Richard Weinberger Subject: [PATCH v2] ubifs: free the encrypted symlink target Date: Fri, 5 Jan 2018 11:30:03 -0800 Message-Id: <20180105193003.118283-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.16.0.rc0.223.g4a4ac83678-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180105_113017_173730_2FBEA177 X-CRM114-Status: GOOD ( 10.41 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4001:c0b:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ebiggers3[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (ebiggers3[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fscrypt@vger.kernel.org, Eric Biggers , Adrian Hunter , Artem Bityutskiy MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Eric Biggers 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") Cc: # v4.10+ Signed-off-by: Eric Biggers --- No changes since v1, just resent as standalone patch. fs/ubifs/dir.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 417fe0b29f23..ef820f803176 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1216,10 +1216,8 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, 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 *dir, struct dentry *dentry, 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 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, fscrypt_free_filename(&nm); out_budg: ubifs_release_budget(c, &req); + kfree(sd); return err; }