Skip to content

Commit

Permalink
SELinux: Convert the netif code to use ifindex values
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
pcmoore authored and James Morris committed Jan 29, 2008
1 parent 75e2291 commit e8bfdb9
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 125 deletions.
4 changes: 2 additions & 2 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3853,7 +3853,7 @@ static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
if (!skb->dev)
goto out;

err = sel_netif_sids(skb->dev, &if_sid, NULL);
err = sel_netif_sid(skb->iif, &if_sid);
if (err)
goto out;

Expand Down Expand Up @@ -4178,7 +4178,7 @@ static int selinux_ip_postroute_last_compat(struct sock *sk, struct net_device *

isec = inode->i_security;

err = sel_netif_sids(dev, &if_sid, NULL);
err = sel_netif_sid(dev->ifindex, &if_sid);
if (err)
goto out;

Expand Down
4 changes: 3 additions & 1 deletion security/selinux/include/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Author: James Morris <[email protected]>
*
* Copyright (C) 2003 Red Hat, Inc., James Morris <[email protected]>
* Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
* Paul Moore, <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand All @@ -15,7 +17,7 @@
#ifndef _SELINUX_NETIF_H_
#define _SELINUX_NETIF_H_

int sel_netif_sids(struct net_device *dev, u32 *if_sid, u32 *msg_sid);
int sel_netif_sid(int ifindex, u32 *sid);

#endif /* _SELINUX_NETIF_H_ */

5 changes: 2 additions & 3 deletions security/selinux/include/objsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ struct bprm_security_struct {
};

struct netif_security_struct {
struct net_device *dev; /* back pointer */
u32 if_sid; /* SID for this interface */
u32 msg_sid; /* default SID for messages received on this interface */
int ifindex; /* device index */
u32 sid; /* SID for this interface */
};

struct sk_security_struct {
Expand Down
3 changes: 1 addition & 2 deletions security/selinux/include/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ int security_get_user_sids(u32 callsid, char *username,
int security_port_sid(u16 domain, u16 type, u8 protocol, u16 port,
u32 *out_sid);

int security_netif_sid(char *name, u32 *if_sid,
u32 *msg_sid);
int security_netif_sid(char *name, u32 *if_sid);

int security_node_sid(u16 domain, void *addr, u32 addrlen,
u32 *out_sid);
Expand Down
Loading

0 comments on commit e8bfdb9

Please sign in to comment.