From: marcelo.leitner@gmail.com
To: linux-sctp@vger.kernel.org
Subject: Re: sctp: Add GSO support
Date: Mon, 06 Jun 2016 20:26:49 +0000 [thread overview]
Message-ID: <20160606202649.GE22680@localhost.localdomain> (raw)
In-Reply-To: <20160606201646.GA5425@mwanda>
Hi Dan,
On Mon, Jun 06, 2016 at 11:16:46PM +0300, Dan Carpenter wrote:
> Hello Marcelo Ricardo Leitner,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 90017accff61: "sctp: Add GSO support" from Jun 2, 2016,
> leads to the following Smatch complaint:
>
> net/sctp/output.c:122 sctp_packet_config()
> error: we previously assumed 'asoc' could be null (see line 94)
>
> net/sctp/output.c
> 93
> 94 if (asoc && tp->dst) {
> ^^^^
> New test.
>
> 95 struct sock *sk = asoc->base.sk;
> 96
> 97 rcu_read_lock();
> 98 if (__sk_dst_get(sk) != tp->dst) {
> 99 dst_hold(tp->dst);
> 100 sk_setup_caps(sk, tp->dst);
> 101 }
> 102
> 103 if (sk_can_gso(sk)) {
> 104 struct net_device *dev = tp->dst->dev;
> 105
> 106 packet->max_size = dev->gso_max_size;
> 107 } else {
> 108 packet->max_size = asoc->pathmtu;
> 109 }
> 110 rcu_read_unlock();
> 111
> 112 } else {
> 113 packet->max_size = tp->pathmtu;
> 114 }
> 115
> 116 if (ecn_capable && sctp_packet_empty(packet)) {
> 117 struct sctp_chunk *chunk;
> 118
> 119 /* If there a is a prepend chunk stick it on the list before
> 120 * any other chunks get appended.
> 121 */
> 122 chunk = sctp_get_ecne_prepend(asoc);
> ^^^^
> New unchecked dereference. It's possible that maybe checking
> ecn_capable and sctp_packet_empty() implies that "asoc" is non-NULL but
> it's not obvious from a glance. Anyway, just let me know if that's the
> case.
>
> 123 if (chunk)
> 124 sctp_packet_append_chunk(packet, chunk);
>
Thanks for the report.
It's a false-positive, I think. Is there a way that we can avoid the
warning without changing the code? I could add a check in there, like
'if (ecn_capable && asoc && ..' just to clear this but wouldn't like to
do it.
False-positive because ecn_capable cannot be true without an asoc, so
checking ecn_capable is enough to know that asoc is there too, as in:
$ git grep -A 1 sctp_packet_config
output.c:void sctp_packet_config(struct sctp_packet *packet, __u32 vtag,
output.c- int ecn_capable)
--
outqueue.c: sctp_packet_config(packet, vtag,
outqueue.c-
asoc->peer.ecn_capable);
--
outqueue.c: sctp_packet_config(&singleton, vtag, 0);
outqueue.c- sctp_packet_append_chunk(&singleton,
chunk);
--
outqueue.c: sctp_packet_config(packet, vtag,
outqueue.c-
asoc->peer.ecn_capable);
--
outqueue.c: sctp_packet_config(packet, vtag,
outqueue.c-
asoc->peer.ecn_capable);
--
sm_statefuns.c: sctp_packet_config(packet, vtag, 0);
sm_statefuns.c-
and in all these cases, asoc was verified already. Unless the tool can
do such check across the call stack and I missed something in it..
Regards,
Marcelo
next prev parent reply other threads:[~2016-06-06 20:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 20:16 sctp: Add GSO support Dan Carpenter
2016-06-06 20:26 ` marcelo.leitner [this message]
2016-06-06 20:42 ` Dan Carpenter
2016-06-06 21:07 ` marcelo.leitner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160606202649.GE22680@localhost.localdomain \
--to=marcelo.leitner@gmail.com \
--cc=linux-sctp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).