All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: netdev@vger.kernel.org
Cc: arvid.brodin@xdin.com
Subject: out of bounds writes in net/hsr/
Date: Mon, 3 Mar 2014 22:27:57 -0500	[thread overview]
Message-ID: <20140304032757.GA19048@redhat.com> (raw)

I found this in coverity, and I think it's a real bug..

hsr_register_frame_in does a check that dev_idx is between 0 and 2,
therefore, a dev_idx of 2 is possible when it gets to the array writes
at the end of the function.  The arrays are defined such..

 26 struct node_entry {
...
 33         unsigned long   time_in[HSR_MAX_SLAVE];
 34         bool            time_in_stale[HSR_MAX_SLAVE];

and HSR_MAX_SLAVE is...

139 enum hsr_dev_idx {
140         HSR_DEV_NONE = -1,
141         HSR_DEV_SLAVE_A = 0,
142         HSR_DEV_SLAVE_B,
143         HSR_DEV_MASTER,
144 };
145 #define HSR_MAX_SLAVE   (HSR_DEV_SLAVE_B + 1)

So we have arrays of 2 bytes, and we can try to write to the 3rd byte.

The problem seems to be that the checking in hsr_register_frame is on
HSR_MAX_DEV which is defined as..

#define HSR_MAX_DEV     (HSR_DEV_MASTER + 1)

The + 1 seems odd, and looking at the other uses of HSR_MAX_DEV, I can't
figure out why it's there.

	Dave

             reply	other threads:[~2014-03-04  3:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04  3:27 Dave Jones [this message]
2014-03-04 16:07 ` out of bounds writes in net/hsr/ Arvid Brodin
2014-03-04 16:30   ` Dave Jones

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=20140304032757.GA19048@redhat.com \
    --to=davej@redhat.com \
    --cc=arvid.brodin@xdin.com \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.