netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: xfrm: policy: add inexact policy search tree infrastructure
@ 2018-11-14 22:26 Colin Ian King
  2018-11-14 22:44 ` Florian Westphal
  2018-11-15  1:51 ` [PATCH ipsec-next] xfrm: policy: fix netlink/pf_key policy lookups Florian Westphal
  0 siblings, 2 replies; 4+ messages in thread
From: Colin Ian King @ 2018-11-14 22:26 UTC (permalink / raw)
  To: Florian Westphal
  Cc: Steffen Klassert, Herbert Xu, David S. Miller,
	netdev@vger.kernel.org

Hi,

Static analysis with CoverityScan found a potential issue with the commit:

commit 6be3b0db6db82cf056a72cc18042048edd27f8ee
Author: Florian Westphal <fw@strlen.de>
Date:   Wed Nov 7 23:00:37 2018 +0100

    xfrm: policy: add inexact policy search tree infrastructure

It seems that pointer pol is set to NULL and then a check to see if it
is non-null is used to set pol to tmp; howeverm this check is always
going to be false because pol is always NULL.

The issue is reported by CoverityScan as follows:

Line
1658
    assignment: Assigning: pol = NULL.
1659                pol = NULL;
1660                for (i = 0; i < ARRAY_SIZE(cand.res); i++) {
1661                        struct xfrm_policy *tmp;
1662
1663                        tmp = __xfrm_policy_bysel_ctx(cand.res[i], mark,
1664                                                      if_id, type, dir,
1665                                                      sel, ctx);

    null: At condition pol, the value of pol must be NULL.
    dead_error_condition: The condition pol cannot be true.

    CID 1475480 (#1 of 1): Logically dead code

(DEADCODE) dead_error_line: Execution cannot reach the expression
tmp->pos < pol->pos inside this statement: if (tmp && pol && tmp->pos ....

1666                        if (tmp && pol && tmp->pos < pol->pos)
1667                                pol = tmp;
1668                }


I suspect this is not intentional and is probably a bug.

Colin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-20 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-14 22:26 xfrm: policy: add inexact policy search tree infrastructure Colin Ian King
2018-11-14 22:44 ` Florian Westphal
2018-11-15  1:51 ` [PATCH ipsec-next] xfrm: policy: fix netlink/pf_key policy lookups Florian Westphal
2018-11-20  7:36   ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).