]> git.baikalelectronics.ru Git - kernel.git/commit
cipso,calipso: resolve a number of problems with the DOI refcounts
authorPaul Moore <paul@paul-moore.com>
Thu, 4 Mar 2021 21:29:51 +0000 (16:29 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Mar 2021 23:26:57 +0000 (15:26 -0800)
commita841a4a8083da094f632a52e826f5ca00a50fae5
tree3f3646f6f025a9f2f2701773053ad4fe378e207e
parent2be6fa576774ade535bf8c1ca6041fb3331b8b03
cipso,calipso: resolve a number of problems with the DOI refcounts

The current CIPSO and CALIPSO refcounting scheme for the DOI
definitions is a bit flawed in that we:

1. Don't correctly match gets/puts in netlbl_cipsov4_list().
2. Decrement the refcount on each attempt to remove the DOI from the
   DOI list, only removing it from the list once the refcount drops
   to zero.

This patch fixes these problems by adding the missing "puts" to
netlbl_cipsov4_list() and introduces a more conventional, i.e.
not-buggy, refcounting mechanism to the DOI definitions.  Upon the
addition of a DOI to the DOI list, it is initialized with a refcount
of one, removing a DOI from the list removes it from the list and
drops the refcount by one; "gets" and "puts" behave as expected with
respect to refcounts, increasing and decreasing the DOI's refcount by
one.

Fixes: 06125f9610a0 ("netlabel: Replace protocol/NetLabel linking with refrerence counts")
Fixes: 356af1a7d047 ("netlabel: Add support for removing a CALIPSO DOI.")
Reported-by: syzbot+9ec037722d2603a9f52e@syzkaller.appspotmail.com
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/cipso_ipv4.c
net/ipv6/calipso.c
net/netlabel/netlabel_cipso_v4.c