Skip to content
  • Kay Sievers's avatar
    sched: delayed cleanup of user_struct · 3959214f
    Kay Sievers authored
    
    
    During bootup performance tracing we see repeated occurrences of
    /sys/kernel/uid/* events for the same uid, leading to a,
    in this case, rather pointless userspace processing for the
    same uid over and over.
    
    This is usually caused by tools which change their uid to "nobody",
    to run without privileges to read data supplied by untrusted users.
    
    This change delays the execution of the (already existing) scheduled
    work, to cleanup the uid after one second, so the allocated and announced
    uid can possibly be re-used by another process.
    
    This is the current behavior, where almost every invocation of a
    binary, which changes the uid, creates two events:
      $ read START < /sys/kernel/uevent_seqnum; \
      for i in `seq 100`; do su --shell=/bin/true bin; done; \
      read END < /sys/kernel/uevent_seqnum; \
      echo $(($END - $START))
      178
    
    With the delayed cleanup, we get only two events, and userspace finishes
    a bit faster too:
      $ read START < /sys/kernel/uevent_seqnum; \
      for i in `seq 100`; do su --shell=/bin/true bin; done; \
      read END < /sys/kernel/uevent_seqnum; \
      echo $(($END - $START))
      1
    
    Acked-by: default avatarDhaval Giani <dhaval@linux.vnet.ibm.com>
    Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    3959214f