lkml.org 
[lkml]   [2014]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: dcache shrink list corruption?
On Thu, May 01, 2014 at 11:42:52AM +0200, Miklos Szeredi wrote:
> Two points about latest version (dentry_kill-2):
>
> - Doing anything with dentry->d_parent in case of DCACHE_DENTRY_KILLED looks
> seriously wrong. Parent has been dealt with, at that point, by the other
> caller, no?

In both branches, actually - we should bugger off earlier *and* return NULL
in that case. Nice catch.

Hmm... I see why it failed to blow up on that. It *did* trigger, all right -
udev is stepping into that right on boot. The thing is, check should be
if ((int)dentry->d_lockref.count > 0)
since the damn thing is unsigned int. IOW, they did go through handover
and shrink_dentry_list() proceeded to lose them. And with that braino
fixed, it steps into the extra dput crap just fine.

OK, fixed and pushed (both branches).

> - "bool foo = flag & FLAG" looks suspicious. Is this guaranteed not to
> overflow?

What do you mean, overflow? It's not a 1-bit unsigned int; conversion to
_Bool is different (which is the only reason why it's more than mere
syntax sugar). See C99 6.3.2.1 ("When any scalar value is converted
to _Bool, the result is 0 if the value compares equal to 0; otherwise,
the result is 1").

That, BTW, is also the reason why _Bool bitfields exist - try
struct {
_Bool a:1;
unsigned b:1;
} x;
x.a = 2;
x.b = 2;
if (x.a)
printf("A");
if (x.b)
printf("B");
and see what it does. The first test triggers, same as if (2) would.
The second does not, since conversion to unsigned integer type other
than _Bool gives the value in range of that type comparable to original
modulo (maximal representable + 1). And 2 modulo 2 is 0...


\
 
 \ /
  Last update: 2014-05-01 17:21    [W:0.111 / U:0.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site