Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ksmbd: use __GFP_RETRY_MAYFAIL

Prefer to report ENOMEM rather than incur the oom for allocations in
ksmbd. __GFP_NORETRY could not achieve that, It would fail the allocations
just too easily. __GFP_RETRY_MAYFAIL will keep retrying the allocation
until there is no more progress and fail the allocation instead go OOM
and let the caller to deal with it.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Namjae Jeon and committed by
Steve French
0066f623 d6eb09fb

+126 -119
+3 -3
fs/smb/server/asn1.c
··· 104 104 oid_len + ntlmssp_len) * 2 + 105 105 neg_result_len + oid_len + ntlmssp_len; 106 106 107 - buf = kmalloc(total_len, GFP_KERNEL); 107 + buf = kmalloc(total_len, KSMBD_DEFAULT_GFP); 108 108 if (!buf) 109 109 return -ENOMEM; 110 110 ··· 140 140 int total_len = 4 + compute_asn_hdr_len_bytes(neg_result_len) * 2 + 141 141 neg_result_len; 142 142 143 - buf = kmalloc(total_len, GFP_KERNEL); 143 + buf = kmalloc(total_len, KSMBD_DEFAULT_GFP); 144 144 if (!buf) 145 145 return -ENOMEM; 146 146 ··· 217 217 if (!vlen) 218 218 return -EINVAL; 219 219 220 - conn->mechToken = kmemdup_nul(value, vlen, GFP_KERNEL); 220 + conn->mechToken = kmemdup_nul(value, vlen, KSMBD_DEFAULT_GFP); 221 221 if (!conn->mechToken) 222 222 return -ENOMEM; 223 223
+10 -9
fs/smb/server/auth.c
··· 151 151 152 152 /* convert user_name to unicode */ 153 153 len = strlen(user_name(sess->user)); 154 - uniname = kzalloc(2 + UNICODE_LEN(len), GFP_KERNEL); 154 + uniname = kzalloc(2 + UNICODE_LEN(len), KSMBD_DEFAULT_GFP); 155 155 if (!uniname) { 156 156 ret = -ENOMEM; 157 157 goto out; ··· 175 175 176 176 /* Convert domain name or conn name to unicode and uppercase */ 177 177 len = strlen(dname); 178 - domain = kzalloc(2 + UNICODE_LEN(len), GFP_KERNEL); 178 + domain = kzalloc(2 + UNICODE_LEN(len), KSMBD_DEFAULT_GFP); 179 179 if (!domain) { 180 180 ret = -ENOMEM; 181 181 goto out; ··· 254 254 } 255 255 256 256 len = CIFS_CRYPTO_KEY_SIZE + blen; 257 - construct = kzalloc(len, GFP_KERNEL); 257 + construct = kzalloc(len, KSMBD_DEFAULT_GFP); 258 258 if (!construct) { 259 259 rc = -ENOMEM; 260 260 goto out; ··· 361 361 if (sess_key_len > CIFS_KEY_SIZE) 362 362 return -EINVAL; 363 363 364 - ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL); 364 + ctx_arc4 = kmalloc(sizeof(*ctx_arc4), KSMBD_DEFAULT_GFP); 365 365 if (!ctx_arc4) 366 366 return -ENOMEM; 367 367 ··· 451 451 452 452 chgblob->NegotiateFlags = cpu_to_le32(flags); 453 453 len = strlen(ksmbd_netbios_name()); 454 - name = kmalloc(2 + UNICODE_LEN(len), GFP_KERNEL); 454 + name = kmalloc(2 + UNICODE_LEN(len), KSMBD_DEFAULT_GFP); 455 455 if (!name) 456 456 return -ENOMEM; 457 457 ··· 1043 1043 if (!nvec) 1044 1044 return NULL; 1045 1045 1046 - nr_entries = kcalloc(nvec, sizeof(int), GFP_KERNEL); 1046 + nr_entries = kcalloc(nvec, sizeof(int), KSMBD_DEFAULT_GFP); 1047 1047 if (!nr_entries) 1048 1048 return NULL; 1049 1049 ··· 1063 1063 /* Add two entries for transform header and signature */ 1064 1064 total_entries += 2; 1065 1065 1066 - sg = kmalloc_array(total_entries, sizeof(struct scatterlist), GFP_KERNEL); 1066 + sg = kmalloc_array(total_entries, sizeof(struct scatterlist), 1067 + KSMBD_DEFAULT_GFP); 1067 1068 if (!sg) { 1068 1069 kfree(nr_entries); 1069 1070 return NULL; ··· 1164 1163 goto free_ctx; 1165 1164 } 1166 1165 1167 - req = aead_request_alloc(tfm, GFP_KERNEL); 1166 + req = aead_request_alloc(tfm, KSMBD_DEFAULT_GFP); 1168 1167 if (!req) { 1169 1168 rc = -ENOMEM; 1170 1169 goto free_ctx; ··· 1183 1182 } 1184 1183 1185 1184 iv_len = crypto_aead_ivsize(tfm); 1186 - iv = kzalloc(iv_len, GFP_KERNEL); 1185 + iv = kzalloc(iv_len, KSMBD_DEFAULT_GFP); 1187 1186 if (!iv) { 1188 1187 rc = -ENOMEM; 1189 1188 goto free_sg;
+2 -2
fs/smb/server/connection.c
··· 52 52 { 53 53 struct ksmbd_conn *conn; 54 54 55 - conn = kzalloc(sizeof(struct ksmbd_conn), GFP_KERNEL); 55 + conn = kzalloc(sizeof(struct ksmbd_conn), KSMBD_DEFAULT_GFP); 56 56 if (!conn) 57 57 return NULL; 58 58 ··· 359 359 /* 4 for rfc1002 length field */ 360 360 /* 1 for implied bcc[0] */ 361 361 size = pdu_size + 4 + 1; 362 - conn->request_buf = kvmalloc(size, GFP_KERNEL); 362 + conn->request_buf = kvmalloc(size, KSMBD_DEFAULT_GFP); 363 363 if (!conn->request_buf) 364 364 break; 365 365
+3 -3
fs/smb/server/crypto_ctx.c
··· 89 89 return NULL; 90 90 91 91 shash = kzalloc(sizeof(*shash) + crypto_shash_descsize(tfm), 92 - GFP_KERNEL); 92 + KSMBD_DEFAULT_GFP); 93 93 if (!shash) 94 94 crypto_free_shash(tfm); 95 95 else ··· 133 133 ctx_list.avail_ctx++; 134 134 spin_unlock(&ctx_list.ctx_lock); 135 135 136 - ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), GFP_KERNEL); 136 + ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), KSMBD_DEFAULT_GFP); 137 137 if (!ctx) { 138 138 spin_lock(&ctx_list.ctx_lock); 139 139 ctx_list.avail_ctx--; ··· 258 258 init_waitqueue_head(&ctx_list.ctx_wait); 259 259 ctx_list.avail_ctx = 1; 260 260 261 - ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), GFP_KERNEL); 261 + ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), KSMBD_DEFAULT_GFP); 262 262 if (!ctx) 263 263 return -ENOMEM; 264 264 list_add(&ctx->list, &ctx_list.idle_ctx);
+2
fs/smb/server/glob.h
··· 44 44 45 45 #define UNICODE_LEN(x) ((x) * 2) 46 46 47 + #define KSMBD_DEFAULT_GFP (GFP_KERNEL | __GFP_RETRY_MAYFAIL) 48 + 47 49 #endif /* __KSMBD_GLOB_H */
+5 -5
fs/smb/server/ksmbd_work.c
··· 18 18 19 19 struct ksmbd_work *ksmbd_alloc_work_struct(void) 20 20 { 21 - struct ksmbd_work *work = kmem_cache_zalloc(work_cache, GFP_KERNEL); 21 + struct ksmbd_work *work = kmem_cache_zalloc(work_cache, KSMBD_DEFAULT_GFP); 22 22 23 23 if (work) { 24 24 work->compound_fid = KSMBD_NO_FID; ··· 30 30 INIT_LIST_HEAD(&work->aux_read_list); 31 31 work->iov_alloc_cnt = 4; 32 32 work->iov = kcalloc(work->iov_alloc_cnt, sizeof(struct kvec), 33 - GFP_KERNEL); 33 + KSMBD_DEFAULT_GFP); 34 34 if (!work->iov) { 35 35 kmem_cache_free(work_cache, work); 36 36 work = NULL; ··· 114 114 115 115 if (aux_size) { 116 116 need_iov_cnt++; 117 - ar = kmalloc(sizeof(struct aux_read), GFP_KERNEL); 117 + ar = kmalloc(sizeof(struct aux_read), KSMBD_DEFAULT_GFP); 118 118 if (!ar) 119 119 return -ENOMEM; 120 120 } ··· 125 125 work->iov_alloc_cnt += 4; 126 126 new = krealloc(work->iov, 127 127 sizeof(struct kvec) * work->iov_alloc_cnt, 128 - GFP_KERNEL | __GFP_ZERO); 128 + KSMBD_DEFAULT_GFP | __GFP_ZERO); 129 129 if (!new) { 130 130 kfree(ar); 131 131 work->iov_alloc_cnt -= 4; ··· 169 169 170 170 int allocate_interim_rsp_buf(struct ksmbd_work *work) 171 171 { 172 - work->response_buf = kzalloc(MAX_CIFS_SMALL_BUFFER_SIZE, GFP_KERNEL); 172 + work->response_buf = kzalloc(MAX_CIFS_SMALL_BUFFER_SIZE, KSMBD_DEFAULT_GFP); 173 173 if (!work->response_buf) 174 174 return -ENOMEM; 175 175 work->response_sz = MAX_CIFS_SMALL_BUFFER_SIZE;
+6 -5
fs/smb/server/mgmt/ksmbd_ida.c
··· 4 4 */ 5 5 6 6 #include "ksmbd_ida.h" 7 + #include "../glob.h" 7 8 8 9 int ksmbd_acquire_smb2_tid(struct ida *ida) 9 10 { 10 - return ida_alloc_range(ida, 1, 0xFFFFFFFE, GFP_KERNEL); 11 + return ida_alloc_range(ida, 1, 0xFFFFFFFE, KSMBD_DEFAULT_GFP); 11 12 } 12 13 13 14 int ksmbd_acquire_smb2_uid(struct ida *ida) 14 15 { 15 16 int id; 16 17 17 - id = ida_alloc_min(ida, 1, GFP_KERNEL); 18 + id = ida_alloc_min(ida, 1, KSMBD_DEFAULT_GFP); 18 19 if (id == 0xFFFE) 19 - id = ida_alloc_min(ida, 1, GFP_KERNEL); 20 + id = ida_alloc_min(ida, 1, KSMBD_DEFAULT_GFP); 20 21 21 22 return id; 22 23 } 23 24 24 25 int ksmbd_acquire_async_msg_id(struct ida *ida) 25 26 { 26 - return ida_alloc_min(ida, 1, GFP_KERNEL); 27 + return ida_alloc_min(ida, 1, KSMBD_DEFAULT_GFP); 27 28 } 28 29 29 30 int ksmbd_acquire_id(struct ida *ida) 30 31 { 31 - return ida_alloc(ida, GFP_KERNEL); 32 + return ida_alloc(ida, KSMBD_DEFAULT_GFP); 32 33 } 33 34 34 35 void ksmbd_release_id(struct ida *ida, int id)
+5 -5
fs/smb/server/mgmt/share_config.c
··· 102 102 if (!sz) 103 103 break; 104 104 105 - p = kzalloc(sizeof(struct ksmbd_veto_pattern), GFP_KERNEL); 105 + p = kzalloc(sizeof(struct ksmbd_veto_pattern), KSMBD_DEFAULT_GFP); 106 106 if (!p) 107 107 return -ENOMEM; 108 108 109 - p->pattern = kstrdup(veto_list, GFP_KERNEL); 109 + p->pattern = kstrdup(veto_list, KSMBD_DEFAULT_GFP); 110 110 if (!p->pattern) { 111 111 kfree(p); 112 112 return -ENOMEM; ··· 150 150 goto out; 151 151 } 152 152 153 - share = kzalloc(sizeof(struct ksmbd_share_config), GFP_KERNEL); 153 + share = kzalloc(sizeof(struct ksmbd_share_config), KSMBD_DEFAULT_GFP); 154 154 if (!share) 155 155 goto out; 156 156 157 157 share->flags = resp->flags; 158 158 atomic_set(&share->refcount, 1); 159 159 INIT_LIST_HEAD(&share->veto_list); 160 - share->name = kstrdup(name, GFP_KERNEL); 160 + share->name = kstrdup(name, KSMBD_DEFAULT_GFP); 161 161 162 162 if (!test_share_config_flag(share, KSMBD_SHARE_FLAG_PIPE)) { 163 163 int path_len = PATH_MAX; ··· 166 166 path_len = resp->payload_sz - resp->veto_list_sz; 167 167 168 168 share->path = kstrndup(ksmbd_share_config_path(resp), path_len, 169 - GFP_KERNEL); 169 + KSMBD_DEFAULT_GFP); 170 170 if (share->path) { 171 171 share->path_sz = strlen(share->path); 172 172 while (share->path_sz > 1 &&
+3 -2
fs/smb/server/mgmt/tree_connect.c
··· 31 31 if (!sc) 32 32 return status; 33 33 34 - tree_conn = kzalloc(sizeof(struct ksmbd_tree_connect), GFP_KERNEL); 34 + tree_conn = kzalloc(sizeof(struct ksmbd_tree_connect), 35 + KSMBD_DEFAULT_GFP); 35 36 if (!tree_conn) { 36 37 status.ret = -ENOMEM; 37 38 goto out_error; ··· 81 80 init_waitqueue_head(&tree_conn->refcount_q); 82 81 83 82 ret = xa_err(xa_store(&sess->tree_conns, tree_conn->id, tree_conn, 84 - GFP_KERNEL)); 83 + KSMBD_DEFAULT_GFP)); 85 84 if (ret) { 86 85 status.ret = -ENOMEM; 87 86 goto out_error;
+4 -4
fs/smb/server/mgmt/user_config.c
··· 36 36 { 37 37 struct ksmbd_user *user; 38 38 39 - user = kmalloc(sizeof(struct ksmbd_user), GFP_KERNEL); 39 + user = kmalloc(sizeof(struct ksmbd_user), KSMBD_DEFAULT_GFP); 40 40 if (!user) 41 41 return NULL; 42 42 43 - user->name = kstrdup(resp->account, GFP_KERNEL); 43 + user->name = kstrdup(resp->account, KSMBD_DEFAULT_GFP); 44 44 user->flags = resp->status; 45 45 user->gid = resp->gid; 46 46 user->uid = resp->uid; 47 47 user->passkey_sz = resp->hash_sz; 48 - user->passkey = kmalloc(resp->hash_sz, GFP_KERNEL); 48 + user->passkey = kmalloc(resp->hash_sz, KSMBD_DEFAULT_GFP); 49 49 if (user->passkey) 50 50 memcpy(user->passkey, resp->hash, resp->hash_sz); 51 51 ··· 64 64 65 65 user->sgid = kmemdup(resp_ext->____payload, 66 66 resp_ext->ngroups * sizeof(gid_t), 67 - GFP_KERNEL); 67 + KSMBD_DEFAULT_GFP); 68 68 if (!user->sgid) 69 69 goto err_free; 70 70
+5 -5
fs/smb/server/mgmt/user_session.c
··· 98 98 if (!method) 99 99 return -EINVAL; 100 100 101 - entry = kzalloc(sizeof(struct ksmbd_session_rpc), GFP_KERNEL); 101 + entry = kzalloc(sizeof(struct ksmbd_session_rpc), KSMBD_DEFAULT_GFP); 102 102 if (!entry) 103 103 return -ENOMEM; 104 104 ··· 106 106 entry->id = ksmbd_ipc_id_alloc(); 107 107 if (entry->id < 0) 108 108 goto free_entry; 109 - old = xa_store(&sess->rpc_handle_list, entry->id, entry, GFP_KERNEL); 109 + old = xa_store(&sess->rpc_handle_list, entry->id, entry, KSMBD_DEFAULT_GFP); 110 110 if (xa_is_err(old)) 111 111 goto free_id; 112 112 ··· 201 201 sess->dialect = conn->dialect; 202 202 memcpy(sess->ClientGUID, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE); 203 203 ksmbd_expire_session(conn); 204 - return xa_err(xa_store(&conn->sessions, sess->id, sess, GFP_KERNEL)); 204 + return xa_err(xa_store(&conn->sessions, sess->id, sess, KSMBD_DEFAULT_GFP)); 205 205 } 206 206 207 207 static int ksmbd_chann_del(struct ksmbd_conn *conn, struct ksmbd_session *sess) ··· 314 314 { 315 315 struct preauth_session *sess; 316 316 317 - sess = kmalloc(sizeof(struct preauth_session), GFP_KERNEL); 317 + sess = kmalloc(sizeof(struct preauth_session), KSMBD_DEFAULT_GFP); 318 318 if (!sess) 319 319 return NULL; 320 320 ··· 398 398 if (protocol != CIFDS_SESSION_FLAG_SMB2) 399 399 return NULL; 400 400 401 - sess = kzalloc(sizeof(struct ksmbd_session), GFP_KERNEL); 401 + sess = kzalloc(sizeof(struct ksmbd_session), KSMBD_DEFAULT_GFP); 402 402 if (!sess) 403 403 return NULL; 404 404
+6 -5
fs/smb/server/misc.c
··· 165 165 char *pathname, *ab_pathname, *nt_pathname; 166 166 int share_path_len = share->path_sz; 167 167 168 - pathname = kmalloc(PATH_MAX, GFP_KERNEL); 168 + pathname = kmalloc(PATH_MAX, KSMBD_DEFAULT_GFP); 169 169 if (!pathname) 170 170 return ERR_PTR(-EACCES); 171 171 ··· 180 180 goto free_pathname; 181 181 } 182 182 183 - nt_pathname = kzalloc(strlen(&ab_pathname[share_path_len]) + 2, GFP_KERNEL); 183 + nt_pathname = kzalloc(strlen(&ab_pathname[share_path_len]) + 2, 184 + KSMBD_DEFAULT_GFP); 184 185 if (!nt_pathname) { 185 186 nt_pathname = ERR_PTR(-ENOMEM); 186 187 goto free_pathname; ··· 233 232 char *cf_name; 234 233 int cf_len; 235 234 236 - cf_name = kzalloc(KSMBD_REQ_MAX_SHARE_NAME, GFP_KERNEL); 235 + cf_name = kzalloc(KSMBD_REQ_MAX_SHARE_NAME, KSMBD_DEFAULT_GFP); 237 236 if (!cf_name) 238 237 return ERR_PTR(-ENOMEM); 239 238 ··· 295 294 296 295 path_len = share->path_sz; 297 296 name_len = strlen(name); 298 - new_name = kmalloc(path_len + name_len + 2, GFP_KERNEL); 297 + new_name = kmalloc(path_len + name_len + 2, KSMBD_DEFAULT_GFP); 299 298 if (!new_name) 300 299 return new_name; 301 300 ··· 321 320 if (!sz) 322 321 return NULL; 323 322 324 - conv = kmalloc(sz, GFP_KERNEL); 323 + conv = kmalloc(sz, KSMBD_DEFAULT_GFP); 325 324 if (!conv) 326 325 return NULL; 327 326
+5 -5
fs/smb/server/ndr.c
··· 18 18 { 19 19 char *data; 20 20 21 - data = krealloc(n->data, n->offset + sz + 1024, GFP_KERNEL); 21 + data = krealloc(n->data, n->offset + sz + 1024, KSMBD_DEFAULT_GFP); 22 22 if (!data) 23 23 return -ENOMEM; 24 24 ··· 174 174 175 175 n->offset = 0; 176 176 n->length = 1024; 177 - n->data = kzalloc(n->length, GFP_KERNEL); 177 + n->data = kzalloc(n->length, KSMBD_DEFAULT_GFP); 178 178 if (!n->data) 179 179 return -ENOMEM; 180 180 ··· 350 350 351 351 n->offset = 0; 352 352 n->length = 1024; 353 - n->data = kzalloc(n->length, GFP_KERNEL); 353 + n->data = kzalloc(n->length, KSMBD_DEFAULT_GFP); 354 354 if (!n->data) 355 355 return -ENOMEM; 356 356 ··· 401 401 402 402 n->offset = 0; 403 403 n->length = 2048; 404 - n->data = kzalloc(n->length, GFP_KERNEL); 404 + n->data = kzalloc(n->length, KSMBD_DEFAULT_GFP); 405 405 if (!n->data) 406 406 return -ENOMEM; 407 407 ··· 505 505 return ret; 506 506 507 507 acl->sd_size = n->length - n->offset; 508 - acl->sd_buf = kzalloc(acl->sd_size, GFP_KERNEL); 508 + acl->sd_buf = kzalloc(acl->sd_size, KSMBD_DEFAULT_GFP); 509 509 if (!acl->sd_buf) 510 510 return -ENOMEM; 511 511
+6 -6
fs/smb/server/oplock.c
··· 34 34 struct ksmbd_session *sess = work->sess; 35 35 struct oplock_info *opinfo; 36 36 37 - opinfo = kzalloc(sizeof(struct oplock_info), GFP_KERNEL); 37 + opinfo = kzalloc(sizeof(struct oplock_info), KSMBD_DEFAULT_GFP); 38 38 if (!opinfo) 39 39 return NULL; 40 40 ··· 94 94 { 95 95 struct lease *lease; 96 96 97 - lease = kmalloc(sizeof(struct lease), GFP_KERNEL); 97 + lease = kmalloc(sizeof(struct lease), KSMBD_DEFAULT_GFP); 98 98 if (!lease) 99 99 return -ENOMEM; 100 100 ··· 709 709 if (!work) 710 710 return -ENOMEM; 711 711 712 - br_info = kmalloc(sizeof(struct oplock_break_info), GFP_KERNEL); 712 + br_info = kmalloc(sizeof(struct oplock_break_info), KSMBD_DEFAULT_GFP); 713 713 if (!br_info) { 714 714 ksmbd_free_work_struct(work); 715 715 return -ENOMEM; ··· 812 812 if (!work) 813 813 return -ENOMEM; 814 814 815 - br_info = kmalloc(sizeof(struct lease_break_info), GFP_KERNEL); 815 + br_info = kmalloc(sizeof(struct lease_break_info), KSMBD_DEFAULT_GFP); 816 816 if (!br_info) { 817 817 ksmbd_free_work_struct(work); 818 818 return -ENOMEM; ··· 1057 1057 } 1058 1058 read_unlock(&lease_list_lock); 1059 1059 1060 - lb = kmalloc(sizeof(struct lease_table), GFP_KERNEL); 1060 + lb = kmalloc(sizeof(struct lease_table), KSMBD_DEFAULT_GFP); 1061 1061 if (!lb) 1062 1062 return -ENOMEM; 1063 1063 ··· 1499 1499 if (IS_ERR_OR_NULL(cc)) 1500 1500 return NULL; 1501 1501 1502 - lreq = kzalloc(sizeof(struct lease_ctx_info), GFP_KERNEL); 1502 + lreq = kzalloc(sizeof(struct lease_ctx_info), KSMBD_DEFAULT_GFP); 1503 1503 if (!lreq) 1504 1504 return NULL; 1505 1505
+2 -2
fs/smb/server/server.c
··· 47 47 return -EINVAL; 48 48 49 49 kfree(server_conf.conf[idx]); 50 - server_conf.conf[idx] = kstrdup(val, GFP_KERNEL); 50 + server_conf.conf[idx] = kstrdup(val, KSMBD_DEFAULT_GFP); 51 51 if (!server_conf.conf[idx]) 52 52 return -ENOMEM; 53 53 return 0; ··· 415 415 { 416 416 struct server_ctrl_struct *ctrl; 417 417 418 - ctrl = kmalloc(sizeof(struct server_ctrl_struct), GFP_KERNEL); 418 + ctrl = kmalloc(sizeof(struct server_ctrl_struct), KSMBD_DEFAULT_GFP); 419 419 if (!ctrl) 420 420 return -ENOMEM; 421 421
+19 -19
fs/smb/server/smb2pdu.c
··· 551 551 if (le32_to_cpu(hdr->NextCommand) > 0) 552 552 sz = large_sz; 553 553 554 - work->response_buf = kvzalloc(sz, GFP_KERNEL); 554 + work->response_buf = kvzalloc(sz, KSMBD_DEFAULT_GFP); 555 555 if (!work->response_buf) 556 556 return -ENOMEM; 557 557 ··· 1147 1147 case SMB311_PROT_ID: 1148 1148 conn->preauth_info = 1149 1149 kzalloc(sizeof(struct preauth_integrity_info), 1150 - GFP_KERNEL); 1150 + KSMBD_DEFAULT_GFP); 1151 1151 if (!conn->preauth_info) { 1152 1152 rc = -ENOMEM; 1153 1153 rsp->hdr.Status = STATUS_INVALID_PARAMETER; ··· 1266 1266 return 0; 1267 1267 1268 1268 sess->Preauth_HashValue = kmemdup(conn->preauth_info->Preauth_HashValue, 1269 - PREAUTH_HASHVALUE_SIZE, GFP_KERNEL); 1269 + PREAUTH_HASHVALUE_SIZE, KSMBD_DEFAULT_GFP); 1270 1270 if (!sess->Preauth_HashValue) 1271 1271 return -ENOMEM; 1272 1272 ··· 1352 1352 sz = sizeof(struct challenge_message); 1353 1353 sz += (strlen(ksmbd_netbios_name()) * 2 + 1 + 4) * 6; 1354 1354 1355 - neg_blob = kzalloc(sz, GFP_KERNEL); 1355 + neg_blob = kzalloc(sz, KSMBD_DEFAULT_GFP); 1356 1356 if (!neg_blob) 1357 1357 return -ENOMEM; 1358 1358 ··· 1543 1543 if (conn->dialect >= SMB30_PROT_ID) { 1544 1544 chann = lookup_chann_list(sess, conn); 1545 1545 if (!chann) { 1546 - chann = kmalloc(sizeof(struct channel), GFP_KERNEL); 1546 + chann = kmalloc(sizeof(struct channel), KSMBD_DEFAULT_GFP); 1547 1547 if (!chann) 1548 1548 return -ENOMEM; 1549 1549 1550 1550 chann->conn = conn; 1551 - xa_store(&sess->ksmbd_chann_list, (long)conn, chann, GFP_KERNEL); 1551 + xa_store(&sess->ksmbd_chann_list, (long)conn, chann, KSMBD_DEFAULT_GFP); 1552 1552 } 1553 1553 } 1554 1554 ··· 1624 1624 if (conn->dialect >= SMB30_PROT_ID) { 1625 1625 chann = lookup_chann_list(sess, conn); 1626 1626 if (!chann) { 1627 - chann = kmalloc(sizeof(struct channel), GFP_KERNEL); 1627 + chann = kmalloc(sizeof(struct channel), KSMBD_DEFAULT_GFP); 1628 1628 if (!chann) 1629 1629 return -ENOMEM; 1630 1630 1631 1631 chann->conn = conn; 1632 - xa_store(&sess->ksmbd_chann_list, (long)conn, chann, GFP_KERNEL); 1632 + xa_store(&sess->ksmbd_chann_list, (long)conn, chann, KSMBD_DEFAULT_GFP); 1633 1633 } 1634 1634 } 1635 1635 ··· 2346 2346 le16_to_cpu(eabuf->EaValueLength)) 2347 2347 return -EINVAL; 2348 2348 2349 - attr_name = kmalloc(XATTR_NAME_MAX + 1, GFP_KERNEL); 2349 + attr_name = kmalloc(XATTR_NAME_MAX + 1, KSMBD_DEFAULT_GFP); 2350 2350 if (!attr_name) 2351 2351 return -ENOMEM; 2352 2352 ··· 2897 2897 goto err_out2; 2898 2898 } 2899 2899 } else { 2900 - name = kstrdup("", GFP_KERNEL); 2900 + name = kstrdup("", KSMBD_DEFAULT_GFP); 2901 2901 if (!name) { 2902 2902 rc = -ENOMEM; 2903 2903 goto err_out2; ··· 3338 3338 sizeof(struct smb_sid) * 3 + 3339 3339 sizeof(struct smb_acl) + 3340 3340 sizeof(struct smb_ace) * ace_num * 2, 3341 - GFP_KERNEL); 3341 + KSMBD_DEFAULT_GFP); 3342 3342 if (!pntsd) { 3343 3343 posix_acl_release(fattr.cf_acls); 3344 3344 posix_acl_release(fattr.cf_dacls); ··· 4946 4946 4947 4947 /* plus : size */ 4948 4948 streamlen += 1; 4949 - stream_buf = kmalloc(streamlen + 1, GFP_KERNEL); 4949 + stream_buf = kmalloc(streamlen + 1, KSMBD_DEFAULT_GFP); 4950 4950 if (!stream_buf) 4951 4951 break; 4952 4952 ··· 5921 5921 return -EINVAL; 5922 5922 5923 5923 ksmbd_debug(SMB, "setting FILE_LINK_INFORMATION\n"); 5924 - pathname = kmalloc(PATH_MAX, GFP_KERNEL); 5924 + pathname = kmalloc(PATH_MAX, KSMBD_DEFAULT_GFP); 5925 5925 if (!pathname) 5926 5926 return -ENOMEM; 5927 5927 ··· 6485 6485 } 6486 6486 6487 6487 aux_payload_buf = 6488 - kvmalloc(rpc_resp->payload_sz, GFP_KERNEL); 6488 + kvmalloc(rpc_resp->payload_sz, KSMBD_DEFAULT_GFP); 6489 6489 if (!aux_payload_buf) { 6490 6490 err = -ENOMEM; 6491 6491 goto out; ··· 6664 6664 ksmbd_debug(SMB, "filename %pD, offset %lld, len %zu\n", 6665 6665 fp->filp, offset, length); 6666 6666 6667 - aux_payload_buf = kvzalloc(length, GFP_KERNEL); 6667 + aux_payload_buf = kvzalloc(length, KSMBD_DEFAULT_GFP); 6668 6668 if (!aux_payload_buf) { 6669 6669 err = -ENOMEM; 6670 6670 goto out; ··· 6816 6816 int ret; 6817 6817 ssize_t nbytes; 6818 6818 6819 - data_buf = kvzalloc(length, GFP_KERNEL); 6819 + data_buf = kvzalloc(length, KSMBD_DEFAULT_GFP); 6820 6820 if (!data_buf) 6821 6821 return -ENOMEM; 6822 6822 ··· 7145 7145 { 7146 7146 struct ksmbd_lock *lock; 7147 7147 7148 - lock = kzalloc(sizeof(struct ksmbd_lock), GFP_KERNEL); 7148 + lock = kzalloc(sizeof(struct ksmbd_lock), KSMBD_DEFAULT_GFP); 7149 7149 if (!lock) 7150 7150 return NULL; 7151 7151 ··· 7413 7413 "would have to wait for getting lock\n"); 7414 7414 list_add(&smb_lock->llist, &rollback_list); 7415 7415 7416 - argv = kmalloc(sizeof(void *), GFP_KERNEL); 7416 + argv = kmalloc(sizeof(void *), KSMBD_DEFAULT_GFP); 7417 7417 if (!argv) { 7418 7418 err = -ENOMEM; 7419 7419 goto out; ··· 8907 8907 int rc = -ENOMEM; 8908 8908 void *tr_buf; 8909 8909 8910 - tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4, GFP_KERNEL); 8910 + tr_buf = kzalloc(sizeof(struct smb2_transform_hdr) + 4, KSMBD_DEFAULT_GFP); 8911 8911 if (!tr_buf) 8912 8912 return rc; 8913 8913
+1 -1
fs/smb/server/smb_common.c
··· 358 358 static int smb1_allocate_rsp_buf(struct ksmbd_work *work) 359 359 { 360 360 work->response_buf = kzalloc(MAX_CIFS_SMALL_BUFFER_SIZE, 361 - GFP_KERNEL); 361 + KSMBD_DEFAULT_GFP); 362 362 work->response_sz = MAX_CIFS_SMALL_BUFFER_SIZE; 363 363 364 364 if (!work->response_buf) {
+12 -11
fs/smb/server/smbacl.c
··· 345 345 */ 346 346 alloc = sizeof(struct posix_ace_state_array) 347 347 + cnt * sizeof(struct posix_user_ace_state); 348 - state->users = kzalloc(alloc, GFP_KERNEL); 348 + state->users = kzalloc(alloc, KSMBD_DEFAULT_GFP); 349 349 if (!state->users) 350 350 return -ENOMEM; 351 - state->groups = kzalloc(alloc, GFP_KERNEL); 351 + state->groups = kzalloc(alloc, KSMBD_DEFAULT_GFP); 352 352 if (!state->groups) { 353 353 kfree(state->users); 354 354 return -ENOMEM; ··· 410 410 return; 411 411 } 412 412 413 - ppace = kmalloc_array(num_aces, sizeof(struct smb_ace *), GFP_KERNEL); 413 + ppace = kmalloc_array(num_aces, sizeof(struct smb_ace *), KSMBD_DEFAULT_GFP); 414 414 if (!ppace) { 415 415 free_acl_state(&default_acl_state); 416 416 free_acl_state(&acl_state); ··· 553 553 if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) { 554 554 fattr->cf_acls = 555 555 posix_acl_alloc(acl_state.users->n + 556 - acl_state.groups->n + 4, GFP_KERNEL); 556 + acl_state.groups->n + 4, KSMBD_DEFAULT_GFP); 557 557 if (fattr->cf_acls) { 558 558 cf_pace = fattr->cf_acls->a_entries; 559 559 posix_state_to_acl(&acl_state, cf_pace); ··· 567 567 if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) { 568 568 fattr->cf_dacls = 569 569 posix_acl_alloc(default_acl_state.users->n + 570 - default_acl_state.groups->n + 4, GFP_KERNEL); 570 + default_acl_state.groups->n + 4, KSMBD_DEFAULT_GFP); 571 571 if (fattr->cf_dacls) { 572 572 cf_pdace = fattr->cf_dacls->a_entries; 573 573 posix_state_to_acl(&default_acl_state, cf_pdace); ··· 595 595 for (i = 0; i < fattr->cf_acls->a_count; i++, pace++) { 596 596 int flags = 0; 597 597 598 - sid = kmalloc(sizeof(struct smb_sid), GFP_KERNEL); 598 + sid = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); 599 599 if (!sid) 600 600 break; 601 601 ··· 662 662 663 663 pace = fattr->cf_dacls->a_entries; 664 664 for (i = 0; i < fattr->cf_dacls->a_count; i++, pace++) { 665 - sid = kmalloc(sizeof(struct smb_sid), GFP_KERNEL); 665 + sid = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); 666 666 if (!sid) 667 667 break; 668 668 ··· 906 906 gid_t gid; 907 907 unsigned int sid_type = SIDOWNER; 908 908 909 - nowner_sid_ptr = kmalloc(sizeof(struct smb_sid), GFP_KERNEL); 909 + nowner_sid_ptr = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); 910 910 if (!nowner_sid_ptr) 911 911 return -ENOMEM; 912 912 ··· 915 915 sid_type = SIDUNIX_USER; 916 916 id_to_sid(uid, sid_type, nowner_sid_ptr); 917 917 918 - ngroup_sid_ptr = kmalloc(sizeof(struct smb_sid), GFP_KERNEL); 918 + ngroup_sid_ptr = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP); 919 919 if (!ngroup_sid_ptr) { 920 920 kfree(nowner_sid_ptr); 921 921 return -ENOMEM; ··· 1032 1032 goto free_parent_pntsd; 1033 1033 } 1034 1034 1035 - aces_base = kmalloc(sizeof(struct smb_ace) * num_aces * 2, GFP_KERNEL); 1035 + aces_base = kmalloc(sizeof(struct smb_ace) * num_aces * 2, 1036 + KSMBD_DEFAULT_GFP); 1036 1037 if (!aces_base) { 1037 1038 rc = -ENOMEM; 1038 1039 goto free_parent_pntsd; ··· 1127 1126 pntsd_alloc_size = sizeof(struct smb_ntsd) + powner_sid_size + 1128 1127 pgroup_sid_size + sizeof(struct smb_acl) + nt_size; 1129 1128 1130 - pntsd = kzalloc(pntsd_alloc_size, GFP_KERNEL); 1129 + pntsd = kzalloc(pntsd_alloc_size, KSMBD_DEFAULT_GFP); 1131 1130 if (!pntsd) { 1132 1131 rc = -ENOMEM; 1133 1132 goto free_aces_base;
+3 -3
fs/smb/server/transport_ipc.c
··· 244 244 struct ksmbd_ipc_msg *msg; 245 245 size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg); 246 246 247 - msg = kvzalloc(msg_sz, GFP_KERNEL); 247 + msg = kvzalloc(msg_sz, KSMBD_DEFAULT_GFP); 248 248 if (msg) 249 249 msg->sz = sz; 250 250 return msg; ··· 283 283 entry->type + 1, type); 284 284 } 285 285 286 - entry->response = kvzalloc(sz, GFP_KERNEL); 286 + entry->response = kvzalloc(sz, KSMBD_DEFAULT_GFP); 287 287 if (!entry->response) { 288 288 ret = -ENOMEM; 289 289 break; ··· 444 444 if (!ksmbd_tools_pid) 445 445 return ret; 446 446 447 - skb = genlmsg_new(msg->sz, GFP_KERNEL); 447 + skb = genlmsg_new(msg->sz, KSMBD_DEFAULT_GFP); 448 448 if (!skb) 449 449 return -ENOMEM; 450 450
+5 -5
fs/smb/server/transport_rdma.c
··· 362 362 struct smb_direct_transport *t; 363 363 struct ksmbd_conn *conn; 364 364 365 - t = kzalloc(sizeof(*t), GFP_KERNEL); 365 + t = kzalloc(sizeof(*t), KSMBD_DEFAULT_GFP); 366 366 if (!t) 367 367 return NULL; 368 368 ··· 462 462 { 463 463 struct smb_direct_sendmsg *msg; 464 464 465 - msg = mempool_alloc(t->sendmsg_mempool, GFP_KERNEL); 465 + msg = mempool_alloc(t->sendmsg_mempool, KSMBD_DEFAULT_GFP); 466 466 if (!msg) 467 467 return ERR_PTR(-ENOMEM); 468 468 msg->transport = t; ··· 1406 1406 desc_buf = buf; 1407 1407 for (i = 0; i < desc_num; i++) { 1408 1408 msg = kzalloc(struct_size(msg, sg_list, SG_CHUNK_SIZE), 1409 - GFP_KERNEL); 1409 + KSMBD_DEFAULT_GFP); 1410 1410 if (!msg) { 1411 1411 ret = -ENOMEM; 1412 1412 goto out; ··· 1852 1852 INIT_LIST_HEAD(&t->recvmsg_queue); 1853 1853 1854 1854 for (i = 0; i < t->recv_credit_max; i++) { 1855 - recvmsg = mempool_alloc(t->recvmsg_mempool, GFP_KERNEL); 1855 + recvmsg = mempool_alloc(t->recvmsg_mempool, KSMBD_DEFAULT_GFP); 1856 1856 if (!recvmsg) 1857 1857 goto err; 1858 1858 recvmsg->transport = t; ··· 2144 2144 if (!rdma_frwr_is_supported(&ib_dev->attrs)) 2145 2145 return 0; 2146 2146 2147 - smb_dev = kzalloc(sizeof(*smb_dev), GFP_KERNEL); 2147 + smb_dev = kzalloc(sizeof(*smb_dev), KSMBD_DEFAULT_GFP); 2148 2148 if (!smb_dev) 2149 2149 return -ENOMEM; 2150 2150 smb_dev->ib_dev = ib_dev;
+6 -6
fs/smb/server/transport_tcp.c
··· 76 76 struct tcp_transport *t; 77 77 struct ksmbd_conn *conn; 78 78 79 - t = kzalloc(sizeof(*t), GFP_KERNEL); 79 + t = kzalloc(sizeof(*t), KSMBD_DEFAULT_GFP); 80 80 if (!t) 81 81 return NULL; 82 82 t->sock = client_sk; ··· 151 151 return t->iov; 152 152 153 153 /* not big enough -- allocate a new one and release the old */ 154 - new_iov = kmalloc_array(nr_segs, sizeof(*new_iov), GFP_KERNEL); 154 + new_iov = kmalloc_array(nr_segs, sizeof(*new_iov), KSMBD_DEFAULT_GFP); 155 155 if (new_iov) { 156 156 kfree(t->iov); 157 157 t->iov = new_iov; ··· 528 528 } 529 529 } 530 530 if (!found && bind_additional_ifaces) { 531 - iface = alloc_iface(kstrdup(netdev->name, GFP_KERNEL)); 531 + iface = alloc_iface(kstrdup(netdev->name, KSMBD_DEFAULT_GFP)); 532 532 if (!iface) 533 533 return NOTIFY_OK; 534 534 ret = create_socket(iface); ··· 600 600 if (!ifname) 601 601 return NULL; 602 602 603 - iface = kzalloc(sizeof(struct interface), GFP_KERNEL); 603 + iface = kzalloc(sizeof(struct interface), KSMBD_DEFAULT_GFP); 604 604 if (!iface) { 605 605 kfree(ifname); 606 606 return NULL; ··· 624 624 for_each_netdev(&init_net, netdev) { 625 625 if (netif_is_bridge_port(netdev)) 626 626 continue; 627 - if (!alloc_iface(kstrdup(netdev->name, GFP_KERNEL))) { 627 + if (!alloc_iface(kstrdup(netdev->name, KSMBD_DEFAULT_GFP))) { 628 628 rtnl_unlock(); 629 629 return -ENOMEM; 630 630 } ··· 635 635 } 636 636 637 637 while (ifc_list_sz > 0) { 638 - if (!alloc_iface(kstrdup(ifc_list, GFP_KERNEL))) 638 + if (!alloc_iface(kstrdup(ifc_list, KSMBD_DEFAULT_GFP))) 639 639 return -ENOMEM; 640 640 641 641 sz = strlen(ifc_list);
+2 -2
fs/smb/server/unicode.c
··· 297 297 if (is_unicode) { 298 298 len = smb_utf16_bytes((__le16 *)src, maxlen, codepage); 299 299 len += nls_nullsize(codepage); 300 - dst = kmalloc(len, GFP_KERNEL); 300 + dst = kmalloc(len, KSMBD_DEFAULT_GFP); 301 301 if (!dst) 302 302 return ERR_PTR(-ENOMEM); 303 303 ret = smb_from_utf16(dst, (__le16 *)src, len, maxlen, codepage, ··· 309 309 } else { 310 310 len = strnlen(src, maxlen); 311 311 len++; 312 - dst = kmalloc(len, GFP_KERNEL); 312 + dst = kmalloc(len, KSMBD_DEFAULT_GFP); 313 313 if (!dst) 314 314 return ERR_PTR(-ENOMEM); 315 315 strscpy(dst, src, len);
+6 -6
fs/smb/server/vfs.c
··· 444 444 } 445 445 446 446 if (v_len < size) { 447 - wbuf = kvzalloc(size, GFP_KERNEL); 447 + wbuf = kvzalloc(size, KSMBD_DEFAULT_GFP); 448 448 if (!wbuf) { 449 449 err = -ENOMEM; 450 450 goto out; ··· 865 865 if (size <= 0) 866 866 return size; 867 867 868 - vlist = kvzalloc(size, GFP_KERNEL); 868 + vlist = kvzalloc(size, KSMBD_DEFAULT_GFP); 869 869 if (!vlist) 870 870 return -ENOMEM; 871 871 ··· 907 907 if (xattr_len < 0) 908 908 return xattr_len; 909 909 910 - buf = kmalloc(xattr_len + 1, GFP_KERNEL); 910 + buf = kmalloc(xattr_len + 1, KSMBD_DEFAULT_GFP); 911 911 if (!buf) 912 912 return -ENOMEM; 913 913 ··· 1411 1411 1412 1412 smb_acl = kzalloc(sizeof(struct xattr_smb_acl) + 1413 1413 sizeof(struct xattr_acl_entry) * posix_acls->a_count, 1414 - GFP_KERNEL); 1414 + KSMBD_DEFAULT_GFP); 1415 1415 if (!smb_acl) 1416 1416 goto out; 1417 1417 ··· 1767 1767 else 1768 1768 type = ":$DATA"; 1769 1769 1770 - buf = kasprintf(GFP_KERNEL, "%s%s%s", 1770 + buf = kasprintf(KSMBD_DEFAULT_GFP, "%s%s%s", 1771 1771 XATTR_NAME_STREAM, stream_name, type); 1772 1772 if (!buf) 1773 1773 return -ENOMEM; ··· 1896 1896 acl_state.group.allow; 1897 1897 acl_state.mask.allow = 0x07; 1898 1898 1899 - acls = posix_acl_alloc(6, GFP_KERNEL); 1899 + acls = posix_acl_alloc(6, KSMBD_DEFAULT_GFP); 1900 1900 if (!acls) { 1901 1901 free_acl_state(&acl_state); 1902 1902 return -ENOMEM;
+5 -5
fs/smb/server/vfs_cache.c
··· 188 188 if (ci) 189 189 return ci; 190 190 191 - ci = kmalloc(sizeof(struct ksmbd_inode), GFP_KERNEL); 191 + ci = kmalloc(sizeof(struct ksmbd_inode), KSMBD_DEFAULT_GFP); 192 192 if (!ci) 193 193 return NULL; 194 194 ··· 577 577 return -EMFILE; 578 578 } 579 579 580 - idr_preload(GFP_KERNEL); 580 + idr_preload(KSMBD_DEFAULT_GFP); 581 581 write_lock(&ft->lock); 582 582 ret = idr_alloc_cyclic(ft->idr, fp, 0, INT_MAX - 1, GFP_NOWAIT); 583 583 if (ret >= 0) { ··· 605 605 struct ksmbd_file *fp; 606 606 int ret; 607 607 608 - fp = kmem_cache_zalloc(filp_cache, GFP_KERNEL); 608 + fp = kmem_cache_zalloc(filp_cache, KSMBD_DEFAULT_GFP); 609 609 if (!fp) { 610 610 pr_err("Failed to allocate memory\n"); 611 611 return ERR_PTR(-ENOMEM); ··· 923 923 char *pathname, *ab_pathname; 924 924 int ret = 0; 925 925 926 - pathname = kmalloc(PATH_MAX, GFP_KERNEL); 926 + pathname = kmalloc(PATH_MAX, KSMBD_DEFAULT_GFP); 927 927 if (!pathname) 928 928 return -EACCES; 929 929 ··· 983 983 984 984 int ksmbd_init_file_table(struct ksmbd_file_table *ft) 985 985 { 986 - ft->idr = kzalloc(sizeof(struct idr), GFP_KERNEL); 986 + ft->idr = kzalloc(sizeof(struct idr), KSMBD_DEFAULT_GFP); 987 987 if (!ft->idr) 988 988 return -ENOMEM; 989 989