aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2006-09-08 14:38:29 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2006-09-24 16:50:42 -0400
commit3384f3df5ed939a25135e1b2734fb7cdee1720a8 (patch)
tree7a68180b6adeb74b5a0a96e6c2d4ad529b34096d /fs
parente2c73698af3dac89328eef2b55f6746e0507d2bc (diff)
ocfs2: Allow binary names in the DLM
The OCFS2 DLM uses strlen() to determine lock name length, which excludes the possibility of putting binary values in the name string. Fix this by requiring that string length be passed in as a parameter. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/dlm/dlmapi.h1
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h1
-rw-r--r--fs/ocfs2/dlm/dlmlock.c10
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c4
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c3
5 files changed, 11 insertions, 8 deletions
diff --git a/fs/ocfs2/dlm/dlmapi.h b/fs/ocfs2/dlm/dlmapi.h
index 53652f51c0e1..cfd5cb65cab0 100644
--- a/fs/ocfs2/dlm/dlmapi.h
+++ b/fs/ocfs2/dlm/dlmapi.h
@@ -182,6 +182,7 @@ enum dlm_status dlmlock(struct dlm_ctxt *dlm,
182 struct dlm_lockstatus *lksb, 182 struct dlm_lockstatus *lksb,
183 int flags, 183 int flags,
184 const char *name, 184 const char *name,
185 int namelen,
185 dlm_astlockfunc_t *ast, 186 dlm_astlockfunc_t *ast,
186 void *data, 187 void *data,
187 dlm_bastlockfunc_t *bast); 188 dlm_bastlockfunc_t *bast);
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index 14530ee7e11d..fa968180b072 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -747,6 +747,7 @@ void dlm_change_lockres_owner(struct dlm_ctxt *dlm,
747 u8 owner); 747 u8 owner);
748struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm, 748struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
749 const char *lockid, 749 const char *lockid,
750 int namelen,
750 int flags); 751 int flags);
751struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, 752struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
752 const char *name, 753 const char *name,
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index 5ca57ec650c7..42a1b91979b5 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -540,8 +540,8 @@ static inline void dlm_get_next_cookie(u8 node_num, u64 *cookie)
540 540
541enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode, 541enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode,
542 struct dlm_lockstatus *lksb, int flags, 542 struct dlm_lockstatus *lksb, int flags,
543 const char *name, dlm_astlockfunc_t *ast, void *data, 543 const char *name, int namelen, dlm_astlockfunc_t *ast,
544 dlm_bastlockfunc_t *bast) 544 void *data, dlm_bastlockfunc_t *bast)
545{ 545{
546 enum dlm_status status; 546 enum dlm_status status;
547 struct dlm_lock_resource *res = NULL; 547 struct dlm_lock_resource *res = NULL;
@@ -571,7 +571,7 @@ enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode,
571 recovery = (flags & LKM_RECOVERY); 571 recovery = (flags & LKM_RECOVERY);
572 572
573 if (recovery && 573 if (recovery &&
574 (!dlm_is_recovery_lock(name, strlen(name)) || convert) ) { 574 (!dlm_is_recovery_lock(name, namelen) || convert) ) {
575 dlm_error(status); 575 dlm_error(status);
576 goto error; 576 goto error;
577 } 577 }
@@ -643,7 +643,7 @@ retry_convert:
643 } 643 }
644 644
645 status = DLM_IVBUFLEN; 645 status = DLM_IVBUFLEN;
646 if (strlen(name) > DLM_LOCKID_NAME_MAX || strlen(name) < 1) { 646 if (namelen > DLM_LOCKID_NAME_MAX || namelen < 1) {
647 dlm_error(status); 647 dlm_error(status);
648 goto error; 648 goto error;
649 } 649 }
@@ -659,7 +659,7 @@ retry_convert:
659 dlm_wait_for_recovery(dlm); 659 dlm_wait_for_recovery(dlm);
660 660
661 /* find or create the lock resource */ 661 /* find or create the lock resource */
662 res = dlm_get_lock_resource(dlm, name, flags); 662 res = dlm_get_lock_resource(dlm, name, namelen, flags);
663 if (!res) { 663 if (!res) {
664 status = DLM_IVLOCKID; 664 status = DLM_IVLOCKID;
665 dlm_error(status); 665 dlm_error(status);
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 9503240ef0e5..f784177b6241 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -740,6 +740,7 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
740 */ 740 */
741struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm, 741struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
742 const char *lockid, 742 const char *lockid,
743 int namelen,
743 int flags) 744 int flags)
744{ 745{
745 struct dlm_lock_resource *tmpres=NULL, *res=NULL; 746 struct dlm_lock_resource *tmpres=NULL, *res=NULL;
@@ -748,13 +749,12 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
748 int blocked = 0; 749 int blocked = 0;
749 int ret, nodenum; 750 int ret, nodenum;
750 struct dlm_node_iter iter; 751 struct dlm_node_iter iter;
751 unsigned int namelen, hash; 752 unsigned int hash;
752 int tries = 0; 753 int tries = 0;
753 int bit, wait_on_recovery = 0; 754 int bit, wait_on_recovery = 0;
754 755
755 BUG_ON(!lockid); 756 BUG_ON(!lockid);
756 757
757 namelen = strlen(lockid);
758 hash = dlm_lockid_hash(lockid, namelen); 758 hash = dlm_lockid_hash(lockid, namelen);
759 759
760 mlog(0, "get lockres %s (len %d)\n", lockid, namelen); 760 mlog(0, "get lockres %s (len %d)\n", lockid, namelen);
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 594745fab0b5..9d950d7cea38 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2285,7 +2285,8 @@ again:
2285 memset(&lksb, 0, sizeof(lksb)); 2285 memset(&lksb, 0, sizeof(lksb));
2286 2286
2287 ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY, 2287 ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY,
2288 DLM_RECOVERY_LOCK_NAME, dlm_reco_ast, dlm, dlm_reco_bast); 2288 DLM_RECOVERY_LOCK_NAME, DLM_RECOVERY_LOCK_NAME_LEN,
2289 dlm_reco_ast, dlm, dlm_reco_bast);
2289 2290
2290 mlog(0, "%s: dlmlock($RECOVERY) returned %d, lksb=%d\n", 2291 mlog(0, "%s: dlmlock($RECOVERY) returned %d, lksb=%d\n",
2291 dlm->name, ret, lksb.status); 2292 dlm->name, ret, lksb.status);