In the Linux kernel, the following vulnerability has been resolved:
skmsg: Fix wrong last sg check in skmsgrecvmsg()
Fix one kernel NULL pointer dereference as below:
[ 224.462334] Call Trace: [ 224.462394] _tcpbpfrecvmsg+0xd3/0x380 [ 224.462441] ? sockhasperm+0x78/0xa0 [ 224.462463] tcpbpfrecvmsg+0x12e/0x220 [ 224.462494] inetrecvmsg+0x5b/0xd0 [ 224.462534] _sysrecvfrom+0xc8/0x130 [ 224.462574] ? syscalltraceenter+0x1df/0x2e0 [ 224.462606] ? _dopagefault+0x2de/0x500 [ 224.462635] _x64sysrecvfrom+0x24/0x30 [ 224.462660] dosyscall64+0x5d/0x1d0 [ 224.462709] entrySYSCALL64afterhwframe+0x65/0xca
In commit 9974d37ea75f ("skmsg: Fix invalid last sg check in skmsgrecvmsg()"), we change last sg check to sgislast(), but in sockmap redirection case (without streamparser/streamverdict/ skbverdict), we did not mark the end of the scatterlist. Check the skmsgalloc, skmsgpageadd, and bpfmsgpushdata functions, they all do not mark the end of sg. They are expected to use sg.end for end judgment. So the judgment of '(i != msgrx->sg.end)' is added back here.