11 Jun, 2008

1 commit

  • When pfkey has no km listeners, it still does a lot of work
    before finding out there aint nobody out there.
    If a tree falls in a forest and no one is around to hear it, does it make
    a sound? In this case it makes a lot of noise:
    With this short-circuit adding 10s of thousands of SAs using
    netlink improves performance by ~10%.

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

    Jamal Hadi Salim
     

22 May, 2008

1 commit


28 Apr, 2008

1 commit

  • Previously I added sessionid output to all audit messages where it was
    available but we still didn't know the sessionid of the sender of
    netlink messages. This patch adds that information to netlink messages
    so we can audit who sent netlink messages.

    Signed-off-by: Eric Paris
    Signed-off-by: Al Viro

    Eric Paris
     

25 Apr, 2008

1 commit

  • net/key/af_key.c: In function ‘pfkey_spddelete’:
    net/key/af_key.c:2359: warning: ‘pol_ctx’ may be used uninitialized in
    this function

    When CONFIG_SECURITY_NETWORK_XFRM isn't set,
    security_xfrm_policy_alloc() is an inline that doesn't set pol_ctx, so
    this seemed like the easiest fix short of using *uninitialized_var(pol_ctx).

    Signed-off-by: Brian Haley
    Signed-off-by: David S. Miller

    Brian Haley
     

22 Apr, 2008

1 commit

  • As it stands it's impossible to use any authentication algorithms
    with an ID above 31 portably. It just happens to work on x86 but
    fails miserably on ppc64.

    The reason is that we're using a bit mask to check the algorithm
    ID but the mask is only 32 bits wide.

    After looking at how this is used in the field, I have concluded
    that in the long term we should phase out state matching by IDs
    because this is made superfluous by the reqid feature. For current
    applications, the best solution IMHO is to allow all algorithms when
    the bit masks are all ~0.

    The following patch does exactly that.

    This bug was identified by IBM when testing on the ppc64 platform
    using the NULL authentication algorithm which has an ID of 251.

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     

13 Apr, 2008

1 commit

  • The xfrm_get_policy() and xfrm_add_pol_expire() put some rather large structs
    on the stack to work around the LSM API. This patch attempts to fix that
    problem by changing the LSM API to require only the relevant "security"
    pointers instead of the entire SPD entry; we do this for all of the
    security_xfrm_policy*() functions to keep things consistent.

    Signed-off-by: Paul Moore
    Acked-by: James Morris
    Signed-off-by: David S. Miller

    Paul Moore
     

28 Mar, 2008

1 commit


25 Mar, 2008

1 commit


04 Mar, 2008

1 commit

  • Stop dumping of entries when af_key socket receive queue is getting
    full and continue it later when there is more room again.

    This fixes dumping of large databases. Currently the entries not
    fitting into the receive queue are just dropped (including the
    end-of-dump message) which can confuse applications.

    Signed-off-by: Timo Teras
    Signed-off-by: David S. Miller

    Timo Teras
     

29 Feb, 2008

1 commit

  • Change xfrm_policy and xfrm_state walking algorithm from O(n^2) to O(n).
    This is achieved adding the entries to one more list which is used
    solely for walking the entries.

    This also fixes some races where the dump can have duplicate or missing
    entries when the SPD/SADB is modified during an ongoing dump.

    Dumping SADB with 20000 entries using "time ip xfrm state" the sys
    time dropped from 1.012s to 0.080s.

    Signed-off-by: Timo Teras
    Signed-off-by: David S. Miller

    Timo Teras
     

27 Feb, 2008

1 commit

  • To make sure the procfs visibility occurs after the ->proc_fs ops are
    setup, use proc_net_fops_create() and proc_net_remove().

    This also fixes an OOPS after module unload in that the name string
    for remove was wrong, so it wouldn't actually be removed. That bug
    was introduced by commit 61145aa1a12401ac71bcc450a58c773dd6e2bfb9
    ("[KEY]: Clean up proc files creation a bit.")

    Signed-off-by: David S. Miller

    David S. Miller
     

15 Feb, 2008

1 commit


10 Feb, 2008

2 commits


02 Feb, 2008

1 commit


29 Jan, 2008

1 commit

  • Since __xfrm_policy_destroy is used to destory the resources
    allocated by xfrm_policy_alloc. So using the name
    __xfrm_policy_destroy is not correspond with xfrm_policy_alloc.
    Rename it to xfrm_policy_destroy.

    And along with some instances that call xfrm_policy_alloc
    but not using xfrm_policy_destroy to destroy the resource,
    fix them.

    Signed-off-by: WANG Cong
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    WANG Cong
     

21 Jan, 2008

1 commit


20 Dec, 2007

1 commit

  • The aalgos/ealgos fields are only 32 bits wide. However, af_key tries
    to test them with the expression 1 << id where id can be as large as
    253. This produces different behaviour on different architectures.

    The following patch explicitly checks whether ID is greater than 31
    and fails the check if that's the case.

    We cannot easily extend the mask to be longer than 32 bits due to
    exposure to user-space. Besides, this whole interface is obsolete
    anyway in favour of the xfrm_user interface which doesn't use this
    bit mask in templates (well not within the kernel anyway).

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     

26 Nov, 2007

1 commit

  • The change 050f009e16f908932070313c1745d09dc69fd62b

    [IPSEC]: Lock state when copying non-atomic fields to user-space

    caused a regression.

    Ingo Molnar reports that it causes a potential dead-lock found by the
    lock validator as it tries to take x->lock within xfrm_state_lock while
    numerous other sites take the locks in opposite order.

    For 2.6.24, the best fix is to simply remove the added locks as that puts
    us back in the same state as we've been in for years. For later kernels
    a proper fix would be to reverse the locking order for every xfrm state
    user such that if x->lock is taken together with xfrm_state_lock then
    it is to be taken within it.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

22 Nov, 2007

1 commit


01 Nov, 2007

1 commit

  • Finally, the zero_it argument can be completely removed from
    the callers and from the function prototype.

    Besides, fix the checkpatch.pl warnings about using the
    assignments inside if-s.

    This patch is rather big, and it is a part of the previous one.
    I splitted it wishing to make the patches more readable. Hope
    this particular split helped.

    Signed-off-by: Pavel Emelyanov
    Signed-off-by: David S. Miller

    Pavel Emelyanov
     

31 Oct, 2007

1 commit


11 Oct, 2007

6 commits

  • This patch adds locking so that when we're copying non-atomic fields such as
    life-time or coaddr to user-space we don't get a partial result.

    For af_key I've changed every instance of pfkey_xfrm_state2msg apart from
    expiration notification to include the keys and life-times. This is in-line
    with XFRM behaviour.

    The actual cases affected are:

    * pfkey_getspi: No change as we don't have any keys to copy.
    * key_notify_sa:
    + ADD/UPD: This wouldn't work otherwise.
    + DEL: It can't hurt.

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     
  • This patch moves some common code that conceptually belongs to the xfrm core
    from af_key/xfrm_user into xfrm_alloc_spi.

    In particular, the spin lock on the state is now taken inside xfrm_alloc_spi.
    Previously it also protected the construction of the response PF_KEY/XFRM
    messages to user-space. This is inconsistent as other identical constructions
    are not protected by the state lock. This is bad because they in fact should
    be protected but only in certain spots (so as not to hold the lock for too
    long which may cause packet drops).

    The SPI byte order conversion has also been moved.

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     
  • This patch passes in the namespace a new socket should be created in
    and has the socket code do the appropriate reference counting. By
    virtue of this all socket create methods are touched. In addition
    the socket create methods are modified so that they will fail if
    you attempt to create a socket in a non-default network namespace.

    Failing if we attempt to create a socket outside of the default
    network namespace ensures that as we incrementally make the network stack
    network namespace aware we will not export functionality that someone
    has not audited and made certain is network namespace safe.
    Allowing us to partially enable network namespaces before all of the
    exotic protocols are supported.

    Any protocol layers I have missed will fail to compile because I now
    pass an extra parameter into the socket creation code.

    [ Integrated AF_IUCV build fixes from Andrew Morton... -DaveM ]

    Signed-off-by: Eric W. Biederman
    Signed-off-by: David S. Miller

    Eric W. Biederman
     
  • This patch makes /proc/net per network namespace. It modifies the global
    variables proc_net and proc_net_stat to be per network namespace.
    The proc_net file helpers are modified to take a network namespace argument,
    and all of their callers are fixed to pass &init_net for that argument.
    This ensures that all of the /proc/net files are only visible and
    usable in the initial network namespace until the code behind them
    has been updated to be handle multiple network namespaces.

    Making /proc/net per namespace is necessary as at least some files
    in /proc/net depend upon the set of network devices which is per
    network namespace, and even more files in /proc/net have contents
    that are relevant to a single network namespace.

    Signed-off-by: Eric W. Biederman
    Signed-off-by: David S. Miller

    Eric W. Biederman
     
  • This patch modifies the current ipsec audit layer
    by breaking it up into purpose driven audit calls.

    So far, the only audit calls made are when add/delete
    an SA/policy. It had been discussed to give each
    key manager it's own calls to do this, but I found
    there to be much redundnacy since they did the exact
    same things, except for how they got auid and sid, so I
    combined them. The below audit calls can be made by any
    key manager. Hopefully, this is ok.

    Signed-off-by: Joy Latten
    Signed-off-by: David S. Miller

    Joy Latten
     
  • Signed-off-by: Ilpo Järvinen
    Signed-off-by: David S. Miller

    Ilpo Järvinen
     

03 Aug, 2007

1 commit

  • Although an ipsec SA was established, kernel couldn't seem to find it.

    I think since we are now using "x->sel.family" instead of "family" in
    the xfrm_selector_match() called in xfrm_state_find(), af_key needs to
    set this field too, just as xfrm_user.

    In af_key.c, x->sel.family only gets set when there's an
    ext_hdrs[SADB_EXT_ADDRESS_PROXY-1] which I think is for tunnel.

    I think pfkey needs to also set the x->sel.family field when it is 0.

    Tested with below patch, and ipsec worked when using pfkey.

    Signed-off-by: David S. Miller

    Joy Latten
     

27 Jul, 2007

1 commit


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
     

20 May, 2007

1 commit

  • This is a natural extension of the changeset

    [XFRM]: Probe selected algorithm only.

    which only removed the probe call for xfrm_user. This patch does exactly
    the same thing for af_key. In other words, we load the algorithm requested
    by the user rather than everything when adding xfrm states in af_key.

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     

26 Apr, 2007

2 commits

  • Spring cleaning time...

    There seems to be a lot of places in the network code that have
    extra bogus semicolons after conditionals. Most commonly is a
    bogus semicolon after: switch() { }

    Signed-off-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    Stephen Hemminger
     
  • For the common, open coded 'skb->h.raw = skb->data' operation, so that we can
    later turn skb->h.raw into a offset, reducing the size of struct sk_buff in
    64bit land while possibly keeping it as a pointer on 32bit.

    This one touches just the most simple cases:

    skb->h.raw = skb->data;
    skb->h.raw = {skb_push|[__]skb_pull}()

    The next ones will handle the slightly more "complex" cases.

    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: David S. Miller

    Arnaldo Carvalho de Melo
     

19 Apr, 2007

1 commit


18 Apr, 2007

1 commit


08 Mar, 2007

3 commits

  • Inside pfkey_delete and xfrm_del_sa the audit hooks were not called if
    there was any permission/security failures in attempting to do the del
    operation (such as permission denied from security_xfrm_state_delete).
    This patch moves the audit hook to the exit path such that all failures
    (and successes) will actually get audited.

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

    Eric Paris
     
  • pfkey_spdget neither had an LSM security hook nor auditing for the
    removal of xfrm_policy structs. The security hook was added when it was
    moved into xfrm_policy_byid instead of the callers to that function by
    my earlier patch and this patch adds the auditing hooks as well.

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

    Eric Paris
     
  • 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
     

13 Feb, 2007

1 commit