The centos7 kernel interacts with the user mode through the / proc file

question background
is now writing a firewall project based on Linux netfilter . There are some questions about the interaction between kernel and user mode programs

.

Program environment

centos7(3.10)
gcc  4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
C

problem description

kernel firewall program: a program (kernel)
user modifies firewall rule program: B program (user mode program)
now the conf file (firewall rule) accessed jointly by AGI B program is implemented through proc file, the specific location is / proc/firewall.conf ;
create proc file through proc_create . The code of creation is as follows

.
struct file_operations proc_fops =
{
    .llseek  = seq_lseek,
    .read=procf_read,
    .write=procf_write,
};
mf_proc_file = proc_create("firewall.conf", 0644, NULL, &proc_fops);

in which procf_write and procf_read are implemented by myself (the code is a bit long, I won"t paste it here)
procf_write is no problem, which is reflected in that I write to the configuration file through the B program, An is aware (firewall Filter effect changes)
the problem lies in the function procf_read , not only can I not view the contents of the configuration file through the B program file open, And I can"t directly execute cat / prod/firewall.conf . Worst of all, as soon as I check the configuration file (the), Linux system crashes directly through the above two methods, I can"t enter any instructions, so I can only repair it by restarting

.

problem analysis
you can locate the problem on the procf_read function. Here is the definition of this function

int procf_read(char *buffer, char **buffer_location, off_t offset, int buffer_length, int *eof, void *data)

/*
**buffer
*/

it"s stuck here right now. I don"t know why. it"s not easy to ask questions, if you are the one

Mar.10,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b357b1-2bf80.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b357b1-2bf80.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?