Tasks for the Linux Kernel
Michael Elizabeth Chastain
<mec@duracef.shout.net>
Sat 18 Nov 1995

Copyright 1995 Michael Chastain
Licensed under the Gnu Public License, Version 2



These things would make trace and replay easier and faster:



Annul sys call

    Allow PTRACE_POKEUSR to set the 'ORIG_EAX' register to -1, to annul
    the system call.  Or have -some- way to say on resumption from
    'PTRACE_SYSCALL': 'don't execute this system call at all'.  This
    requires some code changes in the system call entry code.  Right
    now, I need per-call ways of smashing the arguments to annul the
    call, and some calls don't annul ('fork', 'pause', 'vhangup').



Child memory fast copy

    I'm using 'ptrace' to read and write a word at a time.  Profiling
    shows this takes 80% of the trace time.

    (1) Use /proc/$pid/mem.  This needs to support writing as well as
        reading, although tracing (the performance-sensitive part) is
        read-only.

    (2) Implement the SunOS calls: PTRACE_{READ,WRITE}{TEXT,DATA}.  This
        would be the least work for me.

    (3) Implement shared writeable mmap'ing over /proc/$pid/mem.  This
        yields the fastest possible performance -- the child's pages
        would be right there in my address space!  I hear NeXT has this
        and uses it in their debuggers.

    BTW the existing code for 'sys_ptrace' is crummy, check out the code
    in 'fs/proc/mem.c' for much shorter / cleaner code which also
    appears to be more machine-independent.



Execve reg clear

    Execve leaves the general purpose registers as they were on entry to
    the system call.  It would help to set them to deterministic values,
    such as 0, or any values that are the same for every execution of
    'execve' from the same file.



Include files

    Sometimes, include files in <linux/*.h> fail to include other files
    that they need.  I write patches for these and Linus Torvalds
    accepts them, but then people come along and write more broken
    include files!

    This also keeps 'strace' from building: it scans 'linux/*.h' for
    interesting files and #includes just those files.

    I expect this also annoys human programmers.

    This problem has been getting better lately.



Ioctl cleanup

    Duplicate ioctls, hidden kernel ioctls, and hidden debugging ioctls
    make my job harder.  To the extent these ioctl's are permanent,
    please define them in 'include/linux/*.h'.

    There will always be some imperfections in this area but the cleaner
    this is the easier for me and the more comprehensive tracing can be.
    (Also, 'strace' will know about them, another plus.)

    'SIOCDEVPRIVATE' and 'SIOCPROTOPRIVATE' are overloaded, but I expect
    I'm stuck with those.

    Linux 1.3.41: 'SIOCADDRT', 'SIOCDELRT', and 'SIOCSIFHWADDR' have
    argument types which depend on the protocol of the channel they're
    used on.  Please do not do this!

    Linux 1.3.41: here is a list of hidden kernel ioctls:

	drivers/block/floppy.c		OLDFD* (these will go away eventually)
	drivers/block/ide-cd.c		0x1234
	drivers/cdrom/sjcd.c		0xABCD
	drivers/scsi/scsi_ioctl.h	Several!
	drivers/scsi/sg.h		SG_SET_TIMEOUT, SG_GET_TIMEOUT
	drivers/sound/mpu401.c		1
	drivers/sound/soundcard.c	1



Ioctl TIOCLINUX

    Urgh, reading another sub-type from memory is so annoying.  Please,
    do not add any more cases to this, and obsolete the cases that
    already exist.  BTW: 'set_selection' in 'drivers/char/selection.c'
    needs to have a real struct and it needs to be in
    'linux/something.h'.



Ipc dispatcher

    Annoying sub-cases.  It would be nice to obsolete 'msgrcv version
    0'.  'shmat version 0' and 'shmat version 1' are -identical- for all
    valid arguments.  'shmat version 0' could become the -only- version,
    with no changes needed in any callers, including the iBCS module
    (the original client for 'shmat version 1').



Ipc include files

    linux/{ipc,msg,sem,shm}.h have a lot of user-accessible requests and
    data structures in the __KERNEL__ part.  Fix this.
