diff options
author | Gordon Ross <gwr@nexenta.com> | 2017-08-28 22:07:55 +0000 |
---|---|---|
committer | Patrick Mooney <pmooney@pfmooney.com> | 2017-08-30 15:15:49 +0000 |
commit | 1ac8d1bdbcf8d2c79c9f93e698c96d8d4a04a3c2 (patch) | |
tree | 8c3776733508327ca188511b11597c46dfd8d898 | |
parent | 7b6ca83c4fa34c7bb7554e3baff564cb94edfaae (diff) | |
download | illumos-joyent-1ac8d1bdbcf8d2c79c9f93e698c96d8d4a04a3c2.tar.gz |
OS-6298 SMB client assumes serialized ioctls
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.h | 4 | ||||
-rw-r--r-- | usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c | 19 |
2 files changed, 20 insertions, 3 deletions
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.h b/usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.h index 5e86f4f5ca..42dfd687f9 100644 --- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.h +++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.h @@ -275,8 +275,7 @@ void smb_fscb_set(smb_fscb_t *); * Mostly used in: smb_dev.c, smb_usr.c */ typedef struct smb_dev { - dev_info_t *sd_dip; /* ptr to dev_info node */ - struct cred *sd_cred; /* per dev credentails */ + kmutex_t sd_lock; struct smb_vc *sd_vc; /* Reference to VC */ struct smb_share *sd_share; /* Reference to share if any */ int sd_level; /* SMBL_VC, ... */ @@ -285,6 +284,7 @@ typedef struct smb_dev { int sd_flags; /* State of connection */ #define NSMBFL_OPEN 0x0001 #define NSMBFL_IOD 0x0002 +#define NSMBFL_IOCTL 0x0004 int sd_smbfid; /* library read/write */ zoneid_t zoneid; /* Zone id */ } smb_dev_t; diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c b/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c index 02c6c9a946..54272c19d2 100644 --- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c +++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c @@ -346,6 +346,18 @@ nsmb_ioctl(dev_t dev, int cmd, intptr_t arg, int flags, /* model.h */ * check the zone status here on every ioctl call. */ + /* + * Serialize ioctl calls. The smb_usr_... functions + * don't expect concurrent calls on a given sdp. + */ + mutex_enter(&sdp->sd_lock); + if ((sdp->sd_flags & NSMBFL_IOCTL) != 0) { + mutex_exit(&sdp->sd_lock); + return (EBUSY); + } + sdp->sd_flags |= NSMBFL_IOCTL; + mutex_exit(&sdp->sd_lock); + err = 0; switch (cmd) { case SMBIOC_GETVERS: @@ -432,6 +444,10 @@ nsmb_ioctl(dev_t dev, int cmd, intptr_t arg, int flags, /* model.h */ break; } + mutex_enter(&sdp->sd_lock); + sdp->sd_flags &= ~NSMBFL_IOCTL; + mutex_exit(&sdp->sd_lock); + return (err); } @@ -475,10 +491,10 @@ found: *dev = makedevice(nsmb_major, m); mutex_exit(&dev_lck); - sdp->sd_cred = cr; sdp->sd_smbfid = -1; sdp->sd_flags |= NSMBFL_OPEN; sdp->zoneid = crgetzoneid(cr); + mutex_init(&sdp->sd_lock, NULL, MUTEX_DRIVER, NULL); return (0); } @@ -537,6 +553,7 @@ nsmb_close2(smb_dev_t *sdp, cred_t *cr) smb_iod_disconnect(vcp); smb_vc_rele(vcp); } + mutex_destroy(&sdp->sd_lock); return (0); } |