Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	netdev@vger.kernel.org, open-iscsi@googlegroups.com,
	linux-scsi@vger.kernel.org, ceph-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	Hannes Reinecke <hare@suse.de>, Jan Kara <jack@suse.com>,
	Jens Axboe <axboe@kernel.dk>,
	Mikhail Skorzhinskii <mskorzhinskiy@solarflare.com>,
	Philipp Reisner <philipp.reisner@linbit.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Vlastimil Babka <vbabka@suse.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v7 1/6] net: introduce helper sendpage_ok() in include/linux/net.h
Date: Wed, 19 Aug 2020 00:33:37 +0800	[thread overview]
Message-ID: <217ec0ec-3c5a-a8ed-27d9-c634f0b9a045@suse.de> (raw)
In-Reply-To: <20200818162404.GA27196@lst.de>

On 2020/8/19 00:24, Christoph Hellwig wrote:
> I think we should go for something simple like this instead:

This idea is fine to me. Should a warning message be through here? IMHO
the driver still sends an improper page in, fix it in silence is too
kind or over nice to the buggy driver(s).

And maybe the fix in nvme-tcp driver and do_tcp_sendpages() are still
necessary. I am not network expert, this is my opinion for reference.

Coly Li

> ---
> From 4867e158ee86ebd801b4c267e8f8a4a762a71343 Mon Sep 17 00:00:00 2001
> From: Christoph Hellwig <hch@lst.de>
> Date: Tue, 18 Aug 2020 18:19:23 +0200
> Subject: net: bypass ->sendpage for slab pages
> 
> Sending Slab or tail pages into ->sendpage will cause really strange
> delayed oops.  Prevent it right in the networking code instead of
> requiring drivers to work around the fact.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  net/socket.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/net/socket.c b/net/socket.c
> index dbbe8ea7d395da..fbc82eb96d18ce 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -3638,7 +3638,12 @@ EXPORT_SYMBOL(kernel_getpeername);
>  int kernel_sendpage(struct socket *sock, struct page *page, int offset,
>  		    size_t size, int flags)
>  {
> -	if (sock->ops->sendpage)
> +	/*
> +	 * sendpage does manipulates the refcount of the passed in page, which
> +	 * does not work for Slab pages, or for tails of non-__GFP_COMP
> +	 * high order pages.
> +	 */
> +	if (sock->ops->sendpage && !PageSlab(page) && page_count(page) > 0)
>  		return sock->ops->sendpage(sock, page, offset, size, flags);
>  
>  	return sock_no_sendpage(sock, page, offset, size, flags);
> 


  reply	other threads:[~2020-08-18 16:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 13:12 [PATCH v7 0/6] Introduce sendpage_ok() to detect misused sendpage in network related drivers Coly Li
2020-08-18 13:12 ` [PATCH v7 1/6] net: introduce helper sendpage_ok() in include/linux/net.h Coly Li
2020-08-18 16:24   ` Christoph Hellwig
2020-08-18 16:33     ` Coly Li [this message]
2020-08-18 19:49       ` Christoph Hellwig
2020-08-19  4:22         ` Coly Li
2020-09-23  8:43           ` Christoph Hellwig
2020-09-23  8:45             ` Coly Li
2020-08-18 13:12 ` [PATCH v7 2/6] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Coly Li
2020-08-18 13:12 ` [PATCH v7 3/6] tcp: use sendpage_ok() to detect misused .sendpage Coly Li
2020-08-18 13:12 ` [PATCH v7 4/6] drbd: code cleanup by using sendpage_ok() to check page for kernel_sendpage() Coly Li
2020-08-18 13:12 ` [PATCH v7 5/6] scsi: libiscsi: use sendpage_ok() in iscsi_tcp_segment_map() Coly Li
2020-08-18 13:12 ` [PATCH v7 6/6] libceph: use sendpage_ok() in ceph_tcp_sendpage() Coly Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=217ec0ec-3c5a-a8ed-27d9-c634f0b9a045@suse.de \
    --to=colyli@suse.de \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jack@suse.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mskorzhinskiy@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=open-iscsi@googlegroups.com \
    --cc=philipp.reisner@linbit.com \
    --cc=sagi@grimberg.me \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.com \
    --subject='Re: [PATCH v7 1/6] net: introduce helper sendpage_ok() in include/linux/net.h' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).