Re: Garbage data while reading via usermode driver?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 16, 2020 at 08:11:04PM +0900, Tetsuo Handa wrote:
> Hello.
> 
> Below is a loadable kernel module which attempts to read (for example) /proc/interrupts from
> kernel using usermode driver interface. What is strange is that the total bytes obtained by
> doing "wc -c /proc/interrupts" from userspace's shell and trying to insmod this kernel module
> differs; for unknown reason, kernel_read() returns "#!/bin/cat /proc/interrupts\n" (28 bytes)
> at the end of input.

Because /bin/cat writes it out ;-)

$ echo "#!/bin/echo foo" >/tmp/a
$ chmod +x /tmp/a
$ /tmp/a
foo /tmp/a
$

IOW, same way #!/bin/sh -e in the beginning of /tmp/foo.sh results in exec
of /bin/sh with -e and /tmp/foo.sh in the arguments, #!/bin/cat /proc/interrupts
in /tmp/bar.sh will result in exec of /bin/cat with /proc/interrupts and
/tmp/bar.sh in parameters.  With cat(1) doing what it's supposed to do.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux