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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211112093051.9366-1-chi.minghao@zte.com.cn>
Date:   Fri, 12 Nov 2021 09:30:51 +0000
From:   cgel.zte@...il.com
To:     sfrench@...ba.org
Cc:     linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org,
        linux-kernel@...r.kernel.org, chiminghao <chi.minghao@....com.cn>,
        Zeal Robot <zealci@....com.cm>
Subject: [PATCH] fs:cifs: convert from atomic_t to refcount_t on tlink->tl_count

From: chiminghao <chi.minghao@....com.cn>

use refcount_t instead of atomic_t
which prevents reference counter overflows.

Reported-by: Zeal Robot <zealci@....com.cm>
Signed-off-by: chiminghao <chi.minghao@....com.cn>
---
 fs/cifs/cifsglob.h | 4 ++--
 fs/cifs/connect.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 41e97df4e0e5..a8edaada0fea 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -8,7 +8,7 @@
  */
 #ifndef _CIFS_GLOB_H
 #define _CIFS_GLOB_H
-
+#include <linux/refcount.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/inet.h>
@@ -1115,7 +1115,7 @@ struct tcon_link {
 #define TCON_LINK_PENDING	1
 #define TCON_LINK_IN_TREE	2
 	unsigned long		tl_time;
-	atomic_t		tl_count;
+	refcount_t		tl_count;
 	struct cifs_tcon	*tl_tcon;
 };
 
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 9637465d23db..4aad8c9acf2e 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2318,7 +2318,7 @@ cifs_put_tlink(struct tcon_link *tlink)
 	if (!tlink || IS_ERR(tlink))
 		return;
 
-	if (!atomic_dec_and_test(&tlink->tl_count) ||
+	if (!refcount_dec_and_test(&tlink->tl_count) ||
 	    test_bit(TCON_LINK_IN_TREE, &tlink->tl_flags)) {
 		tlink->tl_time = jiffies;
 		return;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ