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>] [day] [month] [year] [list]
Message-ID: <20250705155714.805067-1-abinashsinghlalotra@gmail.com>
Date: Sat,  5 Jul 2025 21:27:14 +0530
From: Abinash Singh <abinashlalotra@...il.com>
To: sfrench@...ba.org
Cc: pc@...guebit.org,
	ronniesahlberg@...il.com,
	sprasad@...rosoft.com,
	tom@...pey.com,
	bharathsm@...rosoft.com,
	linux-cifs@...r.kernel.org,
	samba-technical@...ts.samba.org,
	linux-kernel@...r.kernel.org,
	Abinash Singh <abinashsinghlalotra@...il.com>
Subject: [PATCH RFC] fs/smb : fix build warning in cifs_open()

The function `cifs_open()` triggers
a large stack frame warning:
ld.lld: warning:
	fs/smb/client/file.c:949:0: stack frame size (1032) exceeds limit (1024) in function 'cifs_open'

Fix excess stack usgae by dynamically allocating `cifs_pending_open` struct.

Signed-off-by: Abinash Singh <abinashsinghlalotra@...il.com>
---
It only reduces only 40 bytes.But we can reduce it more
by allocating other structs on heap.
This is fine if this function is not performance critical,
Is it ?

Thank You
---
 fs/smb/client/file.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index e9212da32f01..818a3c1e6c72 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -959,9 +959,13 @@ int cifs_open(struct inode *inode, struct file *file)
 	const char *full_path;
 	bool posix_open_ok = false;
 	struct cifs_fid fid = {};
-	struct cifs_pending_open open;
+	struct cifs_pending_open *open __free(kfree) = NULL;
 	struct cifs_open_info_data data = {};
 
+	open = kmalloc(sizeof(*open),GFP_KERNEL);
+	if (!open)
+		return -ENOMEM;
+
 	xid = get_xid();
 
 	cifs_sb = CIFS_SB(inode->i_sb);
@@ -1057,7 +1061,7 @@ int cifs_open(struct inode *inode, struct file *file)
 	if (server->ops->get_lease_key)
 		server->ops->get_lease_key(inode, &fid);
 
-	cifs_add_pending_open(&fid, tlink, &open);
+	cifs_add_pending_open(&fid, tlink, open);
 
 	if (!posix_open_ok) {
 		if (server->ops->get_lease_key)
@@ -1066,7 +1070,7 @@ int cifs_open(struct inode *inode, struct file *file)
 		rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, file->f_flags, &oplock, &fid,
 				  xid, &data);
 		if (rc) {
-			cifs_del_pending_open(&open);
+			cifs_del_pending_open(open);
 			goto out;
 		}
 	}
@@ -1075,7 +1079,7 @@ int cifs_open(struct inode *inode, struct file *file)
 	if (cfile == NULL) {
 		if (server->ops->close)
 			server->ops->close(xid, tcon, &fid);
-		cifs_del_pending_open(&open);
+		cifs_del_pending_open(open);
 		rc = -ENOMEM;
 		goto out;
 	}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ