#define DEBUG_SUBSYSTEM S_SEC
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <linux/crypto.h>
#include <linux/key.h>
{
int adapt = 0;
- spin_lock(&imp->imp_lock);
+ write_lock(&imp->imp_sec_lock);
if (imp->imp_sec_expire &&
imp->imp_sec_expire < ktime_get_real_seconds()) {
adapt = 1;
imp->imp_sec_expire = 0;
}
- spin_unlock(&imp->imp_lock);
+ write_unlock(&imp->imp_sec_lock);
if (!adapt)
return 0;
"ctx (%p, fl %lx) doesn't switch, relax a little bit\n",
newctx, newctx->cc_flags);
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC));
+ schedule_timeout_interruptible(cfs_time_seconds(1));
} else if (unlikely(test_bit(PTLRPC_CTX_UPTODATE_BIT, &newctx->cc_flags)
== 0)) {
/*
}
static
-int ctx_refresh_timeout(void *data)
+int ctx_refresh_timeout(struct ptlrpc_request *req)
{
- struct ptlrpc_request *req = data;
int rc;
/* conn_cnt is needed in expire_one_request */
}
static
-void ctx_refresh_interrupt(void *data)
+void ctx_refresh_interrupt(struct ptlrpc_request *req)
{
- struct ptlrpc_request *req = data;
spin_lock(&req->rq_lock);
req->rq_intr = 1;
{
struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
struct ptlrpc_sec *sec;
- struct l_wait_info lwi;
int rc;
ENTRY;
req->rq_restart = 0;
spin_unlock(&req->rq_lock);
- lwi = LWI_TIMEOUT_INTR(msecs_to_jiffies(timeout * MSEC_PER_SEC),
- ctx_refresh_timeout,
- ctx_refresh_interrupt, req);
- rc = l_wait_event(req->rq_reply_waitq, ctx_check_refresh(ctx), &lwi);
+ if (wait_event_idle_timeout(req->rq_reply_waitq,
+ ctx_check_refresh(ctx),
+ cfs_time_seconds(timeout)) == 0) {
+ rc = -ETIMEDOUT;
+ if (!ctx_refresh_timeout(req) &&
+ l_wait_event_abortable(req->rq_reply_waitq,
+ ctx_check_refresh(ctx))
+ == -ERESTARTSYS) {
+ rc = -EINTR;
+ ctx_refresh_interrupt(req);
+ }
+ }
/*
* following cases could lead us here:
rc = do_cli_unwrap_reply(early_req);
if (rc) {
DEBUG_REQ(D_ADAPTTO, early_req,
- "error %d unwrap early reply", rc);
+ "unwrap early reply: rc = %d", rc);
GOTO(err_ctx, rc);
}
{
struct ptlrpc_sec *sec;
- spin_lock(&imp->imp_lock);
+ read_lock(&imp->imp_sec_lock);
sec = sptlrpc_sec_get(imp->imp_sec);
- spin_unlock(&imp->imp_lock);
+ read_unlock(&imp->imp_sec_lock);
return sec;
}
LASSERT_ATOMIC_POS(&sec->ps_refcount);
- spin_lock(&imp->imp_lock);
+ write_lock(&imp->imp_sec_lock);
old_sec = imp->imp_sec;
imp->imp_sec = sec;
- spin_unlock(&imp->imp_lock);
+ write_unlock(&imp->imp_sec_lock);
if (old_sec) {
sptlrpc_sec_kill(old_sec);
sptlrpc_flavor2name(&sf, str, sizeof(str)));
}
- mutex_lock(&imp->imp_sec_mutex);
-
newsec = sptlrpc_sec_create(imp, svc_ctx, &sf, sp);
if (newsec) {
sptlrpc_import_sec_install(imp, newsec);
rc = -EPERM;
}
- mutex_unlock(&imp->imp_sec_mutex);
out:
sptlrpc_sec_put(sec);
RETURN(rc);
imp->imp_obd->obd_type == NULL) {
rc = -EINVAL;
} else {
- argv[2] = imp->imp_obd->obd_type->typ_name;
+ argv[2] = (char *)imp->imp_obd->obd_type->typ_name;
argv[4] = imp->imp_obd->obd_name;
spin_lock(&imp->imp_sec->ps_lock);
if (imp->imp_sec->ps_sepol_mtime == 0 &&
switch (req->rq_sp_from) {
case LUSTRE_SP_CLI:
if (req->rq_auth_usr_mdt || req->rq_auth_usr_ost) {
+ /* The below message is checked in sanity-sec test_33 */
DEBUG_REQ(D_ERROR, req, "faked source CLI");
svc_rc = SECSVC_DROP;
}
break;
case LUSTRE_SP_MDT:
if (!req->rq_auth_usr_mdt) {
+ /* The below message is checked in sanity-sec test_33 */
DEBUG_REQ(D_ERROR, req, "faked source MDT");
svc_rc = SECSVC_DROP;
}
break;
case LUSTRE_SP_OST:
if (!req->rq_auth_usr_ost) {
+ /* The below message is checked in sanity-sec test_33 */
DEBUG_REQ(D_ERROR, req, "faked source OST");
svc_rc = SECSVC_DROP;
}
case LUSTRE_SP_MGC:
if (!req->rq_auth_usr_root && !req->rq_auth_usr_mdt &&
!req->rq_auth_usr_ost) {
+ /* The below message is checked in sanity-sec test_33 */
DEBUG_REQ(D_ERROR, req, "faked source MGC/MGS");
svc_rc = SECSVC_DROP;
}