@@ -431,6 +431,21 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
431
431
& rsp_iov [1 ], sizeof (idata -> posix_fi ) /* add SIDs */ ,
432
432
(char * )& idata -> posix_fi );
433
433
}
434
+ if (rc == 0 ) {
435
+ unsigned int length = le32_to_cpu (qi_rsp -> OutputBufferLength );
436
+
437
+ if (length > sizeof (idata -> posix_fi )) {
438
+ char * base = (char * )rsp_iov [1 ].iov_base +
439
+ le16_to_cpu (qi_rsp -> OutputBufferOffset ) +
440
+ sizeof (idata -> posix_fi );
441
+ * extbuflen = length - sizeof (idata -> posix_fi );
442
+ * extbuf = kmemdup (base , * extbuflen , GFP_KERNEL );
443
+ if (!* extbuf )
444
+ rc = - ENOMEM ;
445
+ } else {
446
+ rc = - EINVAL ;
447
+ }
448
+ }
434
449
if (rqst [1 ].rq_iov )
435
450
SMB2_query_info_free (& rqst [1 ]);
436
451
if (rqst [2 ].rq_iov )
@@ -569,13 +584,20 @@ int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
569
584
570
585
int smb311_posix_query_path_info (const unsigned int xid , struct cifs_tcon * tcon ,
571
586
struct cifs_sb_info * cifs_sb , const char * full_path ,
572
- struct cifs_open_info_data * data , bool * adjust_tz , bool * reparse )
587
+ struct cifs_open_info_data * data ,
588
+ struct cifs_sid * owner ,
589
+ struct cifs_sid * group ,
590
+ bool * adjust_tz , bool * reparse )
573
591
{
574
592
int rc ;
575
593
__u32 create_options = 0 ;
576
594
struct cifsFileInfo * cfile ;
577
595
struct kvec err_iov [3 ] = {};
578
596
int err_buftype [3 ] = {};
597
+ __u8 * sidsbuf = NULL ;
598
+ __u8 * sidsbuf_end = NULL ;
599
+ size_t sidsbuflen = 0 ;
600
+ size_t owner_len , group_len ;
579
601
580
602
* adjust_tz = false;
581
603
* reparse = false;
@@ -590,7 +612,7 @@ int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
590
612
cifs_get_readable_path (tcon , full_path , & cfile );
591
613
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path , FILE_READ_ATTRIBUTES , FILE_OPEN ,
592
614
create_options , ACL_NO_MODE , data , SMB2_OP_POSIX_QUERY_INFO , cfile ,
593
- NULL , NULL , err_iov , err_buftype );
615
+ & sidsbuf , & sidsbuflen , err_iov , err_buftype );
594
616
if (rc == - EOPNOTSUPP ) {
595
617
/* BB TODO: When support for special files added to Samba re-verify this path */
596
618
if (err_iov [0 ].iov_base && err_buftype [0 ] != CIFS_NO_BUFFER &&
@@ -607,10 +629,31 @@ int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
607
629
cifs_get_readable_path (tcon , full_path , & cfile );
608
630
rc = smb2_compound_op (xid , tcon , cifs_sb , full_path , FILE_READ_ATTRIBUTES ,
609
631
FILE_OPEN , create_options , ACL_NO_MODE , data ,
610
- SMB2_OP_POSIX_QUERY_INFO , cfile , NULL , NULL , NULL , NULL );
632
+ SMB2_OP_POSIX_QUERY_INFO , cfile ,
633
+ & sidsbuf , & sidsbuflen , NULL , NULL );
634
+ }
635
+
636
+ if (rc == 0 ) {
637
+ sidsbuf_end = sidsbuf + sidsbuflen ;
638
+
639
+ owner_len = posix_info_sid_size (sidsbuf , sidsbuf_end );
640
+ if (owner_len == -1 ) {
641
+ rc = - EINVAL ;
642
+ goto out ;
643
+ }
644
+ memcpy (owner , sidsbuf , owner_len );
645
+
646
+ group_len = posix_info_sid_size (
647
+ sidsbuf + owner_len , sidsbuf_end );
648
+ if (group_len == -1 ) {
649
+ rc = - EINVAL ;
650
+ goto out ;
651
+ }
652
+ memcpy (group , sidsbuf + owner_len , group_len );
611
653
}
612
654
613
655
out :
656
+ kfree (sidsbuf );
614
657
free_rsp_buf (err_buftype [0 ], err_iov [0 ].iov_base );
615
658
free_rsp_buf (err_buftype [1 ], err_iov [1 ].iov_base );
616
659
free_rsp_buf (err_buftype [2 ], err_iov [2 ].iov_base );
0 commit comments