6

Does the suid bit have any special meaning for device files in Linux ?

2
  • find /dev -perm /ugo+s gives nothing on my machine (nor a few others I checked); does your machine have set id/sticky entries in /dev ?
    – derobert
    Sep 13, 2012 at 15:45
  • You don't execute a device file so it won't have any effect.
    – LawrenceC
    Nov 9, 2015 at 13:31

1 Answer 1

4

I believe it is not. This bit is only used on executable files. It's defined in Linux kernel headers as S_ISUID. If you grep kernel sources for this constant, you will find that it is only used in:

  • should_remove_suid function, which is used on FS operations that should remove SUID/SGID bit,
  • prepare_binprm function in fs/exec.c which is used when prepairing executable file to set EUID on exec,
  • pid_revalidate function in fs/proc/base.c which is used to populate procfs,
  • notify_change function in fs/attr.c which is used when changing file attributes,
  • is_sxid function in include/linux/fs.h which is only used by XFS and GFS specific code and notify_change function,
  • in filesystem specific code (of course)

So it seems to me that this bit is only used (from userspace perspective) when executing files. At least on Linux.

4
  • Don't forget some of these bits serve a purpose for DIRECTories too.
    – mdpc
    Sep 13, 2012 at 22:14
  • @mdpc Directories are also files.
    – Chris Down
    Sep 14, 2012 at 0:34
  • @mdpc: SUID bit on directory has a meaning at least on ext2/3 filesystem. Some other filesystems may implement some mechanisms similar to SGID bit on directories. But that's filesystem dependent so it only involves filesystem operations. Sep 14, 2012 at 6:00
  • @KrzysztofAdamski I don't see any effect from changing the SUID bit on a directory. What effect would you expect it to have?
    – kasperd
    Nov 6, 2015 at 9:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .