lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1413505378-7323-1-git-send-email-dbanerje@akamai.com>
Date:	Thu, 16 Oct 2014 20:22:58 -0400
From:	Debabrata Banerjee <dbanerje@...mai.com>
To:	Alexander Viro <viro@...iv.linux.org.uk>,
	linux-kernel@...r.kernel.org
Cc:	Debabrata Banerjee <dbanerje@...mai.com>,
	linux-fsdevel@...r.kernel.org
Subject: [PATCH v2] procfs: Fix error handling of proc_register()

	I don't see why this should print warnings instead of properly
	unrolling allocations and returning an appropriate error. It's actually
	leaking resources. WARN kept on EINVAL case but the leak is fixed there
	as well.

to: Alexander Viro <viro@...iv.linux.org.uk>
to: linux-kernel@...r.kernel.org
cc: linux-fsdevel@...r.kernel.org
Signed-off-by: Debabrata Banerjee <dbanerje@...mai.com>
---
 fs/proc/generic.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 317b726..89b20cc 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -304,6 +304,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
 		dp->proc_iops = &proc_file_inode_operations;
 	} else {
 		WARN_ON(1);
+		proc_free_inum(dp->low_ino);
 		return -EINVAL;
 	}
 
@@ -311,9 +312,13 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
 
 	for (tmp = dir->subdir; tmp; tmp = tmp->next)
 		if (strcmp(tmp->name, dp->name) == 0) {
-			WARN(1, "proc_dir_entry '%s/%s' already registered\n",
-				dir->name, dp->name);
-			break;
+			spin_unlock(&proc_subdir_lock);
+
+			if (S_ISDIR(dp->mode))
+				dir->nlink--;
+
+			proc_free_inum(dp->low_ino);
+			return -EEXIST;
 		}
 
 	dp->next = dir->subdir;
-- 
2.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ