Skip to content

Introduce sendpage_ok() to detect misused sendpage in network related drivers

Coly Li ceph-devel linux-block linux-nvme linux-scsi lkml netdev stable 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v10 Latest7 patches 3 repliesIn review
  2. v97 patches 5 repliesSuperseded
  3. v87 patches 5 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v76 patches6 repliesSuperseded
v66 patches0 repliesSuperseded
v5 posting 2/23 patches4 repliesSuperseded
v5 posting 1/23 patches2 repliesSuperseded
v42 of 3 patches0 repliesSuperseded
v13 patches0 repliesSuperseded

Changelog from the cover letter

v10, fix WARN_ONCE() usage, and add Reivewed-by tag from Lee Duncan. v9, fix a typo pointed out by Greg KH.
add Acked-by tags from Martin K. Petersen and Ilya Dryomov.
v8: add WARN_ONCE() in kernel_sendpage() as Christoph suggested.
v7: remove outer brackets from the return line of sendpage_ok() as
Eric Dumazet suggested.
v6: fix page check in do_tcp_sendpages(), as Eric Dumazet suggested.
replace other open coded checks with sendpage_ok() in libceph, iscsi drivers.
v5, include linux/mm.h in include/linux/net.h
v4, change sendpage_ok() as an inline helper, and post it as
separate patch, as Christoph Hellwig suggested.
v3, introduce a more common sendpage_ok() as Sagi Grimberg suggested. v2, fix typo in patch subject
v1, the initial version.

Patches in v10 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7net: introduce helper sendpage_ok() in include/linux/net.hinclude/linux/net.h+16 -00 replies
2/7net: add WARN_ONCE in kernel_sendpage() for improper zero-copy sendnet/socket.c+4 -20 replies
3/7nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage()drivers/nvme/host/tcp.c+3 -40 replies
4/7tcp: use sendpage_ok() to detect misused .sendpagenet/ipv4/tcp.c+2 -10 replies
5/7drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage()drivers/block/drbd/drbd_main.c+1 -10 replies
6/7scsi: libiscsi: use sendpage_ok() in iscsi_tcp_segment_map()drivers/scsi/libiscsi_tcp.c+1 -10 replies
7/7libceph: use sendpage_ok() in ceph_tcp_sendpage()net/ceph/messenger.c+1 -10 replies

Reviews trailers per patch

2 of 7 patches have a Reviewed-by or Acked-by.

PatchLee DuncanMartin K. PetersenJeff Layton
1/7
2/7
3/7
4/7
5/7
6/7R-b A-b
7/7A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v10 thread

Cover letter [PATCH v10 0/7] Introduce sendpage_ok() to detect misused sendpage in network related drivers

As Sagi Grimberg suggested, the original fix is refind to a more common inline routine:

    static inline bool sendpage_ok(struct page *page)
    {
        return  (!PageSlab(page) && page_count(page) >= 1);
    }

If sendpage_ok() returns true, the checking page can be handled by the concrete zero-copy sendpage method in network layer.

The v10 series has 7 patches, fixes a WARN_ONCE() usage from v9 series,
- The 1st patch in this series introduces sendpage_ok() in header file include/linux/net.h.
- The 2nd patch adds WARN_ONCE() for improper zero-copy send in kernel_sendpage().
- The 3rd patch fixes the page checking issue in nvme-over-tcp driver.
- The 4th patch adds page_count check by using sendpage_ok() in do_tcp_sendpages() as Eric Dumazet suggested.
- The 5th and 6th patches just replace existing open coded checks with the inline sendpage_ok() routine.

Coly Li

Cc Chaitanya Kulkarni <[email protected]>
Cc Chris Leech <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Cong Wang <[email protected]>
Cc David S. Miller <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Ilya Dryomov <[email protected]>
Cc Jan Kara <[email protected]>
Cc Jeff Layton <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Lee Duncan <[email protected]>
Cc Mike Christie <[email protected]>
Cc Mikhail Skorzhinskii <[email protected]>
Cc Philipp Reisner <[email protected]>
Cc Sagi Grimberg <[email protected]>
Cc Vasily Averin <[email protected]>
Cc Vlastimil Babka <[email protected]>

---
Changelog:
v10, fix WARN_ONCE() usage, and add Reivewed-by tag from Lee Duncan. v9, fix a typo pointed out by Greg KH.
add Acked-by tags from Martin K. Petersen and Ilya Dryomov.
v8: add WARN_ONCE() in kernel_sendpage() as Christoph suggested.
v7: remove outer brackets from the return line of sendpage_ok() as
Eric Dumazet suggested.
v6: fix page check in do_tcp_sendpages(), as Eric Dumazet suggested.
replace other open coded checks with sendpage_ok() in libceph, iscsi drivers.
v5, include linux/mm.h in include/linux/net.h
v4, change sendpage_ok() as an inline helper, and post it as
separate patch, as Christoph Hellwig suggested.
v3, introduce a more common sendpage_ok() as Sagi Grimberg suggested. v2, fix typo in patch subject
v1, the initial version.

Coly Li (7):
net: introduce helper sendpage_ok() in include/linux/net.h
net: add WARN_ONCE in kernel_sendpage() for improper zero-copy send
nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage()
tcp: use sendpage_ok() to detect misused .sendpage
drbd: code cleanup by using sendpage_ok() to check page for
kernel_sendpage()
scsi: libiscsi: use sendpage_ok() in iscsi_tcp_segment_map()
libceph: use sendpage_ok() in ceph_tcp_sendpage()

 drivers/block/drbd/drbd_main.c |  2 +-
 drivers/nvme/host/tcp.c        |  7 +++----
 drivers/scsi/libiscsi_tcp.c    |  2 +-
 include/linux/net.h            | 16 ++++++++++++++++
 net/ceph/messenger.c           |  2 +-
 net/ipv4/tcp.c                 |  3 ++-
 net/socket.c                   |  6 ++++--
 7 files changed, 28 insertions(+), 10 deletions(-)
Signature · 1 line
2.26.2