[lxc-devel] [lxcfs/master] bindings: fix init pid hashing

brauner on Github lxc-bot at linuxcontainers.org
Thu May 28 09:06:14 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 655 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200528/da4822b6/attachment.bin>
-------------- next part --------------
From 97017213a17f96631de1542ea087af15a37c3838 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 28 May 2020 11:03:05 +0200
Subject: [PATCH] bindings: fix init pid hashing

We were stupidly always hashing entry->ino where entry was just freshly
allocated zeroed-memory so we effectively added stuff to the cache
forever but this meant:
- we never found a match when we hashed the actual inode
- we kept growing the cache
- we leaked memory

Closes: #407.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/bindings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bindings.c b/src/bindings.c
index 89ebde5..79a6028 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -278,7 +278,7 @@ static void save_initpid(ino_t pidns_inode, pid_t pid)
 	if (!entry)
 		return;
 
-	ino_hash = HASH(entry->ino);
+	ino_hash = HASH(pidns_inode);
 	*entry = (struct pidns_init_store){
 		.ino		= pidns_inode,
 		.initpid	= pid,


More information about the lxc-devel mailing list