1. 25 Jul, 2020 12 commits
    • Tom Parkin's avatar
      l2tp: WARN_ON rather than BUG_ON in l2tp_session_queue_purge · 493048f5
      Tom Parkin authored
      l2tp_session_queue_purge is used during session shutdown to drop any
      skbs queued for reordering purposes according to L2TP dataplane rules.
      
      The BUG_ON in this function checks the session magic feather in an
      attempt to catch lifetime bugs.
      
      Rather than crashing the kernel with a BUG_ON, we can simply WARN_ON and
      refuse to do anything more -- in the worst case this could result in a
      leak.  However this is highly unlikely given that the session purge only
      occurs from codepaths which have obtained the session by means of a lookup
      via. the parent tunnel and which check the session "dead" flag to
      protect against shutdown races.
      
      While we're here, have l2tp_session_queue_purge return void rather than
      an integer, since neither of the callsites checked the return value.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      493048f5
    • Tom Parkin's avatar
      l2tp: don't BUG_ON seqfile checks in l2tp_ppp · ebb4f5e6
      Tom Parkin authored
      checkpatch advises that WARN_ON and recovery code are preferred over
      BUG_ON which crashes the kernel.
      
      l2tp_ppp has a BUG_ON check of struct seq_file's private pointer in
      pppol2tp_seq_start prior to accessing data through that pointer.
      
      Rather than crashing, we can simply bail out early and return NULL in
      order to terminate the seq file processing in much the same way as we do
      when reaching the end of tunnel/session instances to render.
      
      Retain a WARN_ON to help trace possible bugs in this area.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ebb4f5e6
    • Tom Parkin's avatar
      l2tp: don't BUG_ON session magic checks in l2tp_ppp · 1aa646ac
      Tom Parkin authored
      checkpatch advises that WARN_ON and recovery code are preferred over
      BUG_ON which crashes the kernel.
      
      l2tp_ppp.c's BUG_ON checks of the l2tp session structure's "magic" field
      occur in code paths where it's reasonably easy to recover:
      
       * In the case of pppol2tp_sock_to_session, we can return NULL and the
         caller will bail out appropriately.  There is no change required to
         any of the callsites of this function since they already handle
         pppol2tp_sock_to_session returning NULL.
      
       * In the case of pppol2tp_session_destruct we can just avoid
         decrementing the reference count on the suspect session structure.
         In the worst case scenario this results in a memory leak, which is
         preferable to a crash.
      
      Convert these uses of BUG_ON to WARN_ON accordingly.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1aa646ac
    • Tom Parkin's avatar
      l2tp: remove BUG_ON in l2tp_tunnel_closeall · cd3e29b3
      Tom Parkin authored
      l2tp_tunnel_closeall is only called from l2tp_core.c, and it's easy
      to statically analyse the code path calling it to validate that it
      should never be passed a NULL tunnel pointer.
      
      Having a BUG_ON checking the tunnel pointer triggers a checkpatch
      warning.  Since the BUG_ON is of no value, remove it to avoid the
      warning.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cd3e29b3
    • Tom Parkin's avatar
      l2tp: remove BUG_ON in l2tp_session_queue_purge · ce2f86ae
      Tom Parkin authored
      l2tp_session_queue_purge is only called from l2tp_core.c, and it's easy
      to statically analyse the code paths calling it to validate that it
      should never be passed a NULL session pointer.
      
      Having a BUG_ON checking the session pointer triggers a checkpatch
      warning.  Since the BUG_ON is of no value, remove it to avoid the
      warning.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ce2f86ae
    • Tom Parkin's avatar
      l2tp: WARN_ON rather than BUG_ON in l2tp_dfs_seq_start · 7a379558
      Tom Parkin authored
      l2tp_dfs_seq_start had a BUG_ON to catch a possible programming error in
      l2tp_dfs_seq_open.
      
      Since we can easily bail out of l2tp_dfs_seq_start, prefer to do that
      and flag the error with a WARN_ON rather than crashing the kernel.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7a379558
    • Tom Parkin's avatar
      l2tp: avoid multiple assignments · 95075150
      Tom Parkin authored
      checkpatch warns about multiple assignments.
      
      Update l2tp accordingly.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      95075150
    • David S. Miller's avatar
      Merge branch 'icmp6-support-rfc-4884' · fb92f57b
      David S. Miller authored
      Willem de Bruijn says:
      
      ====================
      icmp6: support rfc 4884
      
      Extend the feature merged earlier this week for IPv4 to IPv6.
      
      I expected this to be a single patch, but patch 1 seemed better to be
      stand-alone
      
      patch 1: small fix in length calculation
      patch 2: factor out ipv4-specific
      patch 3: add ipv6
      
      changes v1->v2: add missing static keyword in patch 3
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fb92f57b
    • Willem de Bruijn's avatar
      icmp6: support rfc 4884 · 01370434
      Willem de Bruijn authored
      Extend the rfc 4884 read interface introduced for ipv4 in
      commit eba75c58 ("icmp: support rfc 4884") to ipv6.
      
      Add socket option SOL_IPV6/IPV6_RECVERR_RFC4884.
      
      Changes v1->v2:
        - make ipv6_icmp_error_rfc4884 static (file scope)
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      01370434
    • Willem de Bruijn's avatar
      icmp: prepare rfc 4884 for ipv6 · 178c49d9
      Willem de Bruijn authored
      The RFC 4884 spec is largely the same between IPv4 and IPv6.
      Factor out the IPv4 specific parts in preparation for IPv6 support:
      
      - icmp types supported
      
      - icmp header size, and thus offset to original datagram start
      
      - datagram length field offset in icmp(6)hdr.
      
      - datagram length field word size: 4B for IPv4, 8B for IPv6.
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      178c49d9
    • Willem de Bruijn's avatar
      icmp: revise rfc4884 tests · c4e9e09f
      Willem de Bruijn authored
      1) Only accept packets with original datagram len field >= header len.
      
      The extension header must start after the original datagram headers.
      The embedded datagram len field is compared against the 128B minimum
      stipulated by RFC 4884. It is unlikely that headers extend beyond
      this. But as we know the exact header length, check explicitly.
      
      2) Remove the check that datagram length must be <= 576B.
      
      This is a send constraint. There is no value in testing this on rx.
      Within private networks it may be known safe to send larger packets.
      Process these packets.
      
      This test was also too lax. It compared original datagram length
      rather than entire icmp packet length. The stand-alone fix would be:
      
        -       if (hlen + skb->len > 576)
        +       if (-skb_network_offset(skb) + skb->len > 576)
      
      Fixes: eba75c58 ("icmp: support rfc 4884")
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c4e9e09f
    • Colin Ian King's avatar
      sctp: remove redundant initialization of variable status · 623b57be
      Colin Ian King authored
      The variable status is being initialized with a value that is never read
      and it is being updated later with a new value.  The initialization is
      redundant and can be removed.  Also put the variable declarations into
      reverse christmas tree order.
      
      Addresses-Coverity: ("Unused value")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      623b57be
  2. 24 Jul, 2020 28 commits