|
50 | 50 | #define SMK_RECEIVING 1
|
51 | 51 | #define SMK_SENDING 2
|
52 | 52 |
|
53 |
| -#ifdef SMACK_IPV6_PORT_LABELING |
54 |
| -DEFINE_MUTEX(smack_ipv6_lock); |
| 53 | +static DEFINE_MUTEX(smack_ipv6_lock); |
55 | 54 | static LIST_HEAD(smk_ipv6_port_list);
|
56 |
| -#endif |
57 | 55 | static struct kmem_cache *smack_inode_cache;
|
58 | 56 | struct kmem_cache *smack_rule_cache;
|
59 | 57 | int smack_enabled;
|
@@ -2320,7 +2318,6 @@ static struct smack_known *smack_ipv4host_label(struct sockaddr_in *sip)
|
2320 | 2318 | return NULL;
|
2321 | 2319 | }
|
2322 | 2320 |
|
2323 |
| -#if IS_ENABLED(CONFIG_IPV6) |
2324 | 2321 | /*
|
2325 | 2322 | * smk_ipv6_localhost - Check for local ipv6 host address
|
2326 | 2323 | * @sip: the address
|
@@ -2388,7 +2385,6 @@ static struct smack_known *smack_ipv6host_label(struct sockaddr_in6 *sip)
|
2388 | 2385 |
|
2389 | 2386 | return NULL;
|
2390 | 2387 | }
|
2391 |
| -#endif /* CONFIG_IPV6 */ |
2392 | 2388 |
|
2393 | 2389 | /**
|
2394 | 2390 | * smack_netlabel - Set the secattr on a socket
|
@@ -2477,7 +2473,6 @@ static int smack_netlabel_send(struct sock *sk, struct sockaddr_in *sap)
|
2477 | 2473 | return smack_netlabel(sk, sk_lbl);
|
2478 | 2474 | }
|
2479 | 2475 |
|
2480 |
| -#if IS_ENABLED(CONFIG_IPV6) |
2481 | 2476 | /**
|
2482 | 2477 | * smk_ipv6_check - check Smack access
|
2483 | 2478 | * @subject: subject Smack label
|
@@ -2510,7 +2505,6 @@ static int smk_ipv6_check(struct smack_known *subject,
|
2510 | 2505 | rc = smk_bu_note("IPv6 check", subject, object, MAY_WRITE, rc);
|
2511 | 2506 | return rc;
|
2512 | 2507 | }
|
2513 |
| -#endif /* CONFIG_IPV6 */ |
2514 | 2508 |
|
2515 | 2509 | #ifdef SMACK_IPV6_PORT_LABELING
|
2516 | 2510 | /**
|
@@ -2599,6 +2593,7 @@ static void smk_ipv6_port_label(struct socket *sock, struct sockaddr *address)
|
2599 | 2593 | mutex_unlock(&smack_ipv6_lock);
|
2600 | 2594 | return;
|
2601 | 2595 | }
|
| 2596 | +#endif |
2602 | 2597 |
|
2603 | 2598 | /**
|
2604 | 2599 | * smk_ipv6_port_check - check Smack port access
|
@@ -2661,7 +2656,6 @@ static int smk_ipv6_port_check(struct sock *sk, struct sockaddr_in6 *address,
|
2661 | 2656 |
|
2662 | 2657 | return smk_ipv6_check(skp, object, address, act);
|
2663 | 2658 | }
|
2664 |
| -#endif /* SMACK_IPV6_PORT_LABELING */ |
2665 | 2659 |
|
2666 | 2660 | /**
|
2667 | 2661 | * smack_inode_setsecurity - set smack xattrs
|
@@ -2836,24 +2830,21 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,
|
2836 | 2830 | return 0;
|
2837 | 2831 | if (IS_ENABLED(CONFIG_IPV6) && sap->sa_family == AF_INET6) {
|
2838 | 2832 | struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;
|
2839 |
| -#ifdef SMACK_IPV6_SECMARK_LABELING |
2840 |
| - struct smack_known *rsp; |
2841 |
| -#endif |
| 2833 | + struct smack_known *rsp = NULL; |
2842 | 2834 |
|
2843 | 2835 | if (addrlen < SIN6_LEN_RFC2133)
|
2844 | 2836 | return 0;
|
2845 |
| -#ifdef SMACK_IPV6_SECMARK_LABELING |
2846 |
| - rsp = smack_ipv6host_label(sip); |
| 2837 | + if (__is_defined(SMACK_IPV6_SECMARK_LABELING)) |
| 2838 | + rsp = smack_ipv6host_label(sip); |
2847 | 2839 | if (rsp != NULL) {
|
2848 | 2840 | struct socket_smack *ssp = sock->sk->sk_security;
|
2849 | 2841 |
|
2850 | 2842 | rc = smk_ipv6_check(ssp->smk_out, rsp, sip,
|
2851 | 2843 | SMK_CONNECTING);
|
2852 | 2844 | }
|
2853 |
| -#endif |
2854 |
| -#ifdef SMACK_IPV6_PORT_LABELING |
2855 |
| - rc = smk_ipv6_port_check(sock->sk, sip, SMK_CONNECTING); |
2856 |
| -#endif |
| 2845 | + if (__is_defined(SMACK_IPV6_PORT_LABELING)) |
| 2846 | + rc = smk_ipv6_port_check(sock->sk, sip, SMK_CONNECTING); |
| 2847 | + |
2857 | 2848 | return rc;
|
2858 | 2849 | }
|
2859 | 2850 | if (sap->sa_family != AF_INET || addrlen < sizeof(struct sockaddr_in))
|
|
0 commit comments