Skip to content

Commit

Permalink
[PATCH] Fix buffer overflow and races in capi debug functions
Browse files Browse the repository at this point in the history
The CAPI trace debug functions were using a fixed size buffer, which can be
overflowed if wrong formatted CAPI messages were sent to the kernel capi
layer.  The code was also not protected against multiple callers.  This fix
bug 8028.

Additionally the patch make the CAPI trace functions optional.

Signed-off-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Karsten Keil authored and Linus Torvalds committed Mar 1, 2007
1 parent 34bbd70 commit 17f0cd2
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 78 deletions.
16 changes: 14 additions & 2 deletions drivers/isdn/capi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
# Config.in for the CAPI subsystem
#
config ISDN_DRV_AVMB1_VERBOSE_REASON
bool "Verbose reason code reporting (kernel size +=7K)"
bool "Verbose reason code reporting"
depends on ISDN_CAPI
default y
help
If you say Y here, the AVM B1 driver will give verbose reasons for
If you say Y here, the CAPI drivers will give verbose reasons for
disconnecting. This will increase the size of the kernel by 7 KB. If
unsure, say Y.

config CAPI_TRACE
bool "CAPI trace support"
depends on ISDN_CAPI
default y
help
If you say Y here, the kernelcapi driver can make verbose traces
of CAPI messages. This feature can be enabled/disabled via IOCTL for
every controler (default disabled).
This will increase the size of the kernelcapi module by 20 KB.
If unsure, say Y.

config ISDN_CAPI_MIDDLEWARE
bool "CAPI2.0 Middleware support (EXPERIMENTAL)"
depends on ISDN_CAPI && EXPERIMENTAL
Expand Down
28 changes: 22 additions & 6 deletions drivers/isdn/capi/capidrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ static void handle_plci(_cmsg * cmsg)
capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f);
capidrv_plci *plcip;
isdn_ctrl cmd;
_cdebbuf *cdb;

if (!card) {
printk(KERN_ERR "capidrv: %s from unknown controller 0x%x\n",
Expand Down Expand Up @@ -1122,8 +1123,15 @@ static void handle_plci(_cmsg * cmsg)
break;
}
}
printk(KERN_ERR "capidrv-%d: %s\n",
card->contrnr, capi_cmsg2str(cmsg));
cdb = capi_cmsg2str(cmsg);
if (cdb) {
printk(KERN_WARNING "capidrv-%d: %s\n",
card->contrnr, cdb->buf);
cdebbuf_free(cdb);
} else
printk(KERN_WARNING "capidrv-%d: CAPI_INFO_IND InfoNumber %x not handled\n",
card->contrnr, cmsg->InfoNumber);

break;

case CAPI_CONNECT_ACTIVE_CONF: /* plci */
Expand Down Expand Up @@ -1371,10 +1379,18 @@ static _cmsg s_cmsg;
static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb)
{
capi_message2cmsg(&s_cmsg, skb->data);
if (debugmode > 3)
printk(KERN_DEBUG "capidrv_signal: applid=%d %s\n",
ap->applid, capi_cmsg2str(&s_cmsg));

if (debugmode > 3) {
_cdebbuf *cdb = capi_cmsg2str(&s_cmsg);

if (cdb) {
printk(KERN_DEBUG "%s: applid=%d %s\n", __FUNCTION__,
ap->applid, cdb->buf);
cdebbuf_free(cdb);
} else
printk(KERN_DEBUG "%s: applid=%d %s not traced\n",
__FUNCTION__, ap->applid,
capi_cmd2str(s_cmsg.Command, s_cmsg.Subcommand));
}
if (s_cmsg.Command == CAPI_DATA_B3
&& s_cmsg.Subcommand == CAPI_IND) {
handle_data(&s_cmsg, skb);
Expand Down
Loading

0 comments on commit 17f0cd2

Please sign in to comment.