提交 2d4b9c66 编写于 作者: P Paolo Abeni 提交者: Shile Zhang

netlabel: cope with NULL catmap

to #27338374

commit eead1c2ea2509fd754c6da893a94f0e69e83ebe4 upstream.

The cipso and calipso code can set the MLS_CAT attribute on
successful parsing, even if the corresponding catmap has
not been allocated, as per current configuration and external
input.

Later, selinux code tries to access the catmap if the MLS_CAT flag
is present via netlbl_catmap_getlong(). That may cause null ptr
dereference while processing incoming network traffic.

Address the issue setting the MLS_CAT flag only if the catmap is
really allocated. Additionally let netlbl_catmap_getlong() cope
with NULL catmap.
Reported-by: NMatthew Sheets <matthew.sheets@gd-ms.com>
Fixes: 4b8feff2 ("netlabel: fix the horribly broken catmap functions")
Fixes: ceba1832 ("calipso: Set the calipso socket label to match the secattr.")
Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
Acked-by: NPaul Moore <paul@paul-moore.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reference: CVE-2020-10711
Signed-off-by: NShile Zhang <shile.zhang@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 0b3509b8
...@@ -1272,6 +1272,7 @@ static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def, ...@@ -1272,6 +1272,7 @@ static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def,
return ret_val; return ret_val;
} }
if (secattr->attr.mls.cat)
secattr->flags |= NETLBL_SECATTR_MLS_CAT; secattr->flags |= NETLBL_SECATTR_MLS_CAT;
} }
...@@ -1453,6 +1454,7 @@ static int cipso_v4_parsetag_rng(const struct cipso_v4_doi *doi_def, ...@@ -1453,6 +1454,7 @@ static int cipso_v4_parsetag_rng(const struct cipso_v4_doi *doi_def,
return ret_val; return ret_val;
} }
if (secattr->attr.mls.cat)
secattr->flags |= NETLBL_SECATTR_MLS_CAT; secattr->flags |= NETLBL_SECATTR_MLS_CAT;
} }
......
...@@ -1061,6 +1061,7 @@ static int calipso_opt_getattr(const unsigned char *calipso, ...@@ -1061,6 +1061,7 @@ static int calipso_opt_getattr(const unsigned char *calipso,
goto getattr_return; goto getattr_return;
} }
if (secattr->attr.mls.cat)
secattr->flags |= NETLBL_SECATTR_MLS_CAT; secattr->flags |= NETLBL_SECATTR_MLS_CAT;
} }
......
...@@ -748,6 +748,12 @@ int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap, ...@@ -748,6 +748,12 @@ int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
if ((off & (BITS_PER_LONG - 1)) != 0) if ((off & (BITS_PER_LONG - 1)) != 0)
return -EINVAL; return -EINVAL;
/* a null catmap is equivalent to an empty one */
if (!catmap) {
*offset = (u32)-1;
return 0;
}
if (off < catmap->startbit) { if (off < catmap->startbit) {
off = catmap->startbit; off = catmap->startbit;
*offset = off; *offset = off;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册