08 Jun, 2007

1 commit

  • Currently we check for permission before deleting entries from SAD and
    SPD, (see security_xfrm_policy_delete() security_xfrm_state_delete())
    However we are not checking for authorization when flushing the SPD and
    the SAD completely. It was perhaps missed in the original security hooks
    patch.

    This patch adds a security check when flushing entries from the SAD and
    SPD. It runs the entire database and checks each entry for a denial.
    If the process attempting the flush is unable to remove all of the
    entries a denial is logged the the flush function returns an error
    without removing anything.

    This is particularly useful when a process may need to create or delete
    its own xfrm entries used for things like labeled networking but that
    same process should not be able to delete other entries or flush the
    entire database.

    Signed-off-by: Joy Latten
    Signed-off-by: Eric Paris
    Signed-off-by: James Morris

    Joy Latten
     

31 May, 2007

1 commit


05 May, 2007

2 commits


30 Apr, 2007

1 commit

  • On MIPv6 usage, XFRM sub policy is enabled.
    When main (IPsec) and sub (MIPv6) policy selectors have the same
    address set but different upper layer information (i.e. protocol
    number and its ports or type/code), multiple bundle should be created.
    However, currently we have issue to use the same bundle created for
    the first time with all flows covered by the case.

    It is useful for the bundle to have the upper layer information
    to be restructured correctly if it does not match with the flow.

    1. Bundle was created by two policies
    Selector from another policy is added to xfrm_dst.
    If the flow does not match the selector, it goes to slow path to
    restructure new bundle by single policy.

    2. Bundle was created by one policy
    Flow cache is added to xfrm_dst as originated one. If the flow does
    not match the cache, it goes to slow path to try searching another
    policy.

    Signed-off-by: Masahide NAKAMURA
    Signed-off-by: David S. Miller

    Masahide NAKAMURA
     

29 Apr, 2007

1 commit


26 Apr, 2007

2 commits

  • On a system with a lot of SAs, counting SAD entries chews useful
    CPU time since you need to dump the whole SAD to user space;
    i.e something like ip xfrm state ls | grep -i src | wc -l
    I have seen taking literally minutes on a 40K SAs when the system
    is swapping.
    With this patch, some of the SAD info (that was already being tracked)
    is exposed to user space. i.e you do:
    ip xfrm state count
    And you get the count; you can also pass -s to the command line and
    get the hash info.

    Signed-off-by: Jamal Hadi Salim
    Signed-off-by: David S. Miller

    Jamal Hadi Salim
     
  • Replace the probing based MTU estimation, which usually takes 2-3 iterations
    to find a fitting value and may underestimate the MTU, by an exact calculation.

    Also fix underestimation of the XFRM trailer_len, which causes unnecessary
    reallocations.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     

08 Mar, 2007

1 commit

  • The security hooks to check permissions to remove an xfrm_policy were
    actually done after the policy was removed. Since the unlinking and
    deletion are done in xfrm_policy_by* functions this moves the hooks
    inside those 2 functions. There we have all the information needed to
    do the security check and it can be done before the deletion. Since
    auditing requires the result of that security check err has to be passed
    back and forth from the xfrm_policy_by* functions.

    This patch also fixes a bug where a deletion that failed the security
    check could cause improper accounting on the xfrm_policy
    (xfrm_get_policy didn't have a put on the exit path for the hold taken
    by xfrm_policy_by*)

    It also fixes the return code when no policy is found in
    xfrm_add_pol_expire. In old code (at least back in the 2.6.18 days) err
    wasn't used before the return when no policy is found and so the
    initialization would cause err to be ENOENT. But since err has since
    been used above when we don't get a policy back from the xfrm_policy_by*
    function we would always return 0 instead of the intended ENOENT. Also
    fixed some white space damage in the same area.

    Signed-off-by: Eric Paris
    Acked-by: Venkat Yekkirala
    Acked-by: James Morris
    Signed-off-by: David S. Miller

    Eric Paris
     

14 Feb, 2007

2 commits


09 Feb, 2007

2 commits

  • Extend the XFRM framework so that endpoint address(es) in the XFRM
    databases could be dynamically updated according to a request (MIGRATE
    message) from user application. Target XFRM policy is first identified
    by the selector in the MIGRATE message. Next, the endpoint addresses
    of the matching templates and XFRM states are updated according to
    the MIGRATE message.

    Signed-off-by: Shinta Sugimoto
    Signed-off-by: Masahide NAKAMURA
    Signed-off-by: YOSHIFUJI Hideaki
    Signed-off-by: David S. Miller

    Shinta Sugimoto
     
  • This patch exports xfrm_state_afinfo.

    Signed-off-by: Miika Komu
    Signed-off-by: Diego Beltrami
    Signed-off-by: Kazunori Miyazawa
    Signed-off-by: David S. Miller

    Miika Komu
     

07 Dec, 2006

2 commits


03 Dec, 2006

7 commits

  • Signed-off-by: Miika Komu
    Signed-off-by: Diego Beltrami
    Signed-off-by: Kazunori Miyazawa
    Signed-off-by: David S. Miller

    Miika Komu
     
  • [acme@newtoy net-2.6.20]$ pahole net/ipv4/tcp.o xfrm_policy
    /* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/linux/security.h:67 */
    struct xfrm_policy {
    struct xfrm_policy * next; /* 0 4 */
    struct hlist_node bydst; /* 4 8 */
    struct hlist_node byidx; /* 12 8 */
    rwlock_t lock; /* 20 36 */
    atomic_t refcnt; /* 56 4 */
    struct timer_list timer; /* 60 24 */
    u8 type; /* 84 1 */

    /* XXX 3 bytes hole, try to pack */

    u32 priority; /* 88 4 */
    u32 index; /* 92 4 */
    struct xfrm_selector selector; /* 96 56 */
    struct xfrm_lifetime_cfg lft; /* 152 64 */
    struct xfrm_lifetime_cur curlft; /* 216 32 */
    struct dst_entry * bundles; /* 248 4 */
    __u16 family; /* 252 2 */
    __u8 action; /* 254 1 */
    __u8 flags; /* 255 1 */
    __u8 dead; /* 256 1 */
    __u8 xfrm_nr; /* 257 1 */

    /* XXX 2 bytes hole, try to pack */

    struct xfrm_sec_ctx * security; /* 260 4 */
    struct xfrm_tmpl xfrm_vec[6]; /* 264 360 */
    }; /* size: 624, sum members: 619, holes: 2, sum holes: 5 */

    So lets have just one hole instead of two, by moving 'type' to just before 'action',
    end result:

    [acme@newtoy net-2.6.20]$ codiff -s /tmp/tcp.o.before net/ipv4/tcp.o
    /pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv4/tcp.c:
    struct xfrm_policy | -4
    1 struct changed
    [acme@newtoy net-2.6.20]$

    [acme@newtoy net-2.6.20]$ pahole -c 64 net/ipv4/tcp.o xfrm_policy
    /* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/linux/security.h:67 */
    struct xfrm_policy {
    struct xfrm_policy * next; /* 0 4 */
    struct hlist_node bydst; /* 4 8 */
    struct hlist_node byidx; /* 12 8 */
    rwlock_t lock; /* 20 36 */
    atomic_t refcnt; /* 56 4 */
    struct timer_list timer; /* 60 24 */
    u32 priority; /* 84 4 */
    u32 index; /* 88 4 */
    struct xfrm_selector selector; /* 92 56 */
    struct xfrm_lifetime_cfg lft; /* 148 64 */
    struct xfrm_lifetime_cur curlft; /* 212 32 */
    struct dst_entry * bundles; /* 244 4 */
    u16 family; /* 248 2 */
    u8 type; /* 250 1 */
    u8 action; /* 251 1 */
    u8 flags; /* 252 1 */
    u8 dead; /* 253 1 */
    u8 xfrm_nr; /* 254 1 */

    /* XXX 1 byte hole, try to pack */

    struct xfrm_sec_ctx * security; /* 256 4 */
    struct xfrm_tmpl xfrm_vec[6]; /* 260 360 */
    }; /* size: 620, sum members: 619, holes: 1, sum holes: 1 */

    Are there any fugly data dependencies here? None that I know.

    In the process changed the removed the __ prefixed types, that are just for
    userspace visible headers.

    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • This is a revision of the previously submitted patch, which alters
    the way files are organized and compiled in the following manner:

    * UDP and UDP-Lite now use separate object files
    * source file dependencies resolved via header files
    net/ipv{4,6}/udp_impl.h
    * order of inclusion files in udp.c/udplite.c adapted
    accordingly

    [NET/IPv4]: Support for the UDP-Lite protocol (RFC 3828)

    This patch adds support for UDP-Lite to the IPv4 stack, provided as an
    extension to the existing UDPv4 code:
    * generic routines are all located in net/ipv4/udp.c
    * UDP-Lite specific routines are in net/ipv4/udplite.c
    * MIB/statistics support in /proc/net/snmp and /proc/net/udplite
    * shared API with extensions for partial checksum coverage

    [NET/IPv6]: Extension for UDP-Lite over IPv6

    It extends the existing UDPv6 code base with support for UDP-Lite
    in the same manner as per UDPv4. In particular,
    * UDPv6 generic and shared code is in net/ipv6/udp.c
    * UDP-Litev6 specific extensions are in net/ipv6/udplite.c
    * MIB/statistics support in /proc/net/snmp6 and /proc/net/udplite6
    * support for IPV6_ADDRFORM
    * aligned the coding style of protocol initialisation with af_inet6.c
    * made the error handling in udpv6_queue_rcv_skb consistent;
    to return `-1' on error on all error cases
    * consolidation of shared code

    [NET]: UDP-Lite Documentation and basic XFRM/Netfilter support

    The UDP-Lite patch further provides
    * API documentation for UDP-Lite
    * basic xfrm support
    * basic netfilter support for IPv4 and IPv6 (LOG target)

    Signed-off-by: Gerrit Renker
    Signed-off-by: David S. Miller

    Gerrit Renker
     
  • Six callsites, huge.

    Signed-off-by: Andrew Morton
    Signed-off-by: David S. Miller

    Andrew Morton
     
  • Signed-off-by: Al Viro
    Signed-off-by: David S. Miller

    Al Viro
     
  • Signed-off-by: Al Viro
    Signed-off-by: David S. Miller

    Al Viro
     
  • Signed-off-by: Al Viro
    Signed-off-by: David S. Miller

    Al Viro
     

12 Oct, 2006

1 commit

  • Currently when an IPSec policy rule doesn't specify a security
    context, it is assumed to be "unlabeled" by SELinux, and so
    the IPSec policy rule fails to match to a flow that it would
    otherwise match to, unless one has explicitly added an SELinux
    policy rule allowing the flow to "polmatch" to the "unlabeled"
    IPSec policy rules. In the absence of such an explicitly added
    SELinux policy rule, the IPSec policy rule fails to match and
    so the packet(s) flow in clear text without the otherwise applicable
    xfrm(s) applied.

    The above SELinux behavior violates the SELinux security notion of
    "deny by default" which should actually translate to "encrypt by
    default" in the above case.

    This was first reported by Evgeniy Polyakov and the way James Morris
    was seeing the problem was when connecting via IPsec to a
    confined service on an SELinux box (vsftpd), which did not have the
    appropriate SELinux policy permissions to send packets via IPsec.

    With this patch applied, SELinux "polmatching" of flows Vs. IPSec
    policy rules will only come into play when there's a explicit context
    specified for the IPSec policy rule (which also means there's corresponding
    SELinux policy allowing appropriate domains/flows to polmatch to this context).

    Secondly, when a security module is loaded (in this case, SELinux), the
    security_xfrm_policy_lookup() hook can return errors other than access denied,
    such as -EINVAL. We were not handling that correctly, and in fact
    inverting the return logic and propagating a false "ok" back up to
    xfrm_lookup(), which then allowed packets to pass as if they were not
    associated with an xfrm policy.

    The solution for this is to first ensure that errno values are
    correctly propagated all the way back up through the various call chains
    from security_xfrm_policy_lookup(), and handled correctly.

    Then, flow_cache_lookup() is modified, so that if the policy resolver
    fails (typically a permission denied via the security module), the flow
    cache entry is killed rather than having a null policy assigned (which
    indicates that the packet can pass freely). This also forces any future
    lookups for the same flow to consult the security module (e.g. SELinux)
    for current security policy (rather than, say, caching the error on the
    flow cache entry).

    This patch: Fix the selinux side of things.

    This makes sure SELinux polmatching of flow contexts to IPSec policy
    rules comes into play only when an explicit context is associated
    with the IPSec policy rule.

    Also, this no longer defaults the context of a socket policy to
    the context of the socket since the "no explicit context" case
    is now handled properly.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: James Morris

    Venkat Yekkirala
     

29 Sep, 2006

7 commits


23 Sep, 2006

10 commits