hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/fs/cifs/link.c
....@@ -97,15 +97,18 @@
9797 if (rc != 1)
9898 return -EINVAL;
9999
100
+ if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN)
101
+ return -EINVAL;
102
+
100103 rc = symlink_hash(link_len, link_str, md5_hash);
101104 if (rc) {
102105 cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __func__, rc);
103106 return rc;
104107 }
105108
106
- snprintf(md5_str2, sizeof(md5_str2),
107
- CIFS_MF_SYMLINK_MD5_FORMAT,
108
- CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
109
+ scnprintf(md5_str2, sizeof(md5_str2),
110
+ CIFS_MF_SYMLINK_MD5_FORMAT,
111
+ CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
109112
110113 if (strncmp(md5_str1, md5_str2, 17) != 0)
111114 return -EINVAL;
....@@ -142,10 +145,10 @@
142145 return rc;
143146 }
144147
145
- snprintf(buf, buf_len,
146
- CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
147
- link_len,
148
- CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
148
+ scnprintf(buf, buf_len,
149
+ CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
150
+ link_len,
151
+ CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
149152
150153 ofs = CIFS_MF_SYMLINK_LINK_OFFSET;
151154 memcpy(buf + ofs, link_str, link_len);
....@@ -308,14 +311,14 @@
308311 int oplock = 0;
309312 struct cifs_fid fid;
310313 struct cifs_open_parms oparms;
311
- struct cifs_io_parms io_parms;
314
+ struct cifs_io_parms io_parms = {0};
312315 int buf_type = CIFS_NO_BUFFER;
313316 FILE_ALL_INFO file_info;
314317
315318 oparms.tcon = tcon;
316319 oparms.cifs_sb = cifs_sb;
317320 oparms.desired_access = GENERIC_READ;
318
- oparms.create_options = CREATE_NOT_DIR;
321
+ oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
319322 oparms.disposition = FILE_OPEN;
320323 oparms.path = path;
321324 oparms.fid = &fid;
....@@ -352,16 +355,12 @@
352355 int oplock = 0;
353356 struct cifs_fid fid;
354357 struct cifs_open_parms oparms;
355
- struct cifs_io_parms io_parms;
356
- int create_options = CREATE_NOT_DIR;
357
-
358
- if (backup_cred(cifs_sb))
359
- create_options |= CREATE_OPEN_BACKUP_INTENT;
358
+ struct cifs_io_parms io_parms = {0};
360359
361360 oparms.tcon = tcon;
362361 oparms.cifs_sb = cifs_sb;
363362 oparms.desired_access = GENERIC_WRITE;
364
- oparms.create_options = create_options;
363
+ oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
365364 oparms.disposition = FILE_CREATE;
366365 oparms.path = path;
367366 oparms.fid = &fid;
....@@ -393,7 +392,7 @@
393392 int rc;
394393 struct cifs_fid fid;
395394 struct cifs_open_parms oparms;
396
- struct cifs_io_parms io_parms;
395
+ struct cifs_io_parms io_parms = {0};
397396 int buf_type = CIFS_NO_BUFFER;
398397 __le16 *utf16_path;
399398 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
....@@ -402,9 +401,7 @@
402401 oparms.tcon = tcon;
403402 oparms.cifs_sb = cifs_sb;
404403 oparms.desired_access = GENERIC_READ;
405
- oparms.create_options = CREATE_NOT_DIR;
406
- if (backup_cred(cifs_sb))
407
- oparms.create_options |= CREATE_OPEN_BACKUP_INTENT;
404
+ oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
408405 oparms.disposition = FILE_OPEN;
409406 oparms.fid = &fid;
410407 oparms.reconnect = false;
....@@ -422,7 +419,7 @@
422419 }
423420
424421 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, pfile_info, NULL,
425
- NULL);
422
+ NULL, NULL);
426423 if (rc)
427424 goto qmf_out_open_fail;
428425
....@@ -456,14 +453,10 @@
456453 int rc;
457454 struct cifs_fid fid;
458455 struct cifs_open_parms oparms;
459
- struct cifs_io_parms io_parms;
460
- int create_options = CREATE_NOT_DIR;
456
+ struct cifs_io_parms io_parms = {0};
461457 __le16 *utf16_path;
462458 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
463459 struct kvec iov[2];
464
-
465
- if (backup_cred(cifs_sb))
466
- create_options |= CREATE_OPEN_BACKUP_INTENT;
467460
468461 cifs_dbg(FYI, "%s: path: %s\n", __func__, path);
469462
....@@ -474,13 +467,14 @@
474467 oparms.tcon = tcon;
475468 oparms.cifs_sb = cifs_sb;
476469 oparms.desired_access = GENERIC_WRITE;
477
- oparms.create_options = create_options;
470
+ oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
478471 oparms.disposition = FILE_CREATE;
479472 oparms.fid = &fid;
480473 oparms.reconnect = false;
474
+ oparms.mode = 0644;
481475
482476 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL,
483
- NULL);
477
+ NULL, NULL);
484478 if (rc) {
485479 kfree(utf16_path);
486480 return rc;
....@@ -648,9 +642,16 @@
648642 rc = query_mf_symlink(xid, tcon, cifs_sb, full_path,
649643 &target_path);
650644
651
- if (rc != 0 && server->ops->query_symlink)
652
- rc = server->ops->query_symlink(xid, tcon, full_path,
653
- &target_path, cifs_sb);
645
+ if (rc != 0 && server->ops->query_symlink) {
646
+ struct cifsInodeInfo *cifsi = CIFS_I(inode);
647
+ bool reparse_point = false;
648
+
649
+ if (cifsi->cifsAttrs & ATTR_REPARSE)
650
+ reparse_point = true;
651
+
652
+ rc = server->ops->query_symlink(xid, tcon, cifs_sb, full_path,
653
+ &target_path, reparse_point);
654
+ }
654655
655656 kfree(full_path);
656657 free_xid(xid);
....@@ -704,7 +705,9 @@
704705 cifs_sb_target->local_nls); */
705706
706707 if (rc == 0) {
707
- if (pTcon->unix_ext)
708
+ if (pTcon->posix_extensions)
709
+ rc = smb311_posix_get_inode_info(&newinode, full_path, inode->i_sb, xid);
710
+ else if (pTcon->unix_ext)
708711 rc = cifs_get_inode_info_unix(&newinode, full_path,
709712 inode->i_sb, xid);
710713 else