Print this page
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
SMB-122 smbd core dumps in smbd_dc_update / smb_log
SMB-117 Win7 fails to open security properties
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb2_set_info.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb2_set_info.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       13 + * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  14   14   */
  15   15  
  16   16  /*
  17   17   * Dispatch function for SMB2_SET_INFO
  18   18   */
  19   19  
  20   20  #include <smbsrv/smb2_kproto.h>
  21   21  #include <smbsrv/smb_fsops.h>
  22   22  #include <smbsrv/ntifs.h>
  23   23  
↓ open down ↓ 1 lines elided ↑ open up ↑
  25   25  smb2_set_info(smb_request_t *sr)
  26   26  {
  27   27          smb_setinfo_t sinfo;
  28   28          uint16_t StructSize;
  29   29          uint16_t iBufOffset;
  30   30          uint32_t iBufLength;
  31   31          uint32_t AddlInfo;
  32   32          smb2fid_t smb2fid;
  33   33          uint32_t status;
  34   34          uint8_t InfoType, InfoClass;
  35      -        smb_sdrc_t sdrc = SDRC_SUCCESS;
  36   35          int rc = 0;
  37   36  
  38   37          bzero(&sinfo, sizeof (sinfo));
  39   38  
  40   39          /*
  41      -         * SMB2 Set Info request
       40 +         * Decode SMB2 Set Info request
  42   41           */
  43   42          rc = smb_mbc_decodef(
  44   43              &sr->smb_data, "wbblw..lqq",
  45   44              &StructSize,                /* w */
  46   45              &InfoType,                  /* b */
  47   46              &InfoClass,                 /* b */
  48   47              &iBufLength,                /* l */
  49   48              &iBufOffset,                /* w */
  50   49              /* reserved                   .. */
  51   50              &AddlInfo,                  /* l */
  52   51              &smb2fid.persistent,        /* q */
  53   52              &smb2fid.temporal);         /* q */
  54      -        if (rc || StructSize != 33) {
  55      -                sdrc = SDRC_ERROR;
  56      -                return (sdrc);
  57      -        }
       53 +        if (rc || StructSize != 33)
       54 +                return (SDRC_ERROR);
  58   55  
  59      -        if (iBufLength > smb2_max_trans) {
  60      -                status = NT_STATUS_INVALID_PARAMETER;
  61      -                goto errout;
  62      -        }
  63      -
  64      -        status = smb2sr_lookup_fid(sr, &smb2fid);
  65      -        if (status)
  66      -                goto errout;
  67      -
  68      -        sinfo.si_node = sr->fid_ofile->f_node;
  69      -        sr->user_cr = sr->fid_ofile->f_cr;
  70      -
  71   56          /*
  72   57           * If there's an input buffer, setup a shadow.
  73   58           */
  74   59          if (iBufLength) {
  75   60                  rc = MBC_SHADOW_CHAIN(&sinfo.si_data, &sr->smb_data,
  76   61                      sr->smb2_cmd_hdr + iBufOffset, iBufLength);
  77   62                  if (rc) {
  78      -                        status = NT_STATUS_INVALID_PARAMETER;
  79      -                        goto errout;
       63 +                        return (SDRC_ERROR);
  80   64                  }
  81   65          }
  82   66  
  83   67          /* No output data. */
  84   68          sr->raw_data.max_bytes = 0;
  85   69  
       70 +        status = smb2sr_lookup_fid(sr, &smb2fid);
       71 +        DTRACE_SMB2_START(op__SetInfo, smb_request_t *, sr);
       72 +
       73 +        if (status)
       74 +                goto errout;
       75 +
       76 +        if (iBufLength > smb2_max_trans) {
       77 +                status = NT_STATUS_INVALID_PARAMETER;
       78 +                goto errout;
       79 +        }
       80 +
       81 +        sinfo.si_node = sr->fid_ofile->f_node;
       82 +        sr->user_cr = sr->fid_ofile->f_cr;
       83 +
  86   84          switch (InfoType) {
  87   85          case SMB2_0_INFO_FILE:
  88   86                  status = smb2_setinfo_file(sr, &sinfo, InfoClass);
  89   87                  break;
  90   88          case SMB2_0_INFO_FILESYSTEM:
  91   89                  status = smb2_setinfo_fs(sr, &sinfo, InfoClass);
  92   90                  break;
  93   91          case SMB2_0_INFO_SECURITY:
  94   92                  status = smb2_setinfo_sec(sr, &sinfo, AddlInfo);
  95   93                  break;
  96   94          case SMB2_0_INFO_QUOTA:
  97   95                  status = smb2_setinfo_quota(sr, &sinfo);
  98   96                  break;
  99   97          default:
 100   98                  status = NT_STATUS_INVALID_PARAMETER;
 101   99                  break;
 102  100          }
 103  101  
      102 +errout:
      103 +        sr->smb2_status = status;
      104 +        DTRACE_SMB2_DONE(op__SetInfo, smb_request_t *, sr);
      105 +
 104  106          if (status) {
 105      -        errout:
 106  107                  smb2sr_put_error(sr, status);
 107      -                return (sdrc);
      108 +                return (SDRC_SUCCESS);
 108  109          }
 109  110  
 110  111          /*
 111  112           * SMB2 Query Info reply
 112  113           */
 113      -        rc = smb_mbc_encodef(
      114 +        (void) smb_mbc_encodef(
 114  115              &sr->reply, "w..",
 115  116              2); /* StructSize */        /* w */
 116      -        if (rc)
 117      -                sdrc = SDRC_ERROR;
 118  117  
 119      -        return (sdrc);
      118 +        return (SDRC_SUCCESS);
 120  119  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX