All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Benjamin Larsson <benjamin@southpole.se>, Antti Palosaari <crope@iki.fi>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free
Date: Mon, 19 Jan 2015 14:15:25 +0100	[thread overview]
Message-ID: <54BD036D.8020701@xs4all.nl> (raw)
In-Reply-To: <54836680.9010404@southpole.se>

On 12/06/2014 09:26 PM, Benjamin Larsson wrote:
> On 12/06/2014 07:37 PM, Antti Palosaari wrote:
>>>
>>> I do think it is good practice to set pointers to null generally as that
>>> would have saved me several days of work of whentracking down this bug.
>>> The current dvb framework contain several other cases where pointers are
>>> feed'd but not nulled.
>>
>> There is kzfree() for that, but still I am very unsure should we start 
>> zeroing memory upon release driver has allocated, or just relase it 
>> using kfree.
>>
>> regards
>> Antti 
> 
> Well I guess I am biased as I have spent lots of time finding a bug that 
> probably wouldn't exist if the policy was that drivers always should set 
> their memory to zero before it is free'd.

Just because you zero memory before it is freed doesn't mean it stays zeroed.
As soon as it is freed some other process might take that memory and fill it
up again. So zeroing is pointless and in fact will only *hide* bugs.

The only reason I know of for zeroing memory before freeing is if that memory
contains sensitive information and you want to make sure it is gone from memory.

You can turn on the kmemcheck kernel option when compiling the kernel to test
for accesses to uninitialized memory if you suspect you have a bug in that
area.

Anyway:

Nacked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Maybe we should have a compile 
> time override so that all free calls zeroes the memory before the actual 
> free? Maybe there already is this kind of feature?
> 
> MvH
> Benjamin Larsson
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2015-01-19 13:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-06  0:25 [PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors Benjamin Larsson
2014-12-06  0:25 ` [PATCH 2/3] mn88472: make sure the private data struct is nulled after free Benjamin Larsson
2014-12-06 16:29   ` Antti Palosaari
2014-12-06 18:08     ` Benjamin Larsson
2014-12-06 18:37       ` Antti Palosaari
2014-12-06 20:26         ` Benjamin Larsson
2015-01-19 13:15           ` Hans Verkuil [this message]
2015-01-19 18:38             ` Benjamin Larsson
2014-12-06  0:25 ` [PATCH 3/3] mn88472: add ts mode and ts clock to driver Benjamin Larsson
2014-12-06 16:31   ` Antti Palosaari
2014-12-06 12:46 ` [PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors Antti Palosaari
2014-12-06 14:27   ` Benjamin Larsson
2015-02-19  9:44 ` Benjamin Larsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54BD036D.8020701@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=benjamin@southpole.se \
    --cc=crope@iki.fi \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.