Skip to content

Commit

Permalink
[S390] call home: fix string length handling
Browse files Browse the repository at this point in the history
After copying uts->nodename to the static nodename array the static
version isn't necessarily zero termininated, since the size of the
array is one byte too short.
Afterwards doing strncat(data, nodename, strlen(nodename)); may copy
an arbitrary large amount of bytes.
Fix this by getting rid of the static array and using strncat with
proper length limit.

Signed-off-by: Heiko Carstens <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
  • Loading branch information
heicarst authored and Martin Schwidefsky committed Oct 29, 2009
1 parent 4a0fb4c commit e8a79c9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/s390/char/sclp_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static struct sclp_async_sccb *sccb;
static int sclp_async_send_wait(char *message);
static struct ctl_table_header *callhome_sysctl_header;
static DEFINE_SPINLOCK(sclp_async_lock);
static char nodename[64];
#define SCLP_NORMAL_WRITE 0x00

struct async_evbuf {
Expand All @@ -52,9 +51,10 @@ static struct sclp_register sclp_async_register = {
static int call_home_on_panic(struct notifier_block *self,
unsigned long event, void *data)
{
strncat(data, nodename, strlen(nodename));
sclp_async_send_wait(data);
return NOTIFY_DONE;
strncat(data, init_utsname()->nodename,
sizeof(init_utsname()->nodename));
sclp_async_send_wait(data);
return NOTIFY_DONE;
}

static struct notifier_block call_home_panic_nb = {
Expand Down Expand Up @@ -183,10 +183,8 @@ static int __init sclp_async_init(void)
goto out_mem;
rc = atomic_notifier_chain_register(&panic_notifier_list,
&call_home_panic_nb);
if (rc)
goto out_mem;
strncpy(nodename, init_utsname()->nodename, 64);
goto out;
if (!rc)
goto out;
out_mem:
kfree(request);
free_page((unsigned long) sccb);
Expand Down

0 comments on commit e8a79c9

Please sign in to comment.