All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org, security@kernel.org,
	Henry Hoggard <henry@henryhoggard.co.uk>
Subject: [patch] isdn: avm: potential signedness issue in loading firmware
Date: Fri, 9 May 2014 14:54:37 +0300	[thread overview]
Message-ID: <20140509115437.GA31764@mwanda> (raw)
In-Reply-To: <20140509102724.GF4963@mwanda>

The concern here is that a negative value for "len" could lead underflow
the "while (left > FWBUF_SIZE) {" test and lead to memory corruption.
I do not believe this is possible because we test for negatives in
old_capi_manufacturer(), "if (ldef.t4file.len <= 0) {".

But it sort of makes the code nicer to only deal with positive lengths
so I have made it unsigned.  The length is still not capped and so if we
get a too large value, we keep on writing it out to the firmware byte by
byte until the writes start failing.

Loading the firmware requires CAP_SYS_ADMIN.

Reported-by: Henry Hoggard <henry@henryhoggard.co.uk>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
index 4d9b195..7f2ed49 100644
--- a/drivers/isdn/hardware/avm/b1.c
+++ b/drivers/isdn/hardware/avm/b1.c
@@ -153,7 +153,8 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
 {
 	unsigned char buf[FWBUF_SIZE];
 	unsigned char *dp;
-	int i, left;
+	unsigned int left;
+	int i;
 	unsigned int base = card->port;
 
 	dp = t4file->data;

       reply	other threads:[~2014-05-09 11:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140509102724.GF4963@mwanda>
2014-05-09 11:54 ` Dan Carpenter [this message]
2014-05-09 17:24   ` [patch] isdn: avm: potential signedness issue in loading firmware David Miller
2014-05-09 17:52     ` Dan Carpenter
2014-05-09 19:19       ` 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=20140509115437.GA31764@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=henry@henryhoggard.co.uk \
    --cc=isdn@linux-pingi.de \
    --cc=netdev@vger.kernel.org \
    --cc=security@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.