All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Re: [PATCH] tty: vt: Add checks after calling kzalloc
@ 2022-08-31  9:08 Jiasheng Jiang
  2022-08-31  9:32 ` Greg KH
  2022-08-31  9:42 ` Tetsuo Handa
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-08-31  9:08 UTC (permalink / raw)
  To: gregkh
  Cc: jirislaby, ilpo.jarvinen, johan, penguin-kernel, zhangxuezhi1,
	xyangxi5, linux-kernel, Jiasheng Jiang

On Wed, Aug 31, 2022 at 03:57:42PM +0800, Jiasheng Jiang wrote:
>>  	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
>>  		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
>> +		if (!vc) {
>> +			console_unlock();
>> +			return -ENOMEM;
>> +		}
>>  		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
>>  		tty_port_init(&vc->port);
>>  		visual_init(vc, currcons, 1);
>>  		/* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
>>  		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
>> +		if (!vc->vc_screenbuf) {
>> +			console_unlock();
>> +			return -ENOMEM;
>> +		}
> 
> This has been attempted many times in the past, sorry.  Unless you can
> prove that this can actually happen in real life, we are going to leave
> these as-is.
> 
> Please do not just do random changes like this without actually testing
> to see if it is possible to happen.

As the harm of vulnerabilities is much higher than the cost of fixing them,
it is acceptable to add harmless security checks that guarantee the
vulnerabilities will never be triggered.

Thanks,
Jiang


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] tty: vt: Add checks after calling kzalloc
  2022-08-31  9:08 Re: [PATCH] tty: vt: Add checks after calling kzalloc Jiasheng Jiang
@ 2022-08-31  9:32 ` Greg KH
  2022-08-31  9:42 ` Tetsuo Handa
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2022-08-31  9:32 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: jirislaby, ilpo.jarvinen, johan, penguin-kernel, zhangxuezhi1,
	xyangxi5, linux-kernel

On Wed, Aug 31, 2022 at 05:08:10PM +0800, Jiasheng Jiang wrote:
> On Wed, Aug 31, 2022 at 03:57:42PM +0800, Jiasheng Jiang wrote:
> >>  	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
> >>  		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
> >> +		if (!vc) {
> >> +			console_unlock();
> >> +			return -ENOMEM;
> >> +		}
> >>  		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
> >>  		tty_port_init(&vc->port);
> >>  		visual_init(vc, currcons, 1);
> >>  		/* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
> >>  		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
> >> +		if (!vc->vc_screenbuf) {
> >> +			console_unlock();
> >> +			return -ENOMEM;
> >> +		}
> > 
> > This has been attempted many times in the past, sorry.  Unless you can
> > prove that this can actually happen in real life, we are going to leave
> > these as-is.
> > 
> > Please do not just do random changes like this without actually testing
> > to see if it is possible to happen.
> 
> As the harm of vulnerabilities is much higher than the cost of fixing them,
> it is acceptable to add harmless security checks that guarantee the
> vulnerabilities will never be triggered.

No, not always, many times you are adding new bugs by doing this type of
"unneeded fixes".  We have had this happen in the vt code many times in
the past, let's learn from our mistakes please.

And where is the "vulnerability" here exactly?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: vt: Add checks after calling kzalloc
  2022-08-31  9:08 Re: [PATCH] tty: vt: Add checks after calling kzalloc Jiasheng Jiang
  2022-08-31  9:32 ` Greg KH
@ 2022-08-31  9:42 ` Tetsuo Handa
  1 sibling, 0 replies; 3+ messages in thread
From: Tetsuo Handa @ 2022-08-31  9:42 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: jirislaby, ilpo.jarvinen, johan, zhangxuezhi1, xyangxi5,
	linux-kernel, gregkh

Please check if your system can survive, by doing

On 2022/08/31 18:08, Jiasheng Jiang wrote:
> On Wed, Aug 31, 2022 at 03:57:42PM +0800, Jiasheng Jiang wrote:
>>>  	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
>>>  		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);

-		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
+		vc_cons[currcons].d = vc = NULL;

>>> +		if (!vc) {
>>> +			console_unlock();
>>> +			return -ENOMEM;
>>> +		}
>>>  		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
>>>  		tty_port_init(&vc->port);
>>>  		visual_init(vc, currcons, 1);
>>>  		/* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
>>>  		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);

and/or

-		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
+		vc->vc_screenbuf = NULL;

>>> +		if (!vc->vc_screenbuf) {
>>> +			console_unlock();
>>> +			return -ENOMEM;
>>> +		}

in addition to your patch.

This is __init function of built-in module, isn't it?
Who can recover from this allocation failure? ;-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-31  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  9:08 Re: [PATCH] tty: vt: Add checks after calling kzalloc Jiasheng Jiang
2022-08-31  9:32 ` Greg KH
2022-08-31  9:42 ` Tetsuo Handa

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.