Skip to content

Commit e8bfdb9

Browse files
pcmoorexjamesmorris
authored andcommitted
SELinux: Convert the netif code to use ifindex values
The current SELinux netif code requires the caller have a valid net_device struct pointer to lookup network interface information. However, we don't always have a valid net_device pointer so convert the netif code to use the ifindex values we always have as part of the sk_buff. This patch also removes the default message SID from the network interface record, it is not being used and therefore is "dead code". Signed-off-by: Paul Moore <paul.moore@hp.com> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 75e2291 commit e8bfdb9

6 files changed

Lines changed: 155 additions & 125 deletions

File tree

‎security/selinux/hooks.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3853,7 +3853,7 @@ static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
38533853
if (!skb->dev)
38543854
goto out;
38553855

3856-
err = sel_netif_sids(skb->dev, &if_sid, NULL);
3856+
err = sel_netif_sid(skb->iif, &if_sid);
38573857
if (err)
38583858
goto out;
38593859

@@ -4178,7 +4178,7 @@ static int selinux_ip_postroute_last_compat(struct sock *sk, struct net_device *
41784178

41794179
isec = inode->i_security;
41804180

4181-
err = sel_netif_sids(dev, &if_sid, NULL);
4181+
err = sel_netif_sid(dev->ifindex, &if_sid);
41824182
if (err)
41834183
goto out;
41844184

‎security/selinux/include/netif.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* Author: James Morris <jmorris@redhat.com>
88
*
99
* Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com>
10+
* Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
11+
* Paul Moore, <paul.moore@hp.com>
1012
*
1113
* This program is free software; you can redistribute it and/or modify
1214
* it under the terms of the GNU General Public License version 2,
@@ -15,7 +17,7 @@
1517
#ifndef _SELINUX_NETIF_H_
1618
#define _SELINUX_NETIF_H_
1719

18-
int sel_netif_sids(struct net_device *dev, u32 *if_sid, u32 *msg_sid);
20+
int sel_netif_sid(int ifindex, u32 *sid);
1921

2022
#endif /* _SELINUX_NETIF_H_ */
2123

‎security/selinux/include/objsec.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ struct bprm_security_struct {
9696
};
9797

9898
struct netif_security_struct {
99-
struct net_device *dev; /* back pointer */
100-
u32 if_sid; /* SID for this interface */
101-
u32 msg_sid; /* default SID for messages received on this interface */
99+
int ifindex; /* device index */
100+
u32 sid; /* SID for this interface */
102101
};
103102

104103
struct sk_security_struct {

‎security/selinux/include/security.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ int security_get_user_sids(u32 callsid, char *username,
7777
int security_port_sid(u16 domain, u16 type, u8 protocol, u16 port,
7878
u32 *out_sid);
7979

80-
int security_netif_sid(char *name, u32 *if_sid,
81-
u32 *msg_sid);
80+
int security_netif_sid(char *name, u32 *if_sid);
8281

8382
int security_node_sid(u16 domain, void *addr, u32 addrlen,
8483
u32 *out_sid);

0 commit comments

Comments
 (0)