From 45272f19ec8da94131d12a4ae4651b228bb60e95 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Wed, 10 Aug 2016 16:59:25 +0200 Subject: [PATCH] T258: caps_lookup_slot: return SYS_ERR_CNODE_NOT_FOUND when encountering null cnode cap during lookup Signed-off-by: Simon Gerber --- errors/errno.fugu | 1 + kernel/capabilities.c | 6 ++++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/errors/errno.fugu b/errors/errno.fugu index 94b43a8..51cb292 100755 --- a/errors/errno.fugu +++ b/errors/errno.fugu @@ -43,6 +43,7 @@ errors kernel SYS_ERR_ { failure IDC_MSG_BOUNDS "Attempted to retrieve a word beyond the size of an LMP message structure", // Generic CSpace lookup errors + failure CNODE_NOT_FOUND "Encountered null capability when resolving slot", failure CNODE_TYPE "Encountered non-CNode capability when resolving slot", failure CNODE_RIGHTS "Insufficient rights on CNode", failure DEPTH_EXCEEDED "Exceeded depth limit of CSpace", diff --git a/kernel/capabilities.c b/kernel/capabilities.c index d2f4377..4865491 100644 --- a/kernel/capabilities.c +++ b/kernel/capabilities.c @@ -1140,6 +1140,12 @@ errval_t caps_lookup_slot(struct capability *rootcn, capaddr_t cptr, return SYS_ERR_OK; } + // L2 CNode in given L1 slot does not exist + if (l2cnode->cap.type == ObjType_Null) { + TRACE(KERNEL, CAP_LOOKUP_SLOT, 1); + debug(SUBSYS_CAPS, "%s: l2cnode is NULL\n", __FUNCTION__); + return SYS_ERR_CNODE_NOT_FOUND; + } if (l2cnode->cap.type != ObjType_L2CNode) { TRACE(KERNEL, CAP_LOOKUP_SLOT, 1); debug(SUBSYS_CAPS, "%s: l2cnode->type = %d\n", __FUNCTION__, -- 1.7.2.5