Skip to content

Commit 17f0cd2

Browse files
Karsten KeilLinus Torvalds
authored andcommitted
[PATCH] Fix buffer overflow and races in capi debug functions
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>
1 parent 34bbd70 commit 17f0cd2

5 files changed

Lines changed: 318 additions & 78 deletions

File tree

‎drivers/isdn/capi/Kconfig‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
# Config.in for the CAPI subsystem
33
#
44
config ISDN_DRV_AVMB1_VERBOSE_REASON
5-
bool "Verbose reason code reporting (kernel size +=7K)"
5+
bool "Verbose reason code reporting"
66
depends on ISDN_CAPI
7+
default y
78
help
8-
If you say Y here, the AVM B1 driver will give verbose reasons for
9+
If you say Y here, the CAPI drivers will give verbose reasons for
910
disconnecting. This will increase the size of the kernel by 7 KB. If
1011
unsure, say Y.
1112

13+
config CAPI_TRACE
14+
bool "CAPI trace support"
15+
depends on ISDN_CAPI
16+
default y
17+
help
18+
If you say Y here, the kernelcapi driver can make verbose traces
19+
of CAPI messages. This feature can be enabled/disabled via IOCTL for
20+
every controler (default disabled).
21+
This will increase the size of the kernelcapi module by 20 KB.
22+
If unsure, say Y.
23+
1224
config ISDN_CAPI_MIDDLEWARE
1325
bool "CAPI2.0 Middleware support (EXPERIMENTAL)"
1426
depends on ISDN_CAPI && EXPERIMENTAL

‎drivers/isdn/capi/capidrv.c‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ static void handle_plci(_cmsg * cmsg)
990990
capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f);
991991
capidrv_plci *plcip;
992992
isdn_ctrl cmd;
993+
_cdebbuf *cdb;
993994

994995
if (!card) {
995996
printk(KERN_ERR "capidrv: %s from unknown controller 0x%x\n",
@@ -1122,8 +1123,15 @@ static void handle_plci(_cmsg * cmsg)
11221123
break;
11231124
}
11241125
}
1125-
printk(KERN_ERR "capidrv-%d: %s\n",
1126-
card->contrnr, capi_cmsg2str(cmsg));
1126+
cdb = capi_cmsg2str(cmsg);
1127+
if (cdb) {
1128+
printk(KERN_WARNING "capidrv-%d: %s\n",
1129+
card->contrnr, cdb->buf);
1130+
cdebbuf_free(cdb);
1131+
} else
1132+
printk(KERN_WARNING "capidrv-%d: CAPI_INFO_IND InfoNumber %x not handled\n",
1133+
card->contrnr, cmsg->InfoNumber);
1134+
11271135
break;
11281136

11291137
case CAPI_CONNECT_ACTIVE_CONF: /* plci */
@@ -1371,10 +1379,18 @@ static _cmsg s_cmsg;
13711379
static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb)
13721380
{
13731381
capi_message2cmsg(&s_cmsg, skb->data);
1374-
if (debugmode > 3)
1375-
printk(KERN_DEBUG "capidrv_signal: applid=%d %s\n",
1376-
ap->applid, capi_cmsg2str(&s_cmsg));
1377-
1382+
if (debugmode > 3) {
1383+
_cdebbuf *cdb = capi_cmsg2str(&s_cmsg);
1384+
1385+
if (cdb) {
1386+
printk(KERN_DEBUG "%s: applid=%d %s\n", __FUNCTION__,
1387+
ap->applid, cdb->buf);
1388+
cdebbuf_free(cdb);
1389+
} else
1390+
printk(KERN_DEBUG "%s: applid=%d %s not traced\n",
1391+
__FUNCTION__, ap->applid,
1392+
capi_cmd2str(s_cmsg.Command, s_cmsg.Subcommand));
1393+
}
13781394
if (s_cmsg.Command == CAPI_DATA_B3
13791395
&& s_cmsg.Subcommand == CAPI_IND) {
13801396
handle_data(&s_cmsg, skb);

0 commit comments

Comments
 (0)