Skip to content

Commit baa756e

Browse files
authored
Revert kernel patch causing failures on CIFS share disk usage (#3051)
* Revert kernel patch causing failures on CIFS share disk usage The issue was reported upstream, waiting for a fix there. Reverting the patch for a quick resolution of the bug that breaks some things in HA and add-ons badly. Refs #3041 * Move the patch to 6.1.71 subdirectory That way Raspberry Pi's kernel won't be patched (unless it's the same version which it's currently not).
1 parent 1a48d6f commit baa756e

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
From 0ef7210b8779b04a380775764ad1a6b8dbfc40ee Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <[email protected]>
3+
Date: Mon, 8 Jan 2024 12:27:41 +0100
4+
Subject: [PATCH] Revert "smb: client: fix OOB in SMB2_query_info_init()"
5+
6+
This reverts commit bef4315f19ba6f434054f58b958c0cf058c7a43f.
7+
8+
This commit introduced regression causing stat operations on CIFS shares
9+
to fail [1]. Issue was reported in mailing lists [2], reverting the patch
10+
before it is resolved in linux-stable 6.1.y.
11+
12+
[1] https://github.com/home-assistant/operating-system/issues/3041
13+
[2] https://lore.kernel.org/stable/[email protected]/
14+
---
15+
fs/smb/client/smb2pdu.c | 29 +++++++----------------------
16+
1 file changed, 7 insertions(+), 22 deletions(-)
17+
18+
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
19+
index 05ff8a457a3d..847d69d327c2 100644
20+
--- a/fs/smb/client/smb2pdu.c
21+
+++ b/fs/smb/client/smb2pdu.c
22+
@@ -372,15 +372,10 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
23+
void **request_buf, unsigned int *total_len)
24+
{
25+
/* BB eventually switch this to SMB2 specific small buf size */
26+
- switch (smb2_command) {
27+
- case SMB2_SET_INFO:
28+
- case SMB2_QUERY_INFO:
29+
+ if (smb2_command == SMB2_SET_INFO)
30+
*request_buf = cifs_buf_get();
31+
- break;
32+
- default:
33+
+ else
34+
*request_buf = cifs_small_buf_get();
35+
- break;
36+
- }
37+
if (*request_buf == NULL) {
38+
/* BB should we add a retry in here if not a writepage? */
39+
return -ENOMEM;
40+
@@ -3528,13 +3523,8 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
41+
struct smb2_query_info_req *req;
42+
struct kvec *iov = rqst->rq_iov;
43+
unsigned int total_len;
44+
- size_t len;
45+
int rc;
46+
47+
- if (unlikely(check_add_overflow(input_len, sizeof(*req), &len) ||
48+
- len > CIFSMaxBufSize))
49+
- return -EINVAL;
50+
-
51+
rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, server,
52+
(void **) &req, &total_len);
53+
if (rc)
54+
@@ -3556,7 +3546,7 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
55+
56+
iov[0].iov_base = (char *)req;
57+
/* 1 for Buffer */
58+
- iov[0].iov_len = len;
59+
+ iov[0].iov_len = total_len - 1 + input_len;
60+
return 0;
61+
}
62+
63+
@@ -3564,7 +3554,7 @@ void
64+
SMB2_query_info_free(struct smb_rqst *rqst)
65+
{
66+
if (rqst && rqst->rq_iov)
67+
- cifs_buf_release(rqst->rq_iov[0].iov_base); /* request */
68+
+ cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
69+
}
70+
71+
static int
72+
@@ -5449,11 +5439,6 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
73+
return 0;
74+
}
75+
76+
-static inline void free_qfs_info_req(struct kvec *iov)
77+
-{
78+
- cifs_buf_release(iov->iov_base);
79+
-}
80+
-
81+
int
82+
SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
83+
u64 persistent_fid, u64 volatile_fid, struct kstatfs *fsdata)
84+
@@ -5485,7 +5470,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
85+
86+
rc = cifs_send_recv(xid, ses, server,
87+
&rqst, &resp_buftype, flags, &rsp_iov);
88+
- free_qfs_info_req(&iov);
89+
+ cifs_small_buf_release(iov.iov_base);
90+
if (rc) {
91+
cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
92+
goto posix_qfsinf_exit;
93+
@@ -5536,7 +5521,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
94+
95+
rc = cifs_send_recv(xid, ses, server,
96+
&rqst, &resp_buftype, flags, &rsp_iov);
97+
- free_qfs_info_req(&iov);
98+
+ cifs_small_buf_release(iov.iov_base);
99+
if (rc) {
100+
cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
101+
goto qfsinf_exit;
102+
@@ -5603,7 +5588,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
103+
104+
rc = cifs_send_recv(xid, ses, server,
105+
&rqst, &resp_buftype, flags, &rsp_iov);
106+
- free_qfs_info_req(&iov);
107+
+ cifs_small_buf_release(iov.iov_base);
108+
if (rc) {
109+
cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
110+
goto qfsattr_exit;
111+
--
112+
2.34.1
113+

0 commit comments

Comments
 (0)