Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1826682pxk; Sat, 26 Sep 2020 06:29:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwySIc1nh3/pWhp240kWUfM+XYhn9P95mBNLu4zFROaDOtxpJo6vhgk/TwGrK7u308HhHHi X-Received: by 2002:a50:9f6f:: with SMTP id b102mr6526508edf.272.1601126974681; Sat, 26 Sep 2020 06:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601126974; cv=none; d=google.com; s=arc-20160816; b=kmC/KF6DRRpofnb/S23j53UPgv/HS01Qe8Ub5tsqr5H8bjMtrJlfxnjVaxmOqBS9+D SFH5tVksIh/HRqxxOsdwAEYWlHb4qHNOV1QbhhYQ1cpL7Sy/6nQqqOnv7aSUmzWDOtLG SRkebKdKIXIMCFOGjAvloKJuLsdbzqeaCOzqmZ+e6RZqOZTe4Wqluty37O2AXP4LD1lP vf3F/yir2jiEDfjKDtU67AYozZdWAYILdMPlG4ge1rH+1vlJ3e/0NpsuqphX58PaUqUh 0+hVz6j2we8Yr4wBI52fwSPlzcIg4P0eTRryP8h/kILxqtPnIV5HNH1Zs7hTlj04tDto 2sOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject :autocrypt:from:references:cc:to; bh=7QgVW1yhfjohTY/8XLzdDqnFLRu+38KAhG1c3fQr2H8=; b=0wWlYauAZatEidmYXSJpO+VnfPRhWnEL1fbEE5QBsy7erJBzUCjRY9uoh/onS74vGv 5+ojqx4K6S8fu47RMEW97v/eafqdNcQJJYFRnUb+fOOVl62TNqr7MVUjq4PsW+GwYV9E tw8BLiSYuLa0GXpcvcQCWQUX/6rJ2/uvXUkYuDMDxYnyNbTod2XDKmx60mrNjoHKjVfY 3LqbKoilNrHyUi2ET/E0Ea07mgGycPilueLypkZVhxaPtu+6zSUMuLmwunhBPRu+Z4NZ WAiJYuwGcPY70jpCFpPG2kLAIIPTzOve9OyWUyUmoyoN7KZ6XG9P4Sluki8li87RmJ+M bkkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d25si3832276eje.181.2020.09.26.06.29.11; Sat, 26 Sep 2020 06:29:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729232AbgIZN2Q (ORCPT + 99 others); Sat, 26 Sep 2020 09:28:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:45634 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgIZN2P (ORCPT ); Sat, 26 Sep 2020 09:28:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CAFBAACB7; Sat, 26 Sep 2020 13:28:12 +0000 (UTC) To: Greg KH 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 , Christoph Hellwig , Hannes Reinecke , Jan Kara , Jens Axboe , Mikhail Skorzhinskii , Philipp Reisner , Sagi Grimberg , Vlastimil Babka , stable@vger.kernel.org References: <20200925150119.112016-1-colyli@suse.de> <20200925150119.112016-2-colyli@suse.de> <20200925151812.GA3182427@kroah.com> From: Coly Li Autocrypt: addr=colyli@suse.de; keydata= mQINBFYX6S8BEAC9VSamb2aiMTQREFXK4K/W7nGnAinca7MRuFUD4JqWMJ9FakNRd/E0v30F qvZ2YWpidPjaIxHwu3u9tmLKqS+2vnP0k7PRHXBYbtZEMpy3kCzseNfdrNqwJ54A430BHf2S GMVRVENiScsnh4SnaYjFVvB8SrlhTsgVEXEBBma5Ktgq9YSoy5miatWmZvHLFTQgFMabCz/P j5/xzykrF6yHo0rHZtwzQzF8rriOplAFCECp/t05+OeHHxjSqSI0P/G79Ll+AJYLRRm9til/ K6yz/1hX5xMToIkYrshDJDrUc8DjEpISQQPhG19PzaUf3vFpmnSVYprcWfJWsa2wZyyjRFkf J51S82WfclafNC6N7eRXedpRpG6udUAYOA1YdtlyQRZa84EJvMzW96iSL1Gf+ZGtRuM3k49H 1wiWOjlANiJYSIWyzJjxAd/7Xtiy/s3PRKL9u9y25ftMLFa1IljiDG+mdY7LyAGfvdtIkanr iBpX4gWXd7lNQFLDJMfShfu+CTMCdRzCAQ9hIHPmBeZDJxKq721CyBiGAhRxDN+TYiaG/UWT 7IB7LL4zJrIe/xQ8HhRO+2NvT89o0LxEFKBGg39yjTMIrjbl2ZxY488+56UV4FclubrG+t16 r2KrandM7P5RjR+cuHhkKseim50Qsw0B+Eu33Hjry7YCihmGswARAQABtBhDb2x5IExpIDxj b2x5bGlAc3VzZS5kZT6JAlYEEwEIAEACGyMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgBYh BOo+RS/0+Uhgjej60Mc5B5Nrffj8BQJcR84dBQkY++fuAAoJEMc5B5Nrffj8ixcP/3KAKg1X EcoW4u/0z+Ton5rCyb/NpAww8MuRjNW82UBUac7yCi1y3OW7NtLjuBLw5SaVG5AArb7IF3U0 qTOobqfl5XHsT0o5wFHZaKUrnHb6y7V3SplsJWfkP3JmOooJsQB3z3K96ZTkFelsNb0ZaBRu gV+LA4MomhQ+D3BCDR1it1OX/tpvm2ua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5Dag4KgKa/4cSZX2x/5+KkQx9wHwackw5gDCvAdZ+Q81nm6tRxEYBBiVDQZYqO73stgT ZyrkxykUbQIy8PI+g7XMDCMnPiDncQqgf96KR3cvw4wN8QrgA6xRo8xOc2C3X7jTMQUytCz9 0MyV1QARAQABiQI8BBgBCAAmAhsMFiEE6j5FL/T5SGCN6PrQxzkHk2t9+PwFAlxHziAFCRj7 5/EACgkQxzkHk2t9+PxgfA//cH5R1DvpJPwraTAl24SUcG9EWe+NXyqveApe05nk15zEuxxd e4zFEjo+xYZilSveLqYHrm/amvQhsQ6JLU+8N60DZHVcXbw1Eb8CEjM5oXdbcJpXh1/1BEwl 4phsQMkxOTns51bGDhTQkv4lsZKvNByB9NiiMkT43EOx14rjkhHw3rnqoI7ogu8OO7XWfKcL CbchjJ8t3c2XK1MUe056yPpNAT2XPNF2EEBPG2Y2F4vLgEbPv1EtpGUS1+JvmK3APxjXUl5z 6xrxCQDWM5AAtGfM/IswVjbZYSJYyH4BQKrShzMb0rWUjkpXvvjsjt8rEXpZEYJgX9jvCoxt oqjCKiVLpwje9WkEe9O9VxljmPvxAhVqJjX62S+TGp93iD+mvpCoHo3+CcvyRcilz+Ko8lfO hS9tYT0HDUiDLvpUyH1AR2xW9RGDevGfwGTpF0K6cLouqyZNdhlmNciX48tFUGjakRFsxRmX K0Jx4CEZubakJe+894sX6pvNFiI7qUUdB882i5GR3v9ijVPhaMr8oGuJ3kvwBIA8lvRBGVGn 9xvzkQ8Prpbqh30I4NMp8MjFdkwCN6znBKPHdjNTwE5PRZH0S9J0o67IEIvHfH0eAWAsgpTz +jwc7VKH7vkvgscUhq/v1/PEWCAqh9UHy7R/jiUxwzw/288OpgO+i+2l11Y= Subject: Re: [PATCH v8 1/7] net: introduce helper sendpage_ok() in include/linux/net.h Message-ID: <7b0d4f63-2fe5-9032-3b88-97619d8c5081@suse.de> Date: Sat, 26 Sep 2020 21:28:03 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200925151812.GA3182427@kroah.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/9/25 23:18, Greg KH wrote: > On Fri, Sep 25, 2020 at 11:01:13PM +0800, Coly Li wrote: >> 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 corrupted kernel heap, because these pages are incorrectly freed >> in network stack as page_count 0 pages. >> >> This patch introduces a helper sendpage_ok(), it returns true if the >> checking page, >> - is not slab page: PageSlab(page) is false. >> - has page refcount: page_count(page) is not zero >> >> All drivers who want to send page to remote end by kernel_sendpage() >> may use this helper to check whether the page is OK. If the helper does >> not return true, the driver should try other non sendpage method (e.g. >> sock_no_sendpage()) to handle the page. >> >> Signed-off-by: Coly Li >> Cc: Chaitanya Kulkarni >> Cc: Christoph Hellwig >> Cc: Hannes Reinecke >> Cc: Jan Kara >> Cc: Jens Axboe >> Cc: Mikhail Skorzhinskii >> Cc: Philipp Reisner >> Cc: Sagi Grimberg >> Cc: Vlastimil Babka >> Cc: stable@vger.kernel.org >> --- >> include/linux/net.h | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/include/linux/net.h b/include/linux/net.h >> index d48ff1180879..05db8690f67e 100644 >> --- a/include/linux/net.h >> +++ b/include/linux/net.h >> @@ -21,6 +21,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include >> @@ -286,6 +287,21 @@ do { \ >> #define net_get_random_once_wait(buf, nbytes) \ >> get_random_once_wait((buf), (nbytes)) >> >> +/* >> + * E.g. XFS meta- & log-data is in slab pages, or bcache meta >> + * data pages, or other high order pages allocated by >> + * __get_free_pages() without __GFP_COMP, which have a page_count >> + * of 0 and/or have PageSlab() set. We cannot use send_page for >> + * those, as that does get_page(); put_page(); and would cause >> + * either a VM_BUG directly, or __page_cache_release a page that >> + * would actually still be referenced by someone, leading to some >> + * obscure delayed Oops somewhere else. >> + */ >> +static inline bool sendpage_ok(struct page *page) >> +{ >> + return !PageSlab(page) && page_count(page) >= 1; > > Do you have one extra ' ' after "return" there? It should be fixed in next version. > > And this feels like a mm thing, why put it in net.h and not mm.h? This check is specific for kernel_sendpage(), so I want to place it closer to where kernel_sendpage() is declared. And indeed there was similar discussion about why this helper is not in mm code in v5 series. Christoph supported to place sendpage_ok() in net.h, an uncompleted piece of his opinion was "It is not a mm bug, it is a networking quirk." Thanks. Coly Li