netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Samuel Ortiz <samuel@sortiz.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, security@kernel.org,
	throber3 <throber3@gmail.com>,
	"程君(成淼)" <chengmiao.cj@alibaba-inc.com>
Subject: [patch] irda: precedence bug in irlmp_seq_hb_idx()
Date: Mon, 19 Oct 2015 13:16:49 +0300	[thread overview]
Message-ID: <20151019101649.GC26688@mwanda> (raw)
In-Reply-To: <----An------QYmAn$4202951b-482d-4d92-98c2-3466de737b40@alibaba-inc.com>

This is decrementing the pointer, instead of the value stored in the
pointer.  KASan detects it as an out of bounds reference.

Reported-by: "Berry Cheng 程君(成淼)" <chengmiao.cj@alibaba-inc.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This bug predates the start of git.  You would think it would have been
reported earlier since it looks like a serious bug.  I cannot test this
so please review carefully.

diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index a26c401..4396459 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -1839,7 +1839,7 @@ static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
 	for (element = hashbin_get_first(iter->hashbin);
 	     element != NULL;
 	     element = hashbin_get_next(iter->hashbin)) {
-		if (!off || *off-- == 0) {
+		if (!off || (*off)-- == 0) {
 			/* NB: hashbin left locked */
 			return element;
 		}

       reply	other threads:[~2015-10-19 10:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <----An------QYmAn$4202951b-482d-4d92-98c2-3466de737b40@alibaba-inc.com>
2015-10-19 10:16 ` Dan Carpenter [this message]
2015-10-21 14:48   ` [patch] irda: precedence bug in irlmp_seq_hb_idx() 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=20151019101649.GC26688@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=chengmiao.cj@alibaba-inc.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=samuel@sortiz.org \
    --cc=security@kernel.org \
    --cc=throber3@gmail.com \
    /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).