|
@@ -255,7 +255,7 @@ static int __init cipso_v4_cache_init(void)
|
|
cipso_v4_cache = kcalloc(CIPSO_V4_CACHE_BUCKETS,
|
|
cipso_v4_cache = kcalloc(CIPSO_V4_CACHE_BUCKETS,
|
|
sizeof(struct cipso_v4_map_cache_bkt),
|
|
sizeof(struct cipso_v4_map_cache_bkt),
|
|
GFP_KERNEL);
|
|
GFP_KERNEL);
|
|
- if (cipso_v4_cache == NULL)
|
|
|
|
|
|
+ if (!cipso_v4_cache)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
for (iter = 0; iter < CIPSO_V4_CACHE_BUCKETS; iter++) {
|
|
for (iter = 0; iter < CIPSO_V4_CACHE_BUCKETS; iter++) {
|
|
@@ -339,7 +339,7 @@ static int cipso_v4_cache_check(const unsigned char *key,
|
|
secattr->cache = entry->lsm_data;
|
|
secattr->cache = entry->lsm_data;
|
|
secattr->flags |= NETLBL_SECATTR_CACHE;
|
|
secattr->flags |= NETLBL_SECATTR_CACHE;
|
|
secattr->type = NETLBL_NLTYPE_CIPSOV4;
|
|
secattr->type = NETLBL_NLTYPE_CIPSOV4;
|
|
- if (prev_entry == NULL) {
|
|
|
|
|
|
+ if (!prev_entry) {
|
|
spin_unlock_bh(&cipso_v4_cache[bkt].lock);
|
|
spin_unlock_bh(&cipso_v4_cache[bkt].lock);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -393,10 +393,10 @@ int cipso_v4_cache_add(const unsigned char *cipso_ptr,
|
|
cipso_ptr_len = cipso_ptr[1];
|
|
cipso_ptr_len = cipso_ptr[1];
|
|
|
|
|
|
entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
|
|
entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
|
|
- if (entry == NULL)
|
|
|
|
|
|
+ if (!entry)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
entry->key = kmemdup(cipso_ptr, cipso_ptr_len, GFP_ATOMIC);
|
|
entry->key = kmemdup(cipso_ptr, cipso_ptr_len, GFP_ATOMIC);
|
|
- if (entry->key == NULL) {
|
|
|
|
|
|
+ if (!entry->key) {
|
|
ret_val = -ENOMEM;
|
|
ret_val = -ENOMEM;
|
|
goto cache_add_failure;
|
|
goto cache_add_failure;
|
|
}
|
|
}
|
|
@@ -502,7 +502,7 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def,
|
|
atomic_set(&doi_def->refcount, 1);
|
|
atomic_set(&doi_def->refcount, 1);
|
|
|
|
|
|
spin_lock(&cipso_v4_doi_list_lock);
|
|
spin_lock(&cipso_v4_doi_list_lock);
|
|
- if (cipso_v4_doi_search(doi_def->doi) != NULL) {
|
|
|
|
|
|
+ if (cipso_v4_doi_search(doi_def->doi)) {
|
|
spin_unlock(&cipso_v4_doi_list_lock);
|
|
spin_unlock(&cipso_v4_doi_list_lock);
|
|
ret_val = -EEXIST;
|
|
ret_val = -EEXIST;
|
|
goto doi_add_return;
|
|
goto doi_add_return;
|
|
@@ -513,7 +513,7 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def,
|
|
|
|
|
|
doi_add_return:
|
|
doi_add_return:
|
|
audit_buf = netlbl_audit_start(AUDIT_MAC_CIPSOV4_ADD, audit_info);
|
|
audit_buf = netlbl_audit_start(AUDIT_MAC_CIPSOV4_ADD, audit_info);
|
|
- if (audit_buf != NULL) {
|
|
|
|
|
|
+ if (audit_buf) {
|
|
const char *type_str;
|
|
const char *type_str;
|
|
switch (doi_type) {
|
|
switch (doi_type) {
|
|
case CIPSO_V4_MAP_TRANS:
|
|
case CIPSO_V4_MAP_TRANS:
|
|
@@ -547,7 +547,7 @@ doi_add_return:
|
|
*/
|
|
*/
|
|
void cipso_v4_doi_free(struct cipso_v4_doi *doi_def)
|
|
void cipso_v4_doi_free(struct cipso_v4_doi *doi_def)
|
|
{
|
|
{
|
|
- if (doi_def == NULL)
|
|
|
|
|
|
+ if (!doi_def)
|
|
return;
|
|
return;
|
|
|
|
|
|
switch (doi_def->type) {
|
|
switch (doi_def->type) {
|
|
@@ -598,7 +598,7 @@ int cipso_v4_doi_remove(u32 doi, struct netlbl_audit *audit_info)
|
|
|
|
|
|
spin_lock(&cipso_v4_doi_list_lock);
|
|
spin_lock(&cipso_v4_doi_list_lock);
|
|
doi_def = cipso_v4_doi_search(doi);
|
|
doi_def = cipso_v4_doi_search(doi);
|
|
- if (doi_def == NULL) {
|
|
|
|
|
|
+ if (!doi_def) {
|
|
spin_unlock(&cipso_v4_doi_list_lock);
|
|
spin_unlock(&cipso_v4_doi_list_lock);
|
|
ret_val = -ENOENT;
|
|
ret_val = -ENOENT;
|
|
goto doi_remove_return;
|
|
goto doi_remove_return;
|
|
@@ -617,7 +617,7 @@ int cipso_v4_doi_remove(u32 doi, struct netlbl_audit *audit_info)
|
|
|
|
|
|
doi_remove_return:
|
|
doi_remove_return:
|
|
audit_buf = netlbl_audit_start(AUDIT_MAC_CIPSOV4_DEL, audit_info);
|
|
audit_buf = netlbl_audit_start(AUDIT_MAC_CIPSOV4_DEL, audit_info);
|
|
- if (audit_buf != NULL) {
|
|
|
|
|
|
+ if (audit_buf) {
|
|
audit_log_format(audit_buf,
|
|
audit_log_format(audit_buf,
|
|
" cipso_doi=%u res=%u",
|
|
" cipso_doi=%u res=%u",
|
|
doi, ret_val == 0 ? 1 : 0);
|
|
doi, ret_val == 0 ? 1 : 0);
|
|
@@ -644,7 +644,7 @@ struct cipso_v4_doi *cipso_v4_doi_getdef(u32 doi)
|
|
|
|
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
doi_def = cipso_v4_doi_search(doi);
|
|
doi_def = cipso_v4_doi_search(doi);
|
|
- if (doi_def == NULL)
|
|
|
|
|
|
+ if (!doi_def)
|
|
goto doi_getdef_return;
|
|
goto doi_getdef_return;
|
|
if (!atomic_inc_not_zero(&doi_def->refcount))
|
|
if (!atomic_inc_not_zero(&doi_def->refcount))
|
|
doi_def = NULL;
|
|
doi_def = NULL;
|
|
@@ -664,7 +664,7 @@ doi_getdef_return:
|
|
*/
|
|
*/
|
|
void cipso_v4_doi_putdef(struct cipso_v4_doi *doi_def)
|
|
void cipso_v4_doi_putdef(struct cipso_v4_doi *doi_def)
|
|
{
|
|
{
|
|
- if (doi_def == NULL)
|
|
|
|
|
|
+ if (!doi_def)
|
|
return;
|
|
return;
|
|
|
|
|
|
if (!atomic_dec_and_test(&doi_def->refcount))
|
|
if (!atomic_dec_and_test(&doi_def->refcount))
|
|
@@ -1642,7 +1642,7 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
|
|
|
|
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
doi_def = cipso_v4_doi_search(get_unaligned_be32(&opt[2]));
|
|
doi_def = cipso_v4_doi_search(get_unaligned_be32(&opt[2]));
|
|
- if (doi_def == NULL) {
|
|
|
|
|
|
+ if (!doi_def) {
|
|
err_offset = 2;
|
|
err_offset = 2;
|
|
goto validate_return_locked;
|
|
goto validate_return_locked;
|
|
}
|
|
}
|
|
@@ -1736,7 +1736,7 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
|
|
* not the loopback device drop the packet. Further,
|
|
* not the loopback device drop the packet. Further,
|
|
* there is no legitimate reason for setting this from
|
|
* there is no legitimate reason for setting this from
|
|
* userspace so reject it if skb is NULL. */
|
|
* userspace so reject it if skb is NULL. */
|
|
- if (skb == NULL || !(skb->dev->flags & IFF_LOOPBACK)) {
|
|
|
|
|
|
+ if (!skb || !(skb->dev->flags & IFF_LOOPBACK)) {
|
|
err_offset = opt_iter;
|
|
err_offset = opt_iter;
|
|
goto validate_return_locked;
|
|
goto validate_return_locked;
|
|
}
|
|
}
|
|
@@ -1897,7 +1897,7 @@ int cipso_v4_sock_setattr(struct sock *sk,
|
|
* defined yet but it is not a problem as the only users of these
|
|
* defined yet but it is not a problem as the only users of these
|
|
* "lite" PF_INET sockets are functions which do an accept() call
|
|
* "lite" PF_INET sockets are functions which do an accept() call
|
|
* afterwards so we will label the socket as part of the accept(). */
|
|
* afterwards so we will label the socket as part of the accept(). */
|
|
- if (sk == NULL)
|
|
|
|
|
|
+ if (!sk)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
/* We allocate the maximum CIPSO option size here so we are probably
|
|
/* We allocate the maximum CIPSO option size here so we are probably
|
|
@@ -1905,7 +1905,7 @@ int cipso_v4_sock_setattr(struct sock *sk,
|
|
* on and after all we are only talking about 40 bytes. */
|
|
* on and after all we are only talking about 40 bytes. */
|
|
buf_len = CIPSO_V4_OPT_LEN_MAX;
|
|
buf_len = CIPSO_V4_OPT_LEN_MAX;
|
|
buf = kmalloc(buf_len, GFP_ATOMIC);
|
|
buf = kmalloc(buf_len, GFP_ATOMIC);
|
|
- if (buf == NULL) {
|
|
|
|
|
|
+ if (!buf) {
|
|
ret_val = -ENOMEM;
|
|
ret_val = -ENOMEM;
|
|
goto socket_setattr_failure;
|
|
goto socket_setattr_failure;
|
|
}
|
|
}
|
|
@@ -1921,7 +1921,7 @@ int cipso_v4_sock_setattr(struct sock *sk,
|
|
* set the IPOPT_CIPSO option. */
|
|
* set the IPOPT_CIPSO option. */
|
|
opt_len = (buf_len + 3) & ~3;
|
|
opt_len = (buf_len + 3) & ~3;
|
|
opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);
|
|
opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);
|
|
- if (opt == NULL) {
|
|
|
|
|
|
+ if (!opt) {
|
|
ret_val = -ENOMEM;
|
|
ret_val = -ENOMEM;
|
|
goto socket_setattr_failure;
|
|
goto socket_setattr_failure;
|
|
}
|
|
}
|
|
@@ -1981,7 +1981,7 @@ int cipso_v4_req_setattr(struct request_sock *req,
|
|
* on and after all we are only talking about 40 bytes. */
|
|
* on and after all we are only talking about 40 bytes. */
|
|
buf_len = CIPSO_V4_OPT_LEN_MAX;
|
|
buf_len = CIPSO_V4_OPT_LEN_MAX;
|
|
buf = kmalloc(buf_len, GFP_ATOMIC);
|
|
buf = kmalloc(buf_len, GFP_ATOMIC);
|
|
- if (buf == NULL) {
|
|
|
|
|
|
+ if (!buf) {
|
|
ret_val = -ENOMEM;
|
|
ret_val = -ENOMEM;
|
|
goto req_setattr_failure;
|
|
goto req_setattr_failure;
|
|
}
|
|
}
|
|
@@ -1997,7 +1997,7 @@ int cipso_v4_req_setattr(struct request_sock *req,
|
|
* set the IPOPT_CIPSO option. */
|
|
* set the IPOPT_CIPSO option. */
|
|
opt_len = (buf_len + 3) & ~3;
|
|
opt_len = (buf_len + 3) & ~3;
|
|
opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);
|
|
opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);
|
|
- if (opt == NULL) {
|
|
|
|
|
|
+ if (!opt) {
|
|
ret_val = -ENOMEM;
|
|
ret_val = -ENOMEM;
|
|
goto req_setattr_failure;
|
|
goto req_setattr_failure;
|
|
}
|
|
}
|
|
@@ -2102,7 +2102,7 @@ void cipso_v4_sock_delattr(struct sock *sk)
|
|
|
|
|
|
sk_inet = inet_sk(sk);
|
|
sk_inet = inet_sk(sk);
|
|
opt = rcu_dereference_protected(sk_inet->inet_opt, 1);
|
|
opt = rcu_dereference_protected(sk_inet->inet_opt, 1);
|
|
- if (opt == NULL || opt->opt.cipso == 0)
|
|
|
|
|
|
+ if (!opt || opt->opt.cipso == 0)
|
|
return;
|
|
return;
|
|
|
|
|
|
hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);
|
|
hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);
|
|
@@ -2128,7 +2128,7 @@ void cipso_v4_req_delattr(struct request_sock *req)
|
|
|
|
|
|
req_inet = inet_rsk(req);
|
|
req_inet = inet_rsk(req);
|
|
opt = req_inet->opt;
|
|
opt = req_inet->opt;
|
|
- if (opt == NULL || opt->opt.cipso == 0)
|
|
|
|
|
|
+ if (!opt || opt->opt.cipso == 0)
|
|
return;
|
|
return;
|
|
|
|
|
|
cipso_v4_delopt(&req_inet->opt);
|
|
cipso_v4_delopt(&req_inet->opt);
|
|
@@ -2157,7 +2157,7 @@ int cipso_v4_getattr(const unsigned char *cipso,
|
|
doi = get_unaligned_be32(&cipso[2]);
|
|
doi = get_unaligned_be32(&cipso[2]);
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
doi_def = cipso_v4_doi_search(doi);
|
|
doi_def = cipso_v4_doi_search(doi);
|
|
- if (doi_def == NULL)
|
|
|
|
|
|
+ if (!doi_def)
|
|
goto getattr_return;
|
|
goto getattr_return;
|
|
/* XXX - This code assumes only one tag per CIPSO option which isn't
|
|
/* XXX - This code assumes only one tag per CIPSO option which isn't
|
|
* really a good assumption to make but since we only support the MAC
|
|
* really a good assumption to make but since we only support the MAC
|