Bug 217509 - [patch] netinet/netinet6: missing curly braces in inm_merge/in6m_merge
Summary: [patch] netinet/netinet6: missing curly braces in inm_merge/in6m_merge
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Enji Cooper
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-03-02 23:20 UTC by Enji Cooper
Modified: 2017-07-18 17:37 UTC (History)
2 users (show)

See Also:
ngie: mfc-stable11+
ngie: mfc-stable10+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2017-03-02 23:20:57 UTC
Filed via internal bugzilla. This will need to be reviewed by someone in net@.

diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c
index 078f2f24536a..c97e36159d01 100644
--- a/sys/netinet/in_mcast.c
+++ b/sys/netinet/in_mcast.c
@@ -1058,9 +1058,10 @@ inm_merge(struct in_multi *inm, /*const*/ struct in_mfilter *imf)
        /* Decrement ASM listener count on transition out of ASM mode. */
        if (imf->imf_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
                if ((imf->imf_st[1] != MCAST_EXCLUDE) ||
-                   (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
+                   (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
                        CTR1(KTR_IGMPV3, "%s: --asm on inm at t1", __func__);
                        --inm->inm_st[1].iss_asm;
+               }
        }

        /* Increment ASM listener count on transition to ASM mode. */
diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c
index 4effb57d0391..b34d02cf35ad 100644
--- a/sys/netinet6/in6_mcast.c
+++ b/sys/netinet6/in6_mcast.c
@@ -999,9 +999,10 @@ in6m_merge(struct in6_multi *inm, /*const*/ struct in6_mfilter *imf)
        /* Decrement ASM listener count on transition out of ASM mode. */
        if (imf->im6f_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
                if ((imf->im6f_st[1] != MCAST_EXCLUDE) ||
-                   (imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
+                   (imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
                        CTR1(KTR_MLD, "%s: --asm on inm at t1", __func__);
                        --inm->in6m_st[1].iss_asm;
+               }
        }

        /* Increment ASM listener count on transition to ASM mode. */

Add missing braces around MCAST_EXCLUDE check so .iss_asm (the number of ASM listeners) isn't incorrectly decremented when dealing with MLD-layer source datagrams when inspecting im*s_st[1] (the second state in the structure).

Reported by: Coverity
Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com>
Sponsored by: Dell EMC Isilon
Comment 1 Andrey V. Elsukov freebsd_committer freebsd_triage 2017-03-04 21:06:53 UTC
The patch looks correct to me.
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2017-03-05 04:45:33 UTC
(In reply to Andrey V. Elsukov from comment #1)

Ok. Is the proposed message accurate, or could it be improved (I wrote it up based on a quick glance at the code -- it might not be accurate).

Thanks!
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-05-13 18:42:06 UTC
A commit references this bug:

Author: ngie
Date: Sat May 13 18:41:25 UTC 2017
New revision: 318255
URL: https://svnweb.freebsd.org/changeset/base/318255

Log:
  Add missing braces around MCAST_EXCLUDE check when KTR support is
  compiled into the kernel

  This ensures that .iss_asm (the number of ASM listeners) isn't incorrectly
  decremented for MLD-layer source datagrams when inspecting im*s_st[1]
  (the second state in the structure).

  MFC after:	2 months
  PR:		217509 [1]
  Reported by:	Coverity (Isilon)
  Reviewed by:	ae ("This patch looks correct to me." [1])
  Submitted by:	Miles Ohlrich <miles.ohlrich@isilon.com>
  Sponsored by:	Dell EMC Isilon

Changes:
  head/sys/netinet/in_mcast.c
  head/sys/netinet6/in6_mcast.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-07-18 16:59:58 UTC
A commit references this bug:

Author: ngie
Date: Tue Jul 18 16:58:53 UTC 2017
New revision: 321134
URL: https://svnweb.freebsd.org/changeset/base/321134

Log:
  MFC r318255:

  Add missing braces around MCAST_EXCLUDE check when KTR support is
  compiled into the kernel

  This ensures that .iss_asm (the number of ASM listeners) isn't incorrectly
  decremented for MLD-layer source datagrams when inspecting im*s_st[1]
  (the second state in the structure).

  PR:		217509 [1]

Changes:
_U  stable/10/
  stable/10/sys/netinet/in_mcast.c
  stable/10/sys/netinet6/in6_mcast.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-07-18 17:00:00 UTC
A commit references this bug:

Author: ngie
Date: Tue Jul 18 16:58:55 UTC 2017
New revision: 321135
URL: https://svnweb.freebsd.org/changeset/base/321135

Log:
  MFC r318255:

  Add missing braces around MCAST_EXCLUDE check when KTR support is
  compiled into the kernel

  This ensures that .iss_asm (the number of ASM listeners) isn't incorrectly
  decremented for MLD-layer source datagrams when inspecting im*s_st[1]
  (the second state in the structure).

  PR:		217509 [1]

Changes:
_U  stable/11/
  stable/11/sys/netinet/in_mcast.c
  stable/11/sys/netinet6/in6_mcast.c