diff options
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0059-iscsi-target-Drop-bogus-struct-file-usage-for-iSCSI-.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0059-iscsi-target-Drop-bogus-struct-file-usage-for-iSCSI-.patch | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0059-iscsi-target-Drop-bogus-struct-file-usage-for-iSCSI-.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0059-iscsi-target-Drop-bogus-struct-file-usage-for-iSCSI-.patch new file mode 100644 index 00000000..cfe9c565 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0059-iscsi-target-Drop-bogus-struct-file-usage-for-iSCSI-.patch | |||
@@ -0,0 +1,230 @@ | |||
1 | From ea954b6e038224e5946f09b1a359d19e672cde3a Mon Sep 17 00:00:00 2001 | ||
2 | From: Al Viro <viro@ZenIV.linux.org.uk> | ||
3 | Date: Sat, 21 Jul 2012 08:55:18 +0100 | ||
4 | Subject: [PATCH 59/73] iscsi-target: Drop bogus struct file usage for | ||
5 | iSCSI/SCTP | ||
6 | |||
7 | commit bf6932f44a7b3fa7e2246a8b18a44670e5eab6c2 upstream. | ||
8 | |||
9 | From Al Viro: | ||
10 | |||
11 | BTW, speaking of struct file treatment related to sockets - | ||
12 | there's this piece of code in iscsi: | ||
13 | /* | ||
14 | * The SCTP stack needs struct socket->file. | ||
15 | */ | ||
16 | if ((np->np_network_transport == ISCSI_SCTP_TCP) || | ||
17 | (np->np_network_transport == ISCSI_SCTP_UDP)) { | ||
18 | if (!new_sock->file) { | ||
19 | new_sock->file = kzalloc( | ||
20 | sizeof(struct file), GFP_KERNEL); | ||
21 | |||
22 | For one thing, as far as I can see it'not true - sctp does *not* depend on | ||
23 | socket->file being non-NULL; it does, in one place, check socket->file->f_flags | ||
24 | for O_NONBLOCK, but there it treats NULL socket->file as "flag not set". | ||
25 | Which is the case here anyway - the fake struct file created in | ||
26 | __iscsi_target_login_thread() (and in iscsi_target_setup_login_socket(), with | ||
27 | the same excuse) do *not* get that flag set. | ||
28 | |||
29 | Moreover, it's a bloody serious violation of a bunch of asserts in VFS; | ||
30 | all struct file instances should come from filp_cachep, via get_empty_filp() | ||
31 | (or alloc_file(), which is a wrapper for it). FWIW, I'm very tempted to | ||
32 | do this and be done with the entire mess: | ||
33 | |||
34 | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> | ||
35 | Cc: Andy Grover <agrover@redhat.com> | ||
36 | Cc: Hannes Reinecke <hare@suse.de> | ||
37 | Cc: Christoph Hellwig <hch@lst.de> | ||
38 | Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> | ||
39 | [bwh: Backported to 3.2: adjust context] | ||
40 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
41 | --- | ||
42 | drivers/target/iscsi/iscsi_target.c | 22 +--------- | ||
43 | drivers/target/iscsi/iscsi_target_core.h | 2 - | ||
44 | drivers/target/iscsi/iscsi_target_login.c | 60 +--------------------------- | ||
45 | 3 files changed, 6 insertions(+), 78 deletions(-) | ||
46 | |||
47 | diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c | ||
48 | index 0842cc7..2ff1255 100644 | ||
49 | --- a/drivers/target/iscsi/iscsi_target.c | ||
50 | +++ b/drivers/target/iscsi/iscsi_target.c | ||
51 | @@ -427,19 +427,8 @@ int iscsit_reset_np_thread( | ||
52 | |||
53 | int iscsit_del_np_comm(struct iscsi_np *np) | ||
54 | { | ||
55 | - if (!np->np_socket) | ||
56 | - return 0; | ||
57 | - | ||
58 | - /* | ||
59 | - * Some network transports allocate their own struct sock->file, | ||
60 | - * see if we need to free any additional allocated resources. | ||
61 | - */ | ||
62 | - if (np->np_flags & NPF_SCTP_STRUCT_FILE) { | ||
63 | - kfree(np->np_socket->file); | ||
64 | - np->np_socket->file = NULL; | ||
65 | - } | ||
66 | - | ||
67 | - sock_release(np->np_socket); | ||
68 | + if (np->np_socket) | ||
69 | + sock_release(np->np_socket); | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | @@ -4105,13 +4094,8 @@ int iscsit_close_connection( | ||
74 | kfree(conn->conn_ops); | ||
75 | conn->conn_ops = NULL; | ||
76 | |||
77 | - if (conn->sock) { | ||
78 | - if (conn->conn_flags & CONNFLAG_SCTP_STRUCT_FILE) { | ||
79 | - kfree(conn->sock->file); | ||
80 | - conn->sock->file = NULL; | ||
81 | - } | ||
82 | + if (conn->sock) | ||
83 | sock_release(conn->sock); | ||
84 | - } | ||
85 | conn->thread_set = NULL; | ||
86 | |||
87 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); | ||
88 | diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h | ||
89 | index 7da2d6a..0f68197 100644 | ||
90 | --- a/drivers/target/iscsi/iscsi_target_core.h | ||
91 | +++ b/drivers/target/iscsi/iscsi_target_core.h | ||
92 | @@ -224,7 +224,6 @@ enum iscsi_timer_flags_table { | ||
93 | /* Used for struct iscsi_np->np_flags */ | ||
94 | enum np_flags_table { | ||
95 | NPF_IP_NETWORK = 0x00, | ||
96 | - NPF_SCTP_STRUCT_FILE = 0x01 /* Bugfix */ | ||
97 | }; | ||
98 | |||
99 | /* Used for struct iscsi_np->np_thread_state */ | ||
100 | @@ -511,7 +510,6 @@ struct iscsi_conn { | ||
101 | u16 local_port; | ||
102 | int net_size; | ||
103 | u32 auth_id; | ||
104 | -#define CONNFLAG_SCTP_STRUCT_FILE 0x01 | ||
105 | u32 conn_flags; | ||
106 | /* Used for iscsi_tx_login_rsp() */ | ||
107 | u32 login_itt; | ||
108 | diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c | ||
109 | index bd2adec..2ec5339 100644 | ||
110 | --- a/drivers/target/iscsi/iscsi_target_login.c | ||
111 | +++ b/drivers/target/iscsi/iscsi_target_login.c | ||
112 | @@ -793,22 +793,6 @@ int iscsi_target_setup_login_socket( | ||
113 | } | ||
114 | np->np_socket = sock; | ||
115 | /* | ||
116 | - * The SCTP stack needs struct socket->file. | ||
117 | - */ | ||
118 | - if ((np->np_network_transport == ISCSI_SCTP_TCP) || | ||
119 | - (np->np_network_transport == ISCSI_SCTP_UDP)) { | ||
120 | - if (!sock->file) { | ||
121 | - sock->file = kzalloc(sizeof(struct file), GFP_KERNEL); | ||
122 | - if (!sock->file) { | ||
123 | - pr_err("Unable to allocate struct" | ||
124 | - " file for SCTP\n"); | ||
125 | - ret = -ENOMEM; | ||
126 | - goto fail; | ||
127 | - } | ||
128 | - np->np_flags |= NPF_SCTP_STRUCT_FILE; | ||
129 | - } | ||
130 | - } | ||
131 | - /* | ||
132 | * Setup the np->np_sockaddr from the passed sockaddr setup | ||
133 | * in iscsi_target_configfs.c code.. | ||
134 | */ | ||
135 | @@ -857,21 +841,15 @@ int iscsi_target_setup_login_socket( | ||
136 | |||
137 | fail: | ||
138 | np->np_socket = NULL; | ||
139 | - if (sock) { | ||
140 | - if (np->np_flags & NPF_SCTP_STRUCT_FILE) { | ||
141 | - kfree(sock->file); | ||
142 | - sock->file = NULL; | ||
143 | - } | ||
144 | - | ||
145 | + if (sock) | ||
146 | sock_release(sock); | ||
147 | - } | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | static int __iscsi_target_login_thread(struct iscsi_np *np) | ||
152 | { | ||
153 | u8 buffer[ISCSI_HDR_LEN], iscsi_opcode, zero_tsih = 0; | ||
154 | - int err, ret = 0, ip_proto, sock_type, set_sctp_conn_flag, stop; | ||
155 | + int err, ret = 0, ip_proto, sock_type, stop; | ||
156 | struct iscsi_conn *conn = NULL; | ||
157 | struct iscsi_login *login; | ||
158 | struct iscsi_portal_group *tpg = NULL; | ||
159 | @@ -882,7 +860,6 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | ||
160 | struct sockaddr_in6 sock_in6; | ||
161 | |||
162 | flush_signals(current); | ||
163 | - set_sctp_conn_flag = 0; | ||
164 | sock = np->np_socket; | ||
165 | ip_proto = np->np_ip_proto; | ||
166 | sock_type = np->np_sock_type; | ||
167 | @@ -907,35 +884,12 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | ||
168 | spin_unlock_bh(&np->np_thread_lock); | ||
169 | goto out; | ||
170 | } | ||
171 | - /* | ||
172 | - * The SCTP stack needs struct socket->file. | ||
173 | - */ | ||
174 | - if ((np->np_network_transport == ISCSI_SCTP_TCP) || | ||
175 | - (np->np_network_transport == ISCSI_SCTP_UDP)) { | ||
176 | - if (!new_sock->file) { | ||
177 | - new_sock->file = kzalloc( | ||
178 | - sizeof(struct file), GFP_KERNEL); | ||
179 | - if (!new_sock->file) { | ||
180 | - pr_err("Unable to allocate struct" | ||
181 | - " file for SCTP\n"); | ||
182 | - sock_release(new_sock); | ||
183 | - /* Get another socket */ | ||
184 | - return 1; | ||
185 | - } | ||
186 | - set_sctp_conn_flag = 1; | ||
187 | - } | ||
188 | - } | ||
189 | - | ||
190 | iscsi_start_login_thread_timer(np); | ||
191 | |||
192 | conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); | ||
193 | if (!conn) { | ||
194 | pr_err("Could not allocate memory for" | ||
195 | " new connection\n"); | ||
196 | - if (set_sctp_conn_flag) { | ||
197 | - kfree(new_sock->file); | ||
198 | - new_sock->file = NULL; | ||
199 | - } | ||
200 | sock_release(new_sock); | ||
201 | /* Get another socket */ | ||
202 | return 1; | ||
203 | @@ -945,9 +899,6 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | ||
204 | conn->conn_state = TARG_CONN_STATE_FREE; | ||
205 | conn->sock = new_sock; | ||
206 | |||
207 | - if (set_sctp_conn_flag) | ||
208 | - conn->conn_flags |= CONNFLAG_SCTP_STRUCT_FILE; | ||
209 | - | ||
210 | pr_debug("Moving to TARG_CONN_STATE_XPT_UP.\n"); | ||
211 | conn->conn_state = TARG_CONN_STATE_XPT_UP; | ||
212 | |||
213 | @@ -1195,13 +1146,8 @@ old_sess_out: | ||
214 | iscsi_release_param_list(conn->param_list); | ||
215 | conn->param_list = NULL; | ||
216 | } | ||
217 | - if (conn->sock) { | ||
218 | - if (conn->conn_flags & CONNFLAG_SCTP_STRUCT_FILE) { | ||
219 | - kfree(conn->sock->file); | ||
220 | - conn->sock->file = NULL; | ||
221 | - } | ||
222 | + if (conn->sock) | ||
223 | sock_release(conn->sock); | ||
224 | - } | ||
225 | kfree(conn); | ||
226 | |||
227 | if (tpg) { | ||
228 | -- | ||
229 | 1.7.7.6 | ||
230 | |||