From patchwork Thu Apr 30 14:38:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 11520441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5767014B4 for ; Thu, 30 Apr 2020 14:38:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2BF372074A for ; Thu, 30 Apr 2020 14:38:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2BF372074A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D0A58E0005; Thu, 30 Apr 2020 10:38:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A7D48E0001; Thu, 30 Apr 2020 10:38:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BD138E0005; Thu, 30 Apr 2020 10:38:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id 24C6D8E0001 for ; Thu, 30 Apr 2020 10:38:44 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C87DE181AEF09 for ; Thu, 30 Apr 2020 14:38:43 +0000 (UTC) X-FDA: 76764777726.20.fight84_4c2593d821319 X-Spam-Summary: 2,0,0,7c882e6480eaeabe,d41d8cd98f00b204,imbrenda@linux.ibm.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1437:1515:1535:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:2736:2918:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3874:4250:5007:6261:6742:7903:8660:8957:10004:11026:11658:11914:12043:12297:12438:12555:12663:12679:12895:13069:13148:13161:13208:13229:13230:13311:13357:13894:14096:14181:14384:14394:14721:21067:21080:21212:21451:21627:21740:21990:30054,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:31,LUA_SUMMARY:none X-HE-Tag: fight84_4c2593d821319 X-Filterd-Recvd-Size: 5255 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Thu, 30 Apr 2020 14:38:43 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03UEa6KC117198; Thu, 30 Apr 2020 10:38:32 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30q7qk14mg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Apr 2020 10:38:32 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 03UEaI32118447; Thu, 30 Apr 2020 10:38:31 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 30q7qk14k1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Apr 2020 10:38:31 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 03UEZhnv012766; Thu, 30 Apr 2020 14:38:29 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma05fra.de.ibm.com with ESMTP id 30mcu52r72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Apr 2020 14:38:29 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03UEcQwT60882962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Apr 2020 14:38:27 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF50A52057; Thu, 30 Apr 2020 14:38:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.14.241]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 28F3A52052; Thu, 30 Apr 2020 14:38:26 +0000 (GMT) From: Claudio Imbrenda To: viro@zeniv.linux.org.uk Cc: borntraeger@de.ibm.com, david@redhat.com, akpm@linux-foundation.org, aarcange@redhat.com, linux-mm@kvack.org, frankja@linux.ibm.com, sfr@canb.auug.org.au, jhubbard@nvidia.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, jack@suse.cz, kirill@shutemov.name, dave.hansen@intel.com, peterz@infradead.org, sean.j.christopherson@intel.com, Ulrich.Weigand@de.ibm.com Subject: [PATCH v2 1/1] fs/splice: add missing callback for inaccessible pages Date: Thu, 30 Apr 2020 16:38:25 +0200 Message-Id: <20200430143825.3534128-1-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-30_09:2020-04-30,2020-04-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 suspectscore=1 mlxlogscore=978 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004300120 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Inaccessible pages are pages that should not be accessed by any device, and belong to a protected VM. If any such pages are passed to a device, there will be I/O errors, which will not always be recoverable, depending on the architecture and on the specific device. CPU accesses to inaccessible pages are less problematic, since they are always recoverable. Page cache and direct I/O were fixed in a previous patch, in which a architecture hook is provided to make the page accessible by I/O devices. One possible remaining path to sneak a protected page directly to a device is sendfile and similar syscalls. Those syscalls take a page directly from the page cache and give them directly to the device with zero-copy. This bypasses both existing hooks in gup and in writeback. This patch fixes the issue by adding a call to arch_make_page_accessible in page_cache_pipe_buf_confirm, thus fixing the issue. Notice that we only need to make sure the source is accessible, since zero-copy only works in one direction, and CPU accesses to inaccessible pages are not a problem. Pagecache-to-pagecache is also not a problem since that is done by the CPU. The hook has no overhead for architectures that do not need to deal with inaccessible pages. Fixes: f28d43636d6f ("mm/gup/writeback: add callbacks for inaccessible pages") Signed-off-by: Claudio Imbrenda Acked-by: Christian Borntraeger --- fs/splice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index 4735defc46ee..f026e0ce9acd 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -106,6 +106,9 @@ static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe, struct page *page = buf->page; int err; + if (arch_make_page_accessible(page)) + return -EIO; + if (!PageUptodate(page)) { lock_page(page);