Hey,
I'm currently getting into some kernel module progamming. As a little exercise I want to read the headers out of an ELF file. My code is very simple, here is the important part:
(I know that might not make much sense, it's just to play around and see how the functions and data structures work).
As long as I choose a valid path and filename in the filp_open everything works fine, just as it should.
But if I enter a non-existent filename it always gets killed. The log says:
BUG: Unable to handle kernel NULL pointer dereference at 0000000a
Interestingly, the module always seems to get killed at the 2nd if-clause. That means that even if the file doesn't exist fd itself is not NULL, but then, once I simply check if f_dentry is a NULLpointer, the module crashes.
Can anyone tell me why and how can I write this short code in such a way that it can handle non-existent files (without creating them, but rather exiting with a simple error msg)
Hmmmm! It looks like it's openFile that's crashing -- or at least something filp_open calls.. It's never getting to the bits of code where you check pointers.
openFile is just the function all the stuff happens in...
Here is the full code:
I copied the read_kernel from another program, not really sure yet what it does But as I told you: The crash happens in the part mentioned above
Great. Now post readElf and kernel_read. Or better yet, post your entire file already. And a complete list of messages from when you load the module until it crashes.
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I'm able to create a group but when I'm trying to delete the group it keeps stating Group Doesn't Exist. I know... (2 Replies)
Hi everyone,
I am trying to prevent the ehci_hcd kernel module to load at boot time.
Here's what I've tried so far:
1) Add the following line to /etc/modprobe.d/blacklist.conf (as suggested here):
2) Blacklisted the module by adding the following string to
3) Tried to blacklist the module... (0 Replies)
Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom.
I create a named pipe then:
dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024
but when I cat a file to the fifo that's 1024 random bytes:
cat randomfile.txt >... (7 Replies)
Hi, I'm pretty new to kernel coding and I'm working on a device driver that works with an existing framework.
Basically my module will be loaded/unloaded multiple times and I'd like to create a register a class, driver, and create a /dev node on the first load only. The existing framework... (0 Replies)
Hii all,
i create the user
useradd -d /home/kk kk
passwd kk
when i tried to login to kk
i get a error user directory doesn't exist
then i tried
useradd kkk
passwd kkkwhen i tried to login to kkk
i get the same error user directory doesn't exist. (4 Replies)
Hi Forums,
I got a little problem, I made a few modifications to the code of the launch script of a testing server(minecraft) and now updating is broken aswell as the automatic directory creation.
These Lines somehow create an endless symlink that refers to itself and I don't know how to fix... (0 Replies)
Can someone please shed light on why this may not be working, file does exist, but I get an error
if ]
then
echo "No ${source_path}/${file_mask} found - ">> ${logfile}
result=1
check_result ${result} "Failed to find file... (4 Replies)
I have a script that is working:
#!/bin/bash
sftp user@domain.com <<EOF
cd somedir
mget *.csv
quit
EOF
but on a crontab I want to only pull newer files, so I want to do something like:
while read ls current dir local file != true do
mget that new file
but I'm not sure the syntax... (2 Replies)
Hi all,
I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/.
I need to know if I can... (0 Replies)
Hi All,
Is there a max number of slabs that can be used per kernel module? I'm having a tough time finding out that kind of information, but the array 'node_zonelists' (mmzone.h) has a size of 5. I just want to avoid buffer overruns and other bad stuff.
Cheers,
Brendan (4 Replies)