Skip to content

Commit 8cc4457

Browse files
pcmooreJames Morris
authored andcommitted
NetLabel: Introduce static network labels for unlabeled connections
Most trusted OSs, with the exception of Linux, have the ability to specify static security labels for unlabeled networks. This patch adds this ability to the NetLabel packet labeling framework. If the NetLabel subsystem is called to determine the security attributes of an incoming packet it first checks to see if any recognized NetLabel packet labeling protocols are in-use on the packet. If none can be found then the unlabled connection table is queried and based on the packets incoming interface and address it is matched with a security label as configured by the administrator using the netlabel_tools package. The matching security label is returned to the caller just as if the packet was explicitly labeled using a labeling protocol. Signed-off-by: Paul Moore <paul.moore@hp.com> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 5dbe1eb commit 8cc4457

File tree

4 files changed

+1524
-18
lines changed

4 files changed

+1524
-18
lines changed

include/net/netlabel.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@
6767
* NetLabel NETLINK protocol
6868
*/
6969

70-
#define NETLBL_PROTO_VERSION 1
70+
/* NetLabel NETLINK protocol version
71+
* 1: initial version
72+
* 2: added static labels for unlabeled connections
73+
*/
74+
#define NETLBL_PROTO_VERSION 2
7175

7276
/* NetLabel NETLINK types/families */
7377
#define NETLBL_NLTYPE_NONE 0

net/netlabel/netlabel_kapi.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,21 +312,15 @@ int netlbl_sock_setattr(struct sock *sk,
312312
* @secattr: the security attributes
313313
*
314314
* Description:
315-
* Examines the given sock to see any NetLabel style labeling has been
315+
* Examines the given sock to see if any NetLabel style labeling has been
316316
* applied to the sock, if so it parses the socket label and returns the
317317
* security attributes in @secattr. Returns zero on success, negative values
318318
* on failure.
319319
*
320320
*/
321321
int netlbl_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
322322
{
323-
int ret_val;
324-
325-
ret_val = cipso_v4_sock_getattr(sk, secattr);
326-
if (ret_val == 0)
327-
return 0;
328-
329-
return netlbl_unlabel_getattr(secattr);
323+
return cipso_v4_sock_getattr(sk, secattr);
330324
}
331325

332326
/**
@@ -350,7 +344,7 @@ int netlbl_skbuff_getattr(const struct sk_buff *skb,
350344
cipso_v4_skbuff_getattr(skb, secattr) == 0)
351345
return 0;
352346

353-
return netlbl_unlabel_getattr(secattr);
347+
return netlbl_unlabel_getattr(skb, family, secattr);
354348
}
355349

356350
/**
@@ -434,6 +428,10 @@ static int __init netlbl_init(void)
434428
if (ret_val != 0)
435429
goto init_failure;
436430

431+
ret_val = netlbl_unlabel_init(NETLBL_UNLHSH_BITSIZE);
432+
if (ret_val != 0)
433+
goto init_failure;
434+
437435
ret_val = netlbl_netlink_init();
438436
if (ret_val != 0)
439437
goto init_failure;

0 commit comments

Comments
 (0)