Linux-Development-Sys Digest #474
Linux-Development-Sys Digest #474, Volume #8 Thu, 8 Feb 01 03:13:09 EST Contents: insmod command line argument (Huy Ton) kernel panic (Jwbat) Re: CPU Time of a process (Kyle) Re: New-bee questions about Display driver (Tim Roberts) Re: can Linux be secure? ([EMAIL PROTECTED]) Re: can Linux be secure? ([EMAIL PROTECTED]) Re: 2.4.1 ppp breaks (works in 2.4.0) ([EMAIL PROTECTED]) Re: insmod command line argument (Yamazaki Kasparov) Re: O_SYNC in 2.4 ([EMAIL PROTECTED]) Re: insmod command line argument (Michael Mueller) Re: timeout irq programming ("Eduardo Ferro") Device Driver development (Yamazaki Kasparov) structure of /proc//stat (Shai Kedem) structure of /proc//stat (Shai Kedem) structure of /proc//stat (Shai Kedem) structure of /proc//stat (Shai Kedem) Re: Device Driver development (Josef Moellers) Re: structure of /proc//stat (Josef Moellers) Re: Problem adding a system call to the kernel... (Michael Mueller) From: Huy Ton <[EMAIL PROTECTED]> Subject: insmod command line argument Date: Wed, 07 Feb 2001 18:30:36 -0800 Hi, I'm trying to use command line argument to set the variable value in the driver. According to the book "Linux Device Drivers" by Rubini, I should be able to do: insmod my_variable=1 Seems like with my kernel (version 2.2.14), I need to also do something else to make it work. Can someone give me some advice? Thanks -- From: [EMAIL PROTECTED] (Jwbat) Date: 08 Feb 2001 02:47:51 GMT Subject: kernel panic hello, My Linux machine has KERNEL PANICed more than once with the error message: In interrup handler: not synching Anyone know what causes this?? system: Linux 2.4.1 intel Pentium II @ 266Mhz 64KB ram ibm Ultrastar18GB SCSI disks using Mylex 170 Raid controller cyclades cyclom Ye serial card Thanx, JWB -- From: Kyle <[EMAIL PROTECTED]> Subject: Re: CPU Time of a process Date: 8 Feb 2001 04:58:34 GMT "Bjorn Brencher" <[EMAIL PROTECTED]> wrote: > Hello, > i try to control a portscanner process. How can i get the exact cpu time the > process is using? > I tried w, top and ps but after a short time the portscanner doesn't > increase his cpu-time any more?! time /whatever/portscanner This will give you real time and cpu time when the process exits. -Kyle -- From: Tim Roberts <[EMAIL PROTECTED]> Subject: Re: New-bee questions about Display driver Date: Wed, 07 Feb 2001 21:04:38 -0800 A. Neshmonin <[EMAIL PROTECTED]> wrote: > >I am about to start a new ground-level project to develop fully HW- >accelerated display driver for latest-n-greatest Matrox graphics chip. Display driver for what? XFree86? >I have strong experience with Win32 development of that drivers, but >merely exposed to Unix or Linux. I'd appreciate if someone helped me >with the advises: >- where to start from?:-) >- what the books/web-sites to read? >- what the newsgroup to register with? >- what the people from freelance open-source community to contact? If you are embarking on an XFree86 driver, then there is no question you need to begin with the XFree86 source code. XFree86 already has drivers for almost everything Matrox makes, and typically generation N+1 of a manufacturer's chip is nearly compatible with generation N. The easiest way to get an XFree86 driver going is to make small tweaks to an existing driver. You should also sign on to be an XFree86 developer. This gets you access to the developer's mailing list, and to various other resources. Start at www.xfree86.org. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- From: [EMAIL PROTECTED] Subject: Re: can Linux be secure? Date: Thu, 08 Feb 2001 05:56:42 - On Tue, 6 Feb 2001 22:47:18 +0100 Peter T. Breuer <[EMAIL PROTECTED]> wrote: | [EMAIL PROTECTED] wrote: |> Well, from the sounds of it, it seems I can trust the Linux kernel, |> though I would have to also continue to watch for any exploits. But | | You can do no such thing. Anyone who gets root can do an insmod | of init_module() { do arbitrary thing to kernel; }. So the kernel | is exactly as secure as userspace. There are two separate mechanisms. One way in is via the user processes letting someone in, especially bad as root. But this is not the issue I'm asking about. The other is the kernel letting them in DIRECTLY. See what I mean about people not reading my question literally. I guess maybe I do have to repeat myself to get it across. -- = | Phil Howard - KA9WGN | Dallas | http://linuxhomepage.com/ | | [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/ | = -- From: [EMAIL PROTECTED] Subject: Re: can Linux be secure? Date: Thu, 08 Feb 2001 0
Linux-Development-Sys Digest #473
Linux-Development-Sys Digest #473, Volume #8 Wed, 7 Feb 01 20:13:17 EST Contents: Re: timeout irq programming (Jeff Andre) Re: does 2.4 kernel need 2.4 initrd? (Eric Taylor) How can I lobby for a new /proc entry (Eric Taylor) Accessing routing table via C/C++ ("Simon Bretin") New-bee questions about Display driver (A. Neshmonin) O_SYNC in 2.4 ([EMAIL PROTECTED]) Re: O_SYNC in 2.4 (Kaz Kylheku) Re: how do i do this in c??? ("Dan Miller") how to shift memory usage?? ("Dan Miller") Re: how to shift memory usage?? (Dave Platt) SIOCRTMSG ("Simon Bretin") From: [EMAIL PROTECTED] (Jeff Andre) Subject: Re: timeout irq programming Date: 7 Feb 2001 17:50:31 GMT Eduardo Ferro ([EMAIL PROTECTED]) wrote: : Hi! : I am developig a driver at my job, but i have a great problem to control : the timeout and the irq of the device at the same time... : I have to wait for a irq for a time, and return an error if the there : wasn`t any interrupt, but i don`t know how to implement this, because, i : don't know if wait sleeping in a wait queue or how. : I think that a posibiliti is to programar other task that sleep for a : while and wake_up the process when the timeout expires seting some flag : or something similar, but i don't know how can do this. : i am reading other drivers code but i can`t see how to do this... : Any suggestion would be apreciated Have you looked at the 'interruptible_sleep_on_timeout'. My interrupt handler, actually a 'bottom half', performs the 'wake_up_interruptible'. If the interrupt doesn't happen or is late, the sleep will time out. -- Jeff Andre -- From: Eric Taylor <[EMAIL PROTECTED]> Subject: Re: does 2.4 kernel need 2.4 initrd? Date: Wed, 07 Feb 2001 18:15:48 GMT Anders Larsen wrote: > > >I need to do this upgrade to other systems, > >so I need to really understand this. > > One pragmatic solution is to build anything that is needed to boot into > the kernel and leave the rest (which can be loaded later) as modules. > In that case, you don't need an initrd at all. > > >(Do you really need to first > >build the drivers modular to build > >initrd, then make the drivers > >built-in in order to boot up?? > >seems strange, I must be doing something > >else wrong). > > Yes. The order should always be > build kernel, build & install modules, mkinitrd > > HTH > Anders Ok, so the only reason for initrd is when you don't know what the boot device is on the target system. Like in a redhat standard release cd. I was wanting to build the kernel on one system and copy it to other systems. But I don't know yet what hardware these systems will have. So, I guess redhat uses initrd, but must have on the install cd all the boot driver modules prebuilt and chooses the right one based on the hardware it sees and builds a custom initrd. In my case, I guess I should forget that idea and upgrade a standard installation from source; look at what scsi device it has and build in that driver only, then add a lilo entry without initrd for the 2.4 kernel. Thanks All, it's been quite an education. eric -- From: Eric Taylor <[EMAIL PROTECTED]> Subject: How can I lobby for a new /proc entry Date: Wed, 07 Feb 2001 19:27:31 GMT Hi: I have a large program that we are porting to linux. I can't change how it allocates memory. It does an sbrk. Sbrk grabs memory in the first gig of virtual address space, but is limited as to how far it can grow (contiguously) because of where the shared libraries load. Shared libraries load starting at the location computed by the symbol TASK_UNMAPPED_BASE in the following fragment in mm/mmap.c: This code has not changed in kernel 2.4. unsigned long get_unmapped_area(unsigned long addr, unsigned long len) { struct vm_area_struct * vmm; if (len > TASK_SIZE) return 0; if (!addr) addr = TASK_UNMAPPED_BASE; addr = PAGE_ALIGN(addr); I've written a simple c program to go into /dev/kmem and patch the instruction that sets addr above. This is usually a single load immediate instruction, so the value (usually 0x4000) can be easily changed. I typically change the 40 to 0x80 or higher to get a contiguous section of memory up to 2 gigs. Problem is my way of changing this. My program is a kludge, it needs to be careful not to clobber the wrong location and depending on the hardware, the instructions at that location can be different. It would be really nice if this value were settable by a /proc/sys/kernel entry. But I don't know how to make that change. And even if I did, I would prefer this to become part of the "official" linux. Does anyone know where I can post such a request? It can't be too difficult for some kernel expert. Instead of it being a constant, it would just be a system variable with a default value of TASK_UNMAPPED_BASE. I know t
Linux-Development-Sys Digest #472
Linux-Development-Sys Digest #472, Volume #8 Wed, 7 Feb 01 13:13:15 EST Contents: getting physical address of var from modules? ("Jin") Re: does 2.4 kernel need 2.4 initrd? (Villy Kruse) Re: select not working for K_MEDIUMRAW keyboard input (Kasper Dupont) timeout irq programming ("Eduardo Ferro") Network Device Drivers ([EMAIL PROTECTED]) network device drivers ([EMAIL PROTECTED]) Re: Web Server and Proxy Server Performance Simulation (Paul Yanzick) Re: network device drivers ("Jean-Michel Audet") Re: Kernel list searcher with underscore smarts? (Kasper Dupont) Error messages asking to relink a shared library. (Thaddeus L Olczyk) Re: 2.4.1 ppp breaks (works in 2.4.0) ("Zoran V. Petrovic") Re: WHAT do They Mean 2.4.1 Stable when 2.4.0 was just released stable? (Thaddeus L Olczyk) Re: Why is O_NONBLOCK implemented at driver level? (Grant Edwards) Problem adding a system call to the kernel... (Geoff Hammerle) CPU Time of a process ("Björn Brencher") read a char dev with select() function ("Damir Dezeljin \(Telemach\)") Re: network device drivers (Kaz Kylheku) From: "Jin" <[EMAIL PROTECTED]> Crossposted-To: linux.dev.kernel Subject: getting physical address of var from modules? Date: Wed, 7 Feb 2001 19:13:14 +0900 Hi, How can I get the physical address of global variables defined in a module? Either virt_to_phys() or virt_to_bus() doesn't work. Jin -- From: [EMAIL PROTECTED] (Villy Kruse) Subject: Re: does 2.4 kernel need 2.4 initrd? Date: 7 Feb 2001 11:16:36 GMT On Wed, 07 Feb 2001 09:51:20 GMT, Eric Taylor <[EMAIL PROTECTED]> wrote: > >Or does the initrd sort of preload the scsi module >before the root device gets accessed and it remains >loaded while the root device is switched? > Exactly. >Trying to think this one out feels like my brain >is being sucked into a black hole! > Don't make the scsi driver as modules, but build them in. (You already did that). Then you forget about initrd. End of story. Villy -- From: Kasper Dupont <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.development.apps Subject: Re: select not working for K_MEDIUMRAW keyboard input Date: Wed, 07 Feb 2001 12:41:53 +0100 Bernd Oliver Christiansen wrote: > > Hello: > > I'm reading from both the (GPM) mouse device and the console device using > the select system call. While mouse input works fine, select does not > unblock when keyboard input becomes available for reading and FD_ISSET(tty) > is always false. This is on a 2.2.14 kernel. The following are code > snippets that illustrate what I'm doing. > > int tty = open("/dev/tty0", O_RDWR); > int mouse_fd = open("/dev/gpmdata", O_NONBLOCK); > ioctl(tty, VT_SETMODE, &mode); // mode.mode = VT_PROCESS; > ioctl(tty, KDSETMODE, KD_GRAPHICS); > ioctl(tty, KDSKBMODE, K_MEDIUMRAW); > fd_set rset; > FD_ZERO(&rset); > FD_SET(tty, &rset); > FD_SET(mouse_fd, &rset); > maxfdp1 = (tty > mouse_fd ? tty : mouse_fd) + 1; > while (1) { > select(maxfdp1, &rset, NULL, NULL, NULL); > if (FD_ISSET(tty, &rset)) > ; // NEVER REACHED > if (FD_ISSET(mouse_fd, &rset)) > ; // works fine > } > > What am I missing? I'm getting somewhat clueless. > > Thanks for your help, > > -Bernd I think the problem is that the tty is in cooked mode, where it will not deliver any data to your program until it receives a newline. When the keymap translation is switched off, the enter keys will not even work. But I think 9 in the Alphanumeric section has scancode 10 and will work. You need to do something with tcgetattr, tcsetattr. Here is a piece of code from a program doing something similar: tcgetattr(keyboard_fd,&ttysetings); { struct termios modified=ttysetings; modified.c_cflag &= ~HUPCL; modified.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); modified.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); tcsetattr(keyboard_fd,TCSANOW,&modified); ioctl(keyboard_fd,KDSKBMODE,K_RAW); } -- Kasper Dupont -- From: "Eduardo Ferro" <[EMAIL PROTECTED]> Subject: timeout irq programming Date: Wed, 07 Feb 2001 13:14:10 +0100 Hi! I am developig a driver at my job, but i have a great problem to control the timeout and the irq of the device at the same time... I have to wait for a irq for a time, and return an error if the there wasn`t any interrupt, but i don`t know how to implement this, because, i don't know if wait sleeping in a wait queue or how. I think that a posibiliti is to programar other task that sleep for a while and wake_up the process when the timeout expires seting some flag or something similar, but i don't know how can do this. i am reading other drivers code but i can`t see how to do this... Any suggestion would be apreciated -- From: [EMAIL PROTECTED] Subject: Network Device Drivers Date:
Linux-Development-Sys Digest #471
Linux-Development-Sys Digest #471, Volume #8 Wed, 7 Feb 01 05:13:15 EST Contents: Re: recursive mutex implementation (Kaz Kylheku) Re: reliable coredump under Linux? ("Gene Soudlenkov") Re: recursive mutex implementation (Kaz Kylheku) does 2.4 kernel need 2.4 initrd? (Eric Taylor) Re: Module Programming Question (Unresolved symbol printk) ([EMAIL PROTECTED]) Re: sleeping inside the kernel (sleep_on ; schedule_timeout) ([EMAIL PROTECTED]) EXPORT Kernel Symbol ([EMAIL PROTECTED]) Re: EXPORT Kernel Symbol ("Gene Soudlenkov") Sendmail problem... ("avi") Re: EXPORT Kernel Symbol ([EMAIL PROTECTED]) Re: Isn't ReiserFS in 2.4.1 (Marc SCHAEFER) EXPORT Kernel Symbol for my own Kernel Function ([EMAIL PROTECTED]) Re: does 2.4 kernel need 2.4 initrd? (Villy Kruse) Re: Module Programming Question (Unresolved symbol printk) (Josef Moellers) Re: can Linux be secure? (Kasper Dupont) Re: Module Programming Question (Unresolved symbol printk) (Kasper Dupont) Re: does 2.4 kernel need 2.4 initrd? (Anders Larsen) Re: does 2.4 kernel need 2.4 initrd? (Eric Taylor) From: [EMAIL PROTECTED] (Kaz Kylheku) Subject: Re: recursive mutex implementation Reply-To: [EMAIL PROTECTED] Date: Wed, 07 Feb 2001 00:09:24 GMT On Tue, 06 Feb 2001 22:31:46 GMT, Daniele Pallastrelli <[EMAIL PROTECTED]> wrote: >Hi all, >I need to implement a my own recursive mutex using only traditional mutexes. >I think this solution could work: > > >variables: >m, critSect: mutex; >lockCount: int; >owner: thread ID; > > >lock() implementation: > >critSect.lock() >if ( owner == 0 ) // mutex is not owned by anyone... It's not portable to compare a pthread_t against zero, nor to assume that zero cannot be a valid thread ID. On some operating systems, pthread_t is in an integer, and the main thread is assigned the value zero. On some others, pthread_t is a struct. This is easy to fix by using an extra flag to indicate that the mutex is not owned. >{ > ++lockCount; > owner = pthread_self(); > m.lock(); This is a problem; while a thread waits here on mutex m, it is holding mutex critSect. So no other thread can perform any operation on the lock, including the thread which owns the mutex m. >} > else >if ( owner == pthread_self() ) // I already have this mutex! > ++lockCount; >else // someone locks this mutex! > { > critSect.unlock(); > m.lock(); > critSect.lock(); > lockCount = 1; Also, you have a horrible race here that leads to deadlock situation, because you acquire the locks in an opposite order. Suppose that just after you call m.lock() some other thread calls this function. That other thread acquires critSect.lock(), sees that there is not yet any owner, and so calls m.lock(). However, your thread has already acquired the lock m, so that other thread has to wait. Meanwhile, your thread calls critSect.lock() and the deadly embrace is complete. I believe that the problem can be solved like this: void lock::acquire() { crit_sect.lock(); bool i_am_the_owner = is_locked && owner == pthread_self(); crit_sect.unlock(); if (i_am_the_owner) lock_count++; else { m.lock(); crit_sect.lock(); is_locked = true; owner = pthread_self(); crit_sect.unlock(); } } void lock::release() { if (--lock_count == 0) { crit_sect.lock(); is_locked = false; crit_sect.unlock(); m.unlock(); } } Note that only the lock_count is protected by m. Only the flag is_locked and the owner variable are protected by crit_sect. The two times when both locks are held by the caller are in the else clause in lock::acquire, and in the body of the if in ::release. There is no opposite locking m is always acquired first, hence no risk of deadlock. Final remark: you'd be better off working with non-recursive locks. Recursive locks are error prone. -- From: "Gene Soudlenkov" <[EMAIL PROTECTED]> Subject: Re: reliable coredump under Linux? Date: Wed, 7 Feb 2001 13:38:17 +1300 Hi, We've got the same problem with our application. Could you give a clue what changes have been done in binfmt_elf? Gene rachel braverman <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > We face a problem after patching the kernel. Maybe you have an idea > what we need to do: > > We run a multithreaded application > (it happens for any multithreaded applications) > using our compiled 2.2.17 kernel with glibc-2.1.2-11. > When we send a > > kill -SEGV > > When analyzing the core dump we see > that it has the information of only the > dumping thread which is not the same > threads that received the signal > (it is the last thread which goes down). > > To fix that we changed the following files: > fs/binfmt_elf.c > kernel/fork.c > include/linux/sched.h > > This fi