Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1333567
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [GIT PULL] Driver core fix for 4.5-rc4 |
| Date | 2016-02-14 22:00 +0100 |
| Message-ID | <r2bVU-7V7-3@gated-at.bofh.it> (permalink) |
| References | <r2adt-72j-31@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, Feb 14, 2016 at 11:02 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> Here is one driver core, well klist, fix for 4.5-rc4. It fixes a
> problem found in the scsi device list traversal that probably also could
> be triggered by other subsystems.
So I pulled this, but quite frankly, the fix smells bad to me.
If the n_ref kref can go down to zero at any time, how is that "struct
klist_node *n" safe to ever even touch in the caller?
IOW, what is it that protects that klist_node from not having entirely
been released, and any access to the kref might be a use-after-free
(and the use of "kref_get_unless_zero()" just hides the problem).
So it smells to me like if the kref can go down to zero, the caller is
basically passing in a random pointer.
Please make me feel better about my pull. I need a virtual hug.
(Also, rather than assigning i_dur twice like this:
+ i->i_cur = NULL;
+ if (n && kref_get_unless_zero(&n->n_ref))
+ i->i_cur = n;
I think it would have been cleaner to [in]validate "n" first (perhaps
with a comment about _why_ that is needed yet safe):
+ if (n && !kref_get_unless_zero(&n->n_ref))
+ n = NULL;
and then just do a simple:
+ i->i_cur = n;
afterwards).
But I care less about that small syntactic issue than I care about
understanding why it's safe to pass around a klist_node that might not
exist any more.
Linus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL] Driver core fix for 4.5-rc4 Greg KH <gregkh@linuxfoundation.org> - 2016-02-14 20:10 +0100
Re: [GIT PULL] Driver core fix for 4.5-rc4 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-14 22:00 +0100
Re: [GIT PULL] Driver core fix for 4.5-rc4 James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-02-14 22:30 +0100
Re: [GIT PULL] Driver core fix for 4.5-rc4 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-14 22:40 +0100
Re: [GIT PULL] Driver core fix for 4.5-rc4 James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-02-14 23:10 +0100
csiph-web