netlabel: cope with NULL catmap
to #27338374 commiteead1c2ea2
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: Matthew Sheets <matthew.sheets@gd-ms.com> Fixes:4b8feff251
("netlabel: fix the horribly broken catmap functions") Fixes:ceba1832b1
("calipso: Set the calipso socket label to match the secattr.") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reference: CVE-2020-10711 Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com> Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
This commit is contained in:
parent
0b3509b831
commit
2d4b9c66b1
|
@ -1272,7 +1272,8 @@ static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def,
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
secattr->flags |= NETLBL_SECATTR_MLS_CAT;
|
||||
if (secattr->attr.mls.cat)
|
||||
secattr->flags |= NETLBL_SECATTR_MLS_CAT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1453,7 +1454,8 @@ static int cipso_v4_parsetag_rng(const struct cipso_v4_doi *doi_def,
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
secattr->flags |= NETLBL_SECATTR_MLS_CAT;
|
||||
if (secattr->attr.mls.cat)
|
||||
secattr->flags |= NETLBL_SECATTR_MLS_CAT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1061,7 +1061,8 @@ static int calipso_opt_getattr(const unsigned char *calipso,
|
|||
goto getattr_return;
|
||||
}
|
||||
|
||||
secattr->flags |= NETLBL_SECATTR_MLS_CAT;
|
||||
if (secattr->attr.mls.cat)
|
||||
secattr->flags |= NETLBL_SECATTR_MLS_CAT;
|
||||
}
|
||||
|
||||
secattr->type = NETLBL_NLTYPE_CALIPSO;
|
||||
|
|
|
@ -748,6 +748,12 @@ int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
|
|||
if ((off & (BITS_PER_LONG - 1)) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* a null catmap is equivalent to an empty one */
|
||||
if (!catmap) {
|
||||
*offset = (u32)-1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (off < catmap->startbit) {
|
||||
off = catmap->startbit;
|
||||
*offset = off;
|
||||
|
|
Loading…
Reference in New Issue