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

2020-10-02 Thread David Miller
From: Coly Li Date: Fri, 2 Oct 2020 16:27:27 +0800 > 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()

Re: [PATCH v9 0/7] Introduce sendpage_ok() to detect misused sendpage in network related drivers

2020-10-02 Thread David Miller
From: David Miller Date: Thu, 01 Oct 2020 12:43:45 -0700 (PDT) > Series applied and queued up for -stable, thank you. Actually, this doesn't even build: In file included from ./arch/x86/include/asm/bug.h:93, from ./include/linux/bug.h:5, from

Re: [PATCH v9 0/7] Introduce sendpage_ok() to detect misused sendpage in network related drivers

2020-10-02 Thread David Miller
From: Coly Li Date: Fri, 2 Oct 2020 16:30:12 +0800 > Obviously my fault and no excuse for leaking this uncompleted version to > you. I just re-post a v10 version which I make sure all patches are the > latest version. > > Sorry for the inconvenience and thank you in advance for taking this set.

Re: [PATCH v9 0/7] Introduce sendpage_ok() to detect misused sendpage in network related drivers

2020-10-02 Thread David Miller
From: Coly Li Date: Thu, 1 Oct 2020 15:54:01 +0800 > This series was original by a bug fix in nvme-over-tcp driver which only > checked whether a page was allocated from slab allcoator, but forgot to > check its page_count: The page handled by sendpage should be neither a > Slab page nor 0

[PATCH] iscsi: iscsi_tcp: Avoid holding spinlock while calling getpeername

2020-10-02 Thread Mark Mielke
Kernel may fail to boot or devices may fail to come up when initializing iscsi_tcp devices starting with Linux 5.8. Marc Dionne identified the cause in RHBZ#1877345. Commit a79af8a64d39 ("[SCSI] iscsi_tcp: use iscsi_conn_get_addr_param libiscsi function") introduced getpeername() within the

Re: [PATCH v2 1/1] scsi: libiscsi: fix NOP race condition

2020-10-02 Thread Lee Duncan
On 9/25/20 11:41 AM, ldun...@suse.com wrote: > From: Lee Duncan > > iSCSI NOPs are sometimes "lost", mistakenly sent to the > user-land iscsid daemon instead of handled in the kernel, > as they should be, resulting in a message from the daemon like: > >> iscsid: Got nop in, but kernel supports

Re: [PATCH v9 0/7] Introduce sendpage_ok() to detect misused sendpage in network related drivers

2020-10-02 Thread Coly Li
On 2020/10/2 03:48, David Miller wrote: > From: David Miller > Date: Thu, 01 Oct 2020 12:43:45 -0700 (PDT) > >> Series applied and queued up for -stable, thank you. > > Actually, this doesn't even build: > > In file included from ./arch/x86/include/asm/bug.h:93, > from

[PATCH v10 6/7] scsi: libiscsi: use sendpage_ok() in iscsi_tcp_segment_map()

2020-10-02 Thread Coly Li
In iscsci driver, iscsi_tcp_segment_map() uses the following code to check whether the page should or not be handled by sendpage: if (!recv && page_count(sg_page(sg)) >= 1 && !PageSlab(sg_page(sg))) The "page_count(sg_page(sg)) >= 1 && !PageSlab(sg_page(sg)" part is to make sure the page can

[PATCH v10 5/7] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage()

2020-10-02 Thread Coly Li
In _drbd_send_page() a page is checked by following code before sending it by kernel_sendpage(), (page_count(page) < 1) || PageSlab(page) If the check is true, this page won't be send by kernel_sendpage() and handled by sock_no_sendpage(). This kind of check is exactly what macro

[PATCH v10 7/7] libceph: use sendpage_ok() in ceph_tcp_sendpage()

2020-10-02 Thread Coly Li
In libceph, ceph_tcp_sendpage() does the following checks before handle the page by network layer's zero copy sendpage method, if (page_count(page) >= 1 && !PageSlab(page)) This check is exactly what sendpage_ok() does. This patch replace the open coded checks by sendpage_ok() as a code

[PATCH v10 4/7] tcp: use sendpage_ok() to detect misused .sendpage

2020-10-02 Thread Coly Li
commit a10674bf2406 ("tcp: detecting the misuse of .sendpage for Slab objects") adds the checks for Slab pages, but the pages don't have page_count are still missing from the check. Network layer's sendpage method is not designed to send page_count 0 pages neither, therefore both PageSlab() and

[PATCH v10 2/7] net: add WARN_ONCE in kernel_sendpage() for improper zero-copy send

2020-10-02 Thread Coly Li
If a page sent into kernel_sendpage() is a slab page or it doesn't have ref_count, this page is improper to send by the zero copy sendpage() method. Otherwise such page might be unexpected released in network code path and causes impredictable panic due to kernel memory management data structure

[PATCH v10 3/7] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage()

2020-10-02 Thread Coly Li
Currently nvme_tcp_try_send_data() doesn't use kernel_sendpage() to send slab pages. But for pages allocated by __get_free_pages() without __GFP_COMP, which also have refcount as 0, they are still sent by kernel_sendpage() to remote end, this is problematic. The new introduced helper

[PATCH v10 1/7] net: introduce helper sendpage_ok() in include/linux/net.h

2020-10-02 Thread Coly Li
The original problem was from nvme-over-tcp code, who mistakenly uses kernel_sendpage() to send pages allocated by __get_free_pages() without __GFP_COMP flag. Such pages don't have refcount (page_count is 0) on tail pages, sending them by kernel_sendpage() may trigger a kernel panic from a

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

2020-10-02 Thread Coly Li
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