Skip to content

Commit

Permalink
scsi: libiscsi: fall back to sendmsg for slab pages
Browse files Browse the repository at this point in the history
In "XFS over network block device" scenario XFS can create IO requests with
slab-based XFS metadata. During processing such requests tcp_sendpage() can
merge skb fragments with neighbour slab objects.

If receiving side is located on the same host tcp_recvmsg() can trigger
BUG_ON in hardening check and crash the host with following message:

usercopy: kernel memory exposure attempt detected
		from XXXXXXXX (kmalloc-512) (1024 bytes)

This patch redirect such requests from sednpage to sendmsg path.  The
problem is similar to one described in recent commit 7e241f6
("libceph: fall back to sendmsg for slab pages")

Signed-off-by: Vasily Averin <[email protected]>
Acked-by: Chris Leech <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
vaverin authored and martinkpetersen committed Mar 7, 2019
1 parent 038d710 commit 08b11ea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/scsi/libiscsi_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,17 @@ static void iscsi_tcp_segment_map(struct iscsi_segment *segment, int recv)
BUG_ON(sg->length == 0);

/*
* We always map for the recv path.
*
* If the page count is greater than one it is ok to send
* to the network layer's zero copy send path. If not we
* have to go the slow sendmsg path. We always map for the
* recv path.
* have to go the slow sendmsg path.
*
* Same goes for slab pages: skb_can_coalesce() allows
* coalescing neighboring slab objects into a single frag which
* triggers one of hardened usercopy checks.
*/
if (page_count(sg_page(sg)) >= 1 && !recv)
if (!recv && page_count(sg_page(sg)) >= 1 && !PageSlab(sg_page(sg)))
return;

if (recv) {
Expand Down

0 comments on commit 08b11ea

Please sign in to comment.