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>
This commit is contained in:
parent
e2c73698af
commit
3384f3df5e
|
@ -182,6 +182,7 @@ enum dlm_status dlmlock(struct dlm_ctxt *dlm,
|
||||||
struct dlm_lockstatus *lksb,
|
struct dlm_lockstatus *lksb,
|
||||||
int flags,
|
int flags,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
int namelen,
|
||||||
dlm_astlockfunc_t *ast,
|
dlm_astlockfunc_t *ast,
|
||||||
void *data,
|
void *data,
|
||||||
dlm_bastlockfunc_t *bast);
|
dlm_bastlockfunc_t *bast);
|
||||||
|
|
|
@ -747,6 +747,7 @@ void dlm_change_lockres_owner(struct dlm_ctxt *dlm,
|
||||||
u8 owner);
|
u8 owner);
|
||||||
struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
|
struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
|
||||||
const char *lockid,
|
const char *lockid,
|
||||||
|
int namelen,
|
||||||
int flags);
|
int flags);
|
||||||
struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
|
struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
|
|
@ -540,8 +540,8 @@ static inline void dlm_get_next_cookie(u8 node_num, u64 *cookie)
|
||||||
|
|
||||||
enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode,
|
enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode,
|
||||||
struct dlm_lockstatus *lksb, int flags,
|
struct dlm_lockstatus *lksb, int flags,
|
||||||
const char *name, dlm_astlockfunc_t *ast, void *data,
|
const char *name, int namelen, dlm_astlockfunc_t *ast,
|
||||||
dlm_bastlockfunc_t *bast)
|
void *data, dlm_bastlockfunc_t *bast)
|
||||||
{
|
{
|
||||||
enum dlm_status status;
|
enum dlm_status status;
|
||||||
struct dlm_lock_resource *res = NULL;
|
struct dlm_lock_resource *res = NULL;
|
||||||
|
@ -571,7 +571,7 @@ enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode,
|
||||||
recovery = (flags & LKM_RECOVERY);
|
recovery = (flags & LKM_RECOVERY);
|
||||||
|
|
||||||
if (recovery &&
|
if (recovery &&
|
||||||
(!dlm_is_recovery_lock(name, strlen(name)) || convert) ) {
|
(!dlm_is_recovery_lock(name, namelen) || convert) ) {
|
||||||
dlm_error(status);
|
dlm_error(status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ retry_convert:
|
||||||
}
|
}
|
||||||
|
|
||||||
status = DLM_IVBUFLEN;
|
status = DLM_IVBUFLEN;
|
||||||
if (strlen(name) > DLM_LOCKID_NAME_MAX || strlen(name) < 1) {
|
if (namelen > DLM_LOCKID_NAME_MAX || namelen < 1) {
|
||||||
dlm_error(status);
|
dlm_error(status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -659,7 +659,7 @@ retry_convert:
|
||||||
dlm_wait_for_recovery(dlm);
|
dlm_wait_for_recovery(dlm);
|
||||||
|
|
||||||
/* find or create the lock resource */
|
/* find or create the lock resource */
|
||||||
res = dlm_get_lock_resource(dlm, name, flags);
|
res = dlm_get_lock_resource(dlm, name, namelen, flags);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
status = DLM_IVLOCKID;
|
status = DLM_IVLOCKID;
|
||||||
dlm_error(status);
|
dlm_error(status);
|
||||||
|
|
|
@ -740,6 +740,7 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
|
||||||
*/
|
*/
|
||||||
struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
|
struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
|
||||||
const char *lockid,
|
const char *lockid,
|
||||||
|
int namelen,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
struct dlm_lock_resource *tmpres=NULL, *res=NULL;
|
struct dlm_lock_resource *tmpres=NULL, *res=NULL;
|
||||||
|
@ -748,13 +749,12 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
|
||||||
int blocked = 0;
|
int blocked = 0;
|
||||||
int ret, nodenum;
|
int ret, nodenum;
|
||||||
struct dlm_node_iter iter;
|
struct dlm_node_iter iter;
|
||||||
unsigned int namelen, hash;
|
unsigned int hash;
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
int bit, wait_on_recovery = 0;
|
int bit, wait_on_recovery = 0;
|
||||||
|
|
||||||
BUG_ON(!lockid);
|
BUG_ON(!lockid);
|
||||||
|
|
||||||
namelen = strlen(lockid);
|
|
||||||
hash = dlm_lockid_hash(lockid, namelen);
|
hash = dlm_lockid_hash(lockid, namelen);
|
||||||
|
|
||||||
mlog(0, "get lockres %s (len %d)\n", lockid, namelen);
|
mlog(0, "get lockres %s (len %d)\n", lockid, namelen);
|
||||||
|
|
|
@ -2285,7 +2285,8 @@ again:
|
||||||
memset(&lksb, 0, sizeof(lksb));
|
memset(&lksb, 0, sizeof(lksb));
|
||||||
|
|
||||||
ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY,
|
ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY,
|
||||||
DLM_RECOVERY_LOCK_NAME, dlm_reco_ast, dlm, dlm_reco_bast);
|
DLM_RECOVERY_LOCK_NAME, DLM_RECOVERY_LOCK_NAME_LEN,
|
||||||
|
dlm_reco_ast, dlm, dlm_reco_bast);
|
||||||
|
|
||||||
mlog(0, "%s: dlmlock($RECOVERY) returned %d, lksb=%d\n",
|
mlog(0, "%s: dlmlock($RECOVERY) returned %d, lksb=%d\n",
|
||||||
dlm->name, ret, lksb.status);
|
dlm->name, ret, lksb.status);
|
||||||
|
|
Loading…
Reference in New Issue