lkml.org 
[lkml]   [2001]   [May]   [19]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
    /
    DateSat, 19 May 2001 17:10:56 +0200
    FromAbramo Bagnara <>
    SubjectRe: Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device arguments from lookup)
    Alexander Viro wrote:
    > 
    >         Folks, before you get all excited about cramming side effects into
    > open(2), consider the following case:
    > 
    > 1) opening "/dev/zero/start_nuclear_war" has a certain side effect.
    > 
    > 2) Local user does the following:
    >         ln -sf /dev/zero/start_nuclear_war bar
    >         while true; do
    >                 mkdir foo
    >                 rmdir foo
    >                 ln -sf bar foo
    >                 rm foo
    >         done
    > 
    > 3) Comes the night and root runs (from crontab) updatedb(8). Said beast
    > includes find(1). With sufficiently bad timing find _will_ be tricked
    > into attempt to open foo. It will honestly lstat() it, all right. But
    > there's no way to make sure that subsequent open() on the found directory
    > will get the same object.
    > 
    > 4) Side effect happens...
    > 
    > Similar scenarios can be found for other programs run by/as root, but I
    > think that the point is obvious - side effects on open() are not a good
    > idea. Yes, we can play with checking for O_DIRECTORY, yodda, yodda, but
    > I wouldn't bet a dime on security of a system with such side effects.
    > A lot of stuff relies on the fact that close(open(foo, O_RDONLY)) is a
    > no-op. Breaking that assumption is a Bad Thing(tm).
    
    Can't this easily avoided if the needed action is not
    
    < /dev/zero/start_nuclear_war 
    or
    > /dev/zero/start_nuclear_war
    
    but
    
    echo "I'm evil" > /dev/zero/start_nuclear_war
    ?
    
    -- 
    Abramo Bagnara                       mailto:abramo@alsa-project.org
    
    Opera Unica                          Phone: +39.546.656023
    Via Emilia Interna, 140
    48014 Castel Bolognese (RA) - Italy
    
    ALSA project               http://www.alsa-project.org
    It sounds good!
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    
    
    \
     
     \ /
      Last update: 2005-03-22 12:53    [from the cache]
    ©2003-2008