From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Jon Maloy <jon.maloy@ericsson.com>,
Allan Stephens <allan.stephens@windriver.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2] tipc: potential divide by zero in tipc_link_recv_fragment()
Date: Mon, 6 May 2013 21:49:46 +0300 [thread overview]
Message-ID: <20130506184946.GA1360@mwanda> (raw)
In-Reply-To: <5187F8BD.1080900@cogentembedded.com>
On Mon, May 06, 2013 at 10:38:53PM +0400, Sergei Shtylyov wrote:
> Hello.
>
> On 06-05-2013 22:29, Dan Carpenter wrote:
>
> >The worry here is that fragm_sz could be zero since it comes from
> >skb->data.
>
> >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> >diff --git a/net/tipc/link.c b/net/tipc/link.c
> >index 3a6064b3..de94493 100644
> >--- a/net/tipc/link.c
> >+++ b/net/tipc/link.c
> >@@ -2524,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
> > struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
> > u32 msg_sz = msg_size(imsg);
> > u32 fragm_sz = msg_data_sz(fragm);
> >- u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
> >+ u32 exp_fragm_cnt;
> > u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
> >+
> > if (msg_type(imsg) == TIPC_MCAST_MSG)
> > max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
> >- if (msg_size(imsg) > max) {
> >+ if (fragm_sz == 0 || msg_size(imsg) > max) {
> > kfree_skb(fbuf);
> > return 0;
> > }
> >+ exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
>
> Don't you think spaces around / should be added at least for
> consistency with %?
Yep. I missed that. I'll resend.
regards,
dan carpenter
next prev parent reply other threads:[~2013-05-06 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 18:29 [patch 2/2] tipc: potential divide by zero in tipc_link_recv_fragment() Dan Carpenter
2013-05-06 18:38 ` Sergei Shtylyov
2013-05-06 18:49 ` Dan Carpenter [this message]
2013-05-06 19:31 ` [patch 2/2 v2] " Dan Carpenter
2013-05-06 20:17 ` David Miller
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=20130506184946.GA1360@mwanda \
--to=dan.carpenter@oracle.com \
--cc=allan.stephens@windriver.com \
--cc=davem@davemloft.net \
--cc=jon.maloy@ericsson.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=tipc-discussion@lists.sourceforge.net \
/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).