Could someone create a smart contract where the target would be to read kernel memory (using some exploit) and then at the end of the smart contact it would write the kernel memory to the blockchain?
I have not studied OS but as I understand you want to take the data in the protected memory of the computer and then load it in the smart contract and then write it on the blockchain.
Smart contract do not have the ability to interact with the data outside them directly, to do that we use a third party oracle. For instance Oraclize. So this is one way to enter the data in the contract.
But what you can also do is that, before you compile and deploy the contract, you can use a script to get the kernel data and make the script write the data in the contract source file. Smart Contract have
bytes datatype to store data in byte format. After that you can compile the contract and deploy it.
Also it is not possible to do file handling in solidity.