From patchwork Mon May 20 05:57:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1101813 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PZxqn86K"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 456p9X1ZnGz9s6w for ; Mon, 20 May 2019 15:58:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3zGQUw30mfuKUKm4eszxsZW+iVvGU2l1wV8zRwP0Elg=; b=PZxqn86Kgw/QkE 6RohwmJF7K1/IZORIaNJjO4GImugMRu2KNpHxtQztZswsdK4Ubhz1b4XAq5tLdmdFcgTHEFbGeU7H 58wnJj26lgUVaJgZByRDEbq8bMLkz8lCeSGf/JnKMhbUSBx2XYIOjJu06xxDxj72WpNFTY/OQwupB 0D1dcWs9iB5rB8e6XtldRBHVJyv35EkVPRH61oTqxSLKWxVQh8Jd86cYKoYEwrHGpJLBeUpQmyjUe WPtT1rNd+Pcrz+1fZH8wsiXLA8JKYqlVR/3PHdPG0X/3LRPhbhbA+/7WYm9OfpVmlNrWhdxdrXcGB TdR+v3GLo2Q1tQ5stTjg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbJi-0006N4-MJ; Mon, 20 May 2019 05:58:34 +0000 Received: from 089144206147.atnat0015.highway.bob.at ([89.144.206.147] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbJa-0006Eo-Oh; Mon, 20 May 2019 05:58:28 +0000 From: Christoph Hellwig To: Andrew Morton Subject: [PATCH 1/4] mm: fix an overly long line in read_cache_page Date: Mon, 20 May 2019 07:57:28 +0200 Message-Id: <20190520055731.24538-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520055731.24538-1-hch@lst.de> References: <20190520055731.24538-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nfs@vger.kernel.org, Kees Cook , Nick Desaulniers , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, Sami Tolvanen Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Christoph Hellwig Reviewed-by: Kees Cook --- mm/filemap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index c5af80c43d36..6a8048477bc6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2862,7 +2862,8 @@ struct page *read_cache_page(struct address_space *mapping, int (*filler)(void *, struct page *), void *data) { - return do_read_cache_page(mapping, index, filler, data, mapping_gfp_mask(mapping)); + return do_read_cache_page(mapping, index, filler, data, + mapping_gfp_mask(mapping)); } EXPORT_SYMBOL(read_cache_page); From patchwork Mon May 20 05:57:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1101814 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KNUL7Nyz"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 456p9h5tw3z9s55 for ; Mon, 20 May 2019 15:58:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rfglLSXDvrKcHjcsfnBWBdXT+sZecKalHClpfIcOroQ=; b=KNUL7NyznCzwIk 15/hHyKNnuL/BdtoAQvl555m7Dwi+jsO545tQBdJH8fXSxs8ZG4iO1Jp5hHF57iCdEbi34c6GQJgr pzLuA7gKBLImApxlQnDHn+Oq0+6Acrl3WhQOC4n0r32mcpDm6zySRYjLHVkvFBRxaYa4BLVpnxjNO ft+O00ozE6zEYV9C+8Bq3M8qWgDreaZrL92QKf7/udP8WPYitYzk7qxtSEv0rDC6J7EgG+ZI4zuTy 3g1Auxwtx3udCzMsC1AaQSz4HezSKzVWxhEpJozFafG8fj+YNuIchnGLdL56pT/SUwE466xFT2m9s c+a9brmtOjVBkfofbQ8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbJs-0006c9-1z; Mon, 20 May 2019 05:58:44 +0000 Received: from 089144206147.atnat0015.highway.bob.at ([89.144.206.147] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbJe-0006FV-Qn; Mon, 20 May 2019 05:58:31 +0000 From: Christoph Hellwig To: Andrew Morton Subject: [PATCH 2/4] mm: don't cast ->readpage to filler_t for do_read_cache_page Date: Mon, 20 May 2019 07:57:29 +0200 Message-Id: <20190520055731.24538-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520055731.24538-1-hch@lst.de> References: <20190520055731.24538-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nfs@vger.kernel.org, Kees Cook , Nick Desaulniers , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, Sami Tolvanen Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We can just pass a NULL filler and do the right thing inside of do_read_cache_page based on the NULL parameter. Signed-off-by: Christoph Hellwig Reviewed-by: Kees Cook --- include/linux/pagemap.h | 3 +-- mm/filemap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 9ec3544baee2..6dd7ec95c778 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -396,8 +396,7 @@ extern int read_cache_pages(struct address_space *mapping, static inline struct page *read_mapping_page(struct address_space *mapping, pgoff_t index, void *data) { - filler_t *filler = (filler_t *)mapping->a_ops->readpage; - return read_cache_page(mapping, index, filler, data); + return read_cache_page(mapping, index, NULL, data); } /* diff --git a/mm/filemap.c b/mm/filemap.c index 6a8048477bc6..3bec6e18b763 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2772,7 +2772,11 @@ static struct page *do_read_cache_page(struct address_space *mapping, } filler: - err = filler(data, page); + if (filler) + err = filler(data, page); + else + err = mapping->a_ops->readpage(data, page); + if (err < 0) { put_page(page); return ERR_PTR(err); @@ -2884,9 +2888,7 @@ struct page *read_cache_page_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp) { - filler_t *filler = (filler_t *)mapping->a_ops->readpage; - - return do_read_cache_page(mapping, index, filler, NULL, gfp); + return do_read_cache_page(mapping, index, NULL, NULL, gfp); } EXPORT_SYMBOL(read_cache_page_gfp); From patchwork Mon May 20 05:57:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1101815 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nd3wV5Kr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 456p9t66JFz9s9N for ; Mon, 20 May 2019 15:58:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V9jZPQkNl1jeOARZPxxwYAzs3xwMHeqobVKaMUOSVmU=; b=nd3wV5KrOUnW4T qjcuWEck7YMspKmpygLkuHv+DVtSwiLIMNrYltaJFpAasShgcNgyo8JVVN54pVdm1W9sgXck39OJZ QcBaJmLlb2t8FGoipGU6TKePjApKknnS3k9735ydAFT+pmdIw3+zzvQmdiN92KTEkUBqlUqF9uIPK Prk90DIUrlVHknD5qg4KxZzmBtOxjwsAsWDbu8rMRMqZ3n7+vZ2ener9TX1S8vdUBaSwdE/TJ0A64 FPUyW+om495nVSOO+8dFqP6fRaZ8oC1JqUEKG3imBrSPVLFSCxeyfmTaReSIOmJ0m83Jt/W1AWm4u HuuO3x3JzmaS5aFFmqDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbK2-0006tO-KK; Mon, 20 May 2019 05:58:54 +0000 Received: from 089144206147.atnat0015.highway.bob.at ([89.144.206.147] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbJh-0006Js-Q9; Mon, 20 May 2019 05:58:34 +0000 From: Christoph Hellwig To: Andrew Morton Subject: [PATCH 3/4] jffs2: pass the correct prototype to read_cache_page Date: Mon, 20 May 2019 07:57:30 +0200 Message-Id: <20190520055731.24538-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520055731.24538-1-hch@lst.de> References: <20190520055731.24538-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nfs@vger.kernel.org, Kees Cook , Nick Desaulniers , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, Sami Tolvanen Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Fix the callback jffs2 passes to read_cache_page to actually have the proper type expected. Casting around function pointers can easily hide typing bugs, and defeats control flow protection. Signed-off-by: Christoph Hellwig Reviewed-by: Kees Cook --- fs/jffs2/file.c | 4 ++-- fs/jffs2/fs.c | 2 +- fs/jffs2/os-linux.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 7d8654a1472e..f8fb89b10227 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -109,9 +109,9 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) return ret; } -int jffs2_do_readpage_unlock(struct inode *inode, struct page *pg) +int jffs2_do_readpage_unlock(void *data, struct page *pg) { - int ret = jffs2_do_readpage_nolock(inode, pg); + int ret = jffs2_do_readpage_nolock(data, pg); unlock_page(pg); return ret; } diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 112d85849db1..8a20ddd25f2d 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -687,7 +687,7 @@ unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, struct page *pg; pg = read_cache_page(inode->i_mapping, offset >> PAGE_SHIFT, - (void *)jffs2_do_readpage_unlock, inode); + jffs2_do_readpage_unlock, inode); if (IS_ERR(pg)) return (void *)pg; diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index a2dbbb3f4c74..bd3d5f0ddc34 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h @@ -155,7 +155,7 @@ extern const struct file_operations jffs2_file_operations; extern const struct inode_operations jffs2_file_inode_operations; extern const struct address_space_operations jffs2_file_address_operations; int jffs2_fsync(struct file *, loff_t, loff_t, int); -int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg); +int jffs2_do_readpage_unlock(void *data, struct page *pg); /* ioctl.c */ long jffs2_ioctl(struct file *, unsigned int, unsigned long); From patchwork Mon May 20 05:57:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1101816 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Sb/t+XT/"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 456pB72rfNz9s55 for ; Mon, 20 May 2019 15:59:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TgsyTHcnb9PTuJQ/lL5LPfG3yvcEBunWmgpmwrZBEj4=; b=Sb/t+XT/u6TZtt xBZTXa4mkK1j5Wc5eEEb63JDopHp+5ET3P8NsYJhBHkvXBkb7n81/DAzzrdkihMXYzjeJ2tExNuB4 70BzIm8yCzfjVYdmj4Asu6QwfZKq0+20YJjm/7+tvOl4AQy5k4xP2FFOjdq6yQv1moPu8pxae5olw yuMTHp6XLmhuoE16RiYEqgVnY3P6HaDCMpnPev0h48zxCgyZec8rbRgp8WpDMHgkhE+gABX1oKrFl VwS6zpl1iJnyrNE21szHB9zVdegRr1SLF88PyGxWvfI3bOq5HnB/wSIPu47sAt7Kj0m4Nc5x7okej jZh47whQWwMHgAkB1d0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbKD-0007AZ-Ik; Mon, 20 May 2019 05:59:05 +0000 Received: from 089144206147.atnat0015.highway.bob.at ([89.144.206.147] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSbJk-0006OG-Cl; Mon, 20 May 2019 05:58:36 +0000 From: Christoph Hellwig To: Andrew Morton Subject: [PATCH 4/4] 9p: pass the correct prototype to read_cache_page Date: Mon, 20 May 2019 07:57:31 +0200 Message-Id: <20190520055731.24538-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520055731.24538-1-hch@lst.de> References: <20190520055731.24538-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nfs@vger.kernel.org, Kees Cook , Nick Desaulniers , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, Sami Tolvanen Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Fix the callback 9p passes to read_cache_page to actually have the proper type expected. Casting around function pointers can easily hide typing bugs, and defeats control flow protection. Signed-off-by: Christoph Hellwig Reviewed-by: Kees Cook --- fs/9p/vfs_addr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 0bcbcc20f769..02e0fc51401e 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c @@ -50,8 +50,9 @@ * @page: structure to page * */ -static int v9fs_fid_readpage(struct p9_fid *fid, struct page *page) +static int v9fs_fid_readpage(void *data, struct page *page) { + struct p9_fid *fid = data; struct inode *inode = page->mapping->host; struct bio_vec bvec = {.bv_page = page, .bv_len = PAGE_SIZE}; struct iov_iter to; @@ -122,7 +123,8 @@ static int v9fs_vfs_readpages(struct file *filp, struct address_space *mapping, if (ret == 0) return ret; - ret = read_cache_pages(mapping, pages, (void *)v9fs_vfs_readpage, filp); + ret = read_cache_pages(mapping, pages, v9fs_fid_readpage, + filp->private_data); p9_debug(P9_DEBUG_VFS, " = %d\n", ret); return ret; }