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]
Date:   Thu, 6 Jun 2019 13:47:53 +0200
From:   Hans Verkuil <hverkuil-cisco@...all.nl>
To:     Pavel Machek <pavel@...x.de>, pavel@....cz
Cc:     linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
        Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 4.19 262/276] media: saa7146: avoid high stack usage with
 clang

On 6/6/19 1:44 PM, Pavel Machek wrote:
> Hi!
> 
>> Two saa7146/hexium files contain a construct that causes a warning
>> when built with clang:
>>
>> drivers/media/pci/saa7146/hexium_orion.c:210:12: error: stack frame size of 2272 bytes in function 'hexium_probe'
>>       [-Werror,-Wframe-larger-than=]
>> static int hexium_probe(struct saa7146_dev *dev)
>>            ^
>> drivers/media/pci/saa7146/hexium_gemini.c:257:12: error: stack frame size of 2304 bytes in function 'hexium_attach'
>>       [-Werror,-Wframe-larger-than=]
>> static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
>>            ^
>>
>> This one happens regardless of KASAN, and the problem is that a
>> constructor to initialize a dynamically allocated structure leads
>> to a copy of that structure on the stack, whereas gcc initializes
>> it in place.
>>
>> Link: https://bugs.llvm.org/show_bug.cgi?id=40776
> 
>> --- a/drivers/media/pci/saa7146/hexium_gemini.c
>> +++ b/drivers/media/pci/saa7146/hexium_gemini.c
>> @@ -270,9 +270,8 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
>>  	/* enable i2c-port pins */
>>  	saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
>>  
>> -	hexium->i2c_adapter = (struct i2c_adapter) {
>> -		.name = "hexium gemini",
>> -	};
>> +	strscpy(hexium->i2c_adapter.name, "hexium gemini",
>> +		sizeof(hexium->i2c_adapter.name));
>>  	saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
>>  	if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
>>  		DEB_S("cannot register i2c-device. skipping.\n");
> 
> As a sideeffect, this removes zero-initialization from
> hexium->i2c_adapter.
> 
> Is that intended / correct?

It's correct, the hexium struct that contains the i2c_adapter is zeroed with
kzalloc, so there is no need to zero it again.

Regards,

	Hans

> 
> [I tried looked at saa7146_i2c_adapter_prepare(), and that does not
> initialize all the fields, either.]
> 
> Best regards,
> 									Pavel
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ