From: Paulo Alcantara <pc@manguebit.com>
To: smfrench@gmail.com
Cc: linux-cifs@vger.kernel.org, Paulo Alcantara <pc@manguebit.com>
Subject: [PATCH 17/17] smb: client: reduce stack usage in smb2_query_reparse_point()
Date: Thu, 17 Aug 2023 12:34:15 -0300 [thread overview]
Message-ID: <20230817153416.28083-18-pc@manguebit.com> (raw)
In-Reply-To: <20230817153416.28083-1-pc@manguebit.com>
Clang warns about exceeded stack frame size
fs/smb/client/smb2ops.c:2973:12: warning: stack frame size (1336)
exceeds limit (1024) in 'smb2_query_reparse_point'
[-Wframe-larger-than]
Fix this by allocating a structure that will hold most of the large
variables.
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
---
fs/smb/client/smb2ops.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 015d13d9054d..38bc92371560 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -2965,6 +2965,7 @@ static int smb2_query_reparse_point(const unsigned int xid,
u32 *tag, struct kvec *rsp,
int *rsp_buftype)
{
+ struct smb2_compound_vars *vars;
int rc;
__le16 *utf16_path = NULL;
__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
@@ -2972,12 +2973,9 @@ static int smb2_query_reparse_point(const unsigned int xid,
struct cifs_fid fid;
struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses);
int flags = CIFS_CP_CREATE_CLOSE_OP;
- struct smb_rqst rqst[3];
+ struct smb_rqst *rqst;
int resp_buftype[3];
- struct kvec rsp_iov[3];
- struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
- struct kvec io_iov[SMB2_IOCTL_IOV_SIZE];
- struct kvec close_iov[1];
+ struct kvec *rsp_iov;
struct smb2_ioctl_rsp *ioctl_rsp;
struct reparse_data_buffer *reparse_buf;
u32 plen;
@@ -2987,20 +2985,24 @@ static int smb2_query_reparse_point(const unsigned int xid,
if (smb3_encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ;
- memset(rqst, 0, sizeof(rqst));
- resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
- memset(rsp_iov, 0, sizeof(rsp_iov));
-
utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
if (!utf16_path)
return -ENOMEM;
+ resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
+ vars = kzalloc(sizeof(*vars), GFP_KERNEL);
+ if (!vars) {
+ rc = -ENOMEM;
+ goto out_free_path;
+ }
+ rqst = vars->rqst;
+ rsp_iov = vars->rsp_iov;
+
/*
* setup smb2open - TODO add optimization to call cifs_get_readable_path
* to see if there is a handle already open that we can use
*/
- memset(&open_iov, 0, sizeof(open_iov));
- rqst[0].rq_iov = open_iov;
+ rqst[0].rq_iov = vars->open_iov;
rqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE;
oparms = (struct cifs_open_parms) {
@@ -3020,8 +3022,7 @@ static int smb2_query_reparse_point(const unsigned int xid,
/* IOCTL */
- memset(&io_iov, 0, sizeof(io_iov));
- rqst[1].rq_iov = io_iov;
+ rqst[1].rq_iov = vars->io_iov;
rqst[1].rq_nvec = SMB2_IOCTL_IOV_SIZE;
rc = SMB2_ioctl_init(tcon, server,
@@ -3036,10 +3037,8 @@ static int smb2_query_reparse_point(const unsigned int xid,
smb2_set_next_command(tcon, &rqst[1]);
smb2_set_related(&rqst[1]);
-
/* Close */
- memset(&close_iov, 0, sizeof(close_iov));
- rqst[2].rq_iov = close_iov;
+ rqst[2].rq_iov = &vars->close_iov;
rqst[2].rq_nvec = 1;
rc = SMB2_close_init(tcon, server,
@@ -3080,13 +3079,15 @@ static int smb2_query_reparse_point(const unsigned int xid,
}
query_rp_exit:
- kfree(utf16_path);
SMB2_open_free(&rqst[0]);
SMB2_ioctl_free(&rqst[1]);
SMB2_close_free(&rqst[2]);
free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
+ kfree(vars);
+out_free_path:
+ kfree(utf16_path);
return rc;
}
--
2.41.0
next prev parent reply other threads:[~2023-08-17 15:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 15:33 [PATCH 00/17] cifs.ko fixes Paulo Alcantara
2023-08-17 15:33 ` [PATCH 01/17] smb: client: introduce DFS_CACHE_TGT_LIST() Paulo Alcantara
2023-08-17 15:34 ` [PATCH 02/17] smb: client: ensure to try all targets when finding nested links Paulo Alcantara
2023-08-17 15:34 ` [PATCH 03/17] smb: client: move some params to cifs_open_info_data Paulo Alcantara
2023-08-17 15:34 ` [PATCH 04/17] smb: client: make smb2_compound_op() return resp buffer on success Paulo Alcantara
2023-08-17 15:34 ` [PATCH 05/17] smb: client: rename cifs_dfs_ref.c to namespace.c Paulo Alcantara
2023-08-17 15:34 ` [PATCH 06/17] smb: client: get rid of dfs naming in automount code Paulo Alcantara
2023-08-17 15:34 ` [PATCH 07/17] smb: client: get rid of dfs code dep in namespace.c Paulo Alcantara
2023-08-17 15:34 ` [PATCH 08/17] smb: client: parse reparse point flag in create response Paulo Alcantara
2023-08-17 15:34 ` [PATCH 09/17] smb: client: do not query reparse points twice on symlinks Paulo Alcantara
2023-08-17 15:52 ` Fwd: " Steve French
2023-08-17 16:19 ` Paulo Alcantara
2023-08-17 15:34 ` [PATCH 10/17] smb: client: query reparse points in older dialects Paulo Alcantara
2023-08-17 15:34 ` [PATCH 11/17] smb: cilent: set reparse mount points as automounts Paulo Alcantara
2023-08-17 15:34 ` [PATCH 12/17] smb: client: reduce stack usage in cifs_try_adding_channels() Paulo Alcantara
2023-08-17 15:34 ` [PATCH 13/17] smb: client: reduce stack usage in cifs_demultiplex_thread() Paulo Alcantara
2023-08-17 15:34 ` [PATCH 14/17] smb: client: reduce stack usage in smb_send_rqst() Paulo Alcantara
2023-08-17 15:34 ` [PATCH 15/17] smb: client: reduce stack usage in smb2_set_ea() Paulo Alcantara
2023-08-17 15:34 ` [PATCH 16/17] smb: client: reduce stack usage in smb2_query_info_compound() Paulo Alcantara
2023-08-17 15:34 ` Paulo Alcantara [this message]
2023-08-19 3:37 ` [PATCH 00/17] cifs.ko fixes Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230817153416.28083-18-pc@manguebit.com \
--to=pc@manguebit.com \
--cc=linux-cifs@vger.kernel.org \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox