lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54AA9884.5070202@redhat.com>
Date:	Mon, 05 Jan 2015 14:58:28 +0100
From:	Laszlo Ersek <lersek@...hat.com>
To:	David Vrabel <david.vrabel@...rix.com>,
	Vitaly Kuznetsov <vkuznets@...hat.com>
CC:	x86@...nel.org, Andrew Jones <drjones@...hat.com>,
	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, xen-devel@...ts.xenproject.org,
	Boris Ostrovsky <boris.ostrovsky@...cle.com>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [Xen-devel] [PATCH] x86/xen: avoid freeing static 'name' when
 kasprintf() fails

On 01/05/15 14:19, David Vrabel wrote:
> On 05/01/15 13:06, Vitaly Kuznetsov wrote:
>> In case kasprintf() fails in xen_setup_timer() we assign name to the static
>> string "<timer kasprintf failed>". We, however, don't check that fact before
>> issuing kfree() in xen_teardown_timer(), kernel is supposed to crash with
>> 'kernel BUG at mm/slub.c:3341!'
>>
>> Solve the issue by making name a fixed length string inside struct
>> xen_clock_event_device. 16 bytes should be enough.
>>
>> The issue was discovered by Laszlo Ersek.
> 
> Add Reported-by: Laszlo ... tag perhaps?
> 
>> --- a/arch/x86/xen/time.c
>> +++ b/arch/x86/xen/time.c
>> @@ -391,7 +391,7 @@ static const struct clock_event_device *xen_clockevent =
>>  
>>  struct xen_clock_event_device {
>>  	struct clock_event_device evt;
>> -	char *name;
>> +	char name[16];
>>  };
>>  static DEFINE_PER_CPU(struct xen_clock_event_device, xen_clock_events) = { .evt.irq = -1 };
>>  
>> @@ -420,14 +420,11 @@ void xen_teardown_timer(int cpu)
>>  	if (evt->irq >= 0) {
>>  		unbind_from_irqhandler(evt->irq, NULL);
>>  		evt->irq = -1;
>> -		kfree(per_cpu(xen_clock_events, cpu).name);
>> -		per_cpu(xen_clock_events, cpu).name = NULL;
>>  	}
>>  }
>>  
>>  void xen_setup_timer(int cpu)
>>  {
>> -	char *name;
>>  	struct clock_event_device *evt;
> 
> struct xen_clock_event_device *xevt = ...;
> 
>>  	int irq;
>>  
>> @@ -438,21 +435,19 @@ void xen_setup_timer(int cpu)
>>  
>>  	printk(KERN_INFO "installing Xen timer for CPU %d\n", cpu);
>>  
>> -	name = kasprintf(GFP_KERNEL, "timer%d", cpu);
>> -	if (!name)
>> -		name = "<timer kasprintf failed>";
>> +	snprintf(per_cpu(xen_clock_events, cpu).name, 16, "timer%d", cpu);
> 
> Use sizeof(xevt->name) here.

Yes, I wanted to recommend sizeof too.

Also the "standard" Reported-by tag would be nice.

Thanks!
Laszlo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ