All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels
@ 2017-11-22 22:24 alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 2/9] vti6: fix device register to report IFLA_INFO_KIND alexander.levin
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Peter Ujfalusi, Tony Lindgren, alexander.levin

From: Peter Ujfalusi <peter.ujfalusi@ti.com>

[ Upstream commit 657279778af54f35e54b07b6687918f254a2992c ]

OMAP1510, OMAP5910 and OMAP310 have only 9 logical channels.
OMAP1610, OMAP5912, OMAP1710, OMAP730, and OMAP850 have 16 logical channels
available.

The wired 17 for the lch_count must have been used to cover the 16 + 1
dedicated LCD channel, in reality we can only use 9 or 16 channels.

The d->chan_count is not used by the omap-dma stack, so we can skip the
setup. chan_count was configured to the number of logical channels and not
the actual number of physical channels anyways.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/arm/mach-omap1/dma.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c
index 4be601b638d7..8129e5f9c94d 100644
--- a/arch/arm/mach-omap1/dma.c
+++ b/arch/arm/mach-omap1/dma.c
@@ -31,7 +31,6 @@
 #include <mach/irqs.h>
 
 #define OMAP1_DMA_BASE			(0xfffed800)
-#define OMAP1_LOGICAL_DMA_CH_COUNT	17
 
 static u32 enable_1510_mode;
 
@@ -311,8 +310,6 @@ static int __init omap1_system_dma_init(void)
 		goto exit_iounmap;
 	}
 
-	d->lch_count		= OMAP1_LOGICAL_DMA_CH_COUNT;
-
 	/* Valid attributes for omap1 plus processors */
 	if (cpu_is_omap15xx())
 		d->dev_caps = ENABLE_1510_MODE;
@@ -329,13 +326,14 @@ static int __init omap1_system_dma_init(void)
 	d->dev_caps		|= CLEAR_CSR_ON_READ;
 	d->dev_caps		|= IS_WORD_16;
 
-	if (cpu_is_omap15xx())
-		d->chan_count = 9;
-	else if (cpu_is_omap16xx() || cpu_is_omap7xx()) {
-		if (!(d->dev_caps & ENABLE_1510_MODE))
-			d->chan_count = 16;
+	/* available logical channels */
+	if (cpu_is_omap15xx()) {
+		d->lch_count = 9;
+	} else {
+		if (d->dev_caps & ENABLE_1510_MODE)
+			d->lch_count = 9;
 		else
-			d->chan_count = 9;
+			d->lch_count = 16;
 	}
 
 	p = dma_plat_info;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 2/9] vti6: fix device register to report IFLA_INFO_KIND
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 4/9] nfs: Don't take a reference on fl->fl_file for LOCK operation alexander.levin
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: David Forster, David S . Miller, alexander.levin

From: David Forster <dforster@brocade.com>

[ Upstream commit 93e246f783e6bd1bc64fdfbfe68b18161f69b28e ]

vti6 interface is registered before the rtnl_link_ops block
is attached. As a result the resulting RTM_NEWLINK is missing
IFLA_INFO_KIND. Re-order attachment of rtnl_link_ops block to fix.

Signed-off-by: Dave Forster <dforster@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv6/ip6_vti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index a11083d37789..91fdb612279f 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -172,12 +172,12 @@ static int vti6_tnl_create2(struct net_device *dev)
 	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
 	int err;
 
+	dev->rtnl_link_ops = &vti6_link_ops;
 	err = register_netdevice(dev);
 	if (err < 0)
 		goto out;
 
 	strcpy(t->parms.name, dev->name);
-	dev->rtnl_link_ops = &vti6_link_ops;
 
 	dev_hold(dev);
 	vti6_tnl_link(ip6n, t);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 6/9] net: sctp: fix array overrun read on sctp_timer_tbl
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
                   ` (3 preceding siblings ...)
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 5/9] NFSv4: Fix client recovery when server reboots multiple times alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 8/9] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers alexander.levin
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Colin Ian King, David S . Miller, alexander.levin

From: Colin Ian King <colin.king@canonical.com>

[ Upstream commit 0e73fc9a56f22f2eec4d2b2910c649f7af67b74d ]

The comparison on the timeout can lead to an array overrun
read on sctp_timer_tbl because of an off-by-one error. Fix
this by using < instead of <= and also compare to the array
size rather than SCTP_EVENT_TIMEOUT_MAX.

Fixes CoverityScan CID#1397639 ("Out-of-bounds read")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/sctp/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/debug.c b/net/sctp/debug.c
index 95d7b15dad21..e371a0d90068 100644
--- a/net/sctp/debug.c
+++ b/net/sctp/debug.c
@@ -166,7 +166,7 @@ static const char *const sctp_timer_tbl[] = {
 /* Lookup timer debug name. */
 const char *sctp_tname(const sctp_subtype_t id)
 {
-	if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
+	if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
 		return sctp_timer_tbl[id.timeout];
 	return "unknown_timer";
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 5/9] NFSv4: Fix client recovery when server reboots multiple times
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
                   ` (2 preceding siblings ...)
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 3/9] net/appletalk: Fix kernel memory disclosure alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 6/9] net: sctp: fix array overrun read on sctp_timer_tbl alexander.levin
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Trond Myklebust, alexander.levin

From: Trond Myklebust <trond.myklebust@primarydata.com>

[ Upstream commit c6180a6237174f481dc856ed6e890d8196b6f0fb ]

If the server reboots multiple times, the client should rely on the
server to tell it that it cannot reclaim state as per section 9.6.3.4
in RFC7530 and section 8.4.2.1 in RFC5661.
Currently, the client is being to conservative, and is assuming that
if the server reboots while state recovery is in progress, then it must
ignore state that was not recovered before the reboot.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/nfs/nfs4state.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 1f9d57ab8df4..f471662c0a1f 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1650,7 +1650,6 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
 			break;
 		case -NFS4ERR_STALE_CLIENTID:
 			set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
-			nfs4_state_clear_reclaim_reboot(clp);
 			nfs4_state_start_reclaim_reboot(clp);
 			break;
 		case -NFS4ERR_EXPIRED:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 4/9] nfs: Don't take a reference on fl->fl_file for LOCK operation
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 2/9] vti6: fix device register to report IFLA_INFO_KIND alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 3/9] net/appletalk: Fix kernel memory disclosure alexander.levin
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Benjamin Coddington, Trond Myklebust, alexander.levin

From: Benjamin Coddington <bcodding@redhat.com>

[ Upstream commit 4b09ec4b14a168bf2c687e1f598140c3c11e9222 ]

I have reports of a crash that look like __fput() was called twice for
a NFSv4.0 file.  It seems possible that the state manager could try to
reclaim a lock and take a reference on the fl->fl_file at the same time the
file is being released if, during the close(), a signal interrupts the wait
for outstanding IO while removing locks which then skips the removal
of that lock.

Since 83bfff23e9ed ("nfs4: have do_vfs_lock take an inode pointer") has
removed the need to traverse fl->fl_file->f_inode in nfs4_lock_done(),
taking that reference is no longer necessary.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/nfs/nfs4proc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index dbd010051b33..f3a9626af42b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -38,7 +38,6 @@
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
-#include <linux/file.h>
 #include <linux/string.h>
 #include <linux/ratelimit.h>
 #include <linux/printk.h>
@@ -5547,7 +5546,6 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
 	p->server = server;
 	atomic_inc(&lsp->ls_count);
 	p->ctx = get_nfs_open_context(ctx);
-	get_file(fl->fl_file);
 	memcpy(&p->fl, fl, sizeof(p->fl));
 	return p;
 out_free_seqid:
@@ -5637,7 +5635,6 @@ static void nfs4_lock_release(void *calldata)
 		nfs_free_seqid(data->arg.lock_seqid);
 	nfs4_put_lock_state(data->lsp);
 	put_nfs_open_context(data->ctx);
-	fput(data->fl.fl_file);
 	kfree(data);
 	dprintk("%s: done!\n", __func__);
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 3/9] net/appletalk: Fix kernel memory disclosure
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 2/9] vti6: fix device register to report IFLA_INFO_KIND alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 4/9] nfs: Don't take a reference on fl->fl_file for LOCK operation alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 5/9] NFSv4: Fix client recovery when server reboots multiple times alexander.levin
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Vlad Tsyrklevich, David S . Miller, alexander.levin

From: Vlad Tsyrklevich <vlad@tsyrklevich.net>

[ Upstream commit ce7e40c432ba84da104438f6799d460a4cad41bc ]

ipddp_route structs contain alignment padding so kernel heap memory
is leaked when they are copied to user space in
ipddp_ioctl(SIOCFINDIPDDPRT). Change kmalloc() to kzalloc() to clear
that memory.

Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/appletalk/ipddp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index e90c6a7333d7..2e4649655181 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -191,7 +191,7 @@ static netdev_tx_t ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
  */
 static int ipddp_create(struct ipddp_route *new_rt)
 {
-        struct ipddp_route *rt = kmalloc(sizeof(*rt), GFP_KERNEL);
+        struct ipddp_route *rt = kzalloc(sizeof(*rt), GFP_KERNEL);
 
         if (rt == NULL)
                 return -ENOMEM;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 9/9] net: fec: fix multicast filtering hardware setup
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
                   ` (5 preceding siblings ...)
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 8/9] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 7/9] tipc: fix cleanup at module unload alexander.levin
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Rui Sousa, Fugang Duan, David S . Miller, alexander.levin

From: Rui Sousa <rui.sousa@nxp.com>

[ Upstream commit 01f8902bcf3ff124d0aeb88a774180ebcec20ace ]

Fix hardware setup of multicast address hash:
- Never clear the hardware hash (to avoid packet loss)
- Construct the hash register values in software and then write once
to hardware

Signed-off-by: Rui Sousa <rui.sousa@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 51f65299094b..065a7616e961 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2793,6 +2793,7 @@ static void set_multicast_list(struct net_device *ndev)
 	struct netdev_hw_addr *ha;
 	unsigned int i, bit, data, crc, tmp;
 	unsigned char hash;
+	unsigned int hash_high = 0, hash_low = 0;
 
 	if (ndev->flags & IFF_PROMISC) {
 		tmp = readl(fep->hwp + FEC_R_CNTRL);
@@ -2815,11 +2816,7 @@ static void set_multicast_list(struct net_device *ndev)
 		return;
 	}
 
-	/* Clear filter and add the addresses in hash register
-	 */
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-
+	/* Add the addresses in hash register */
 	netdev_for_each_mc_addr(ha, ndev) {
 		/* calculate crc32 value of mac address */
 		crc = 0xffffffff;
@@ -2837,16 +2834,14 @@ static void set_multicast_list(struct net_device *ndev)
 		 */
 		hash = (crc >> (32 - HASH_BITS)) & 0x3f;
 
-		if (hash > 31) {
-			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-			tmp |= 1 << (hash - 32);
-			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-		} else {
-			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-			tmp |= 1 << hash;
-			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-		}
+		if (hash > 31)
+			hash_high |= 1 << (hash - 32);
+		else
+			hash_low |= 1 << hash;
 	}
+
+	writel(hash_high, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+	writel(hash_low, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
 }
 
 /* Set a MAC change in hardware. */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 7/9] tipc: fix cleanup at module unload
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
                   ` (6 preceding siblings ...)
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 9/9] net: fec: fix multicast filtering hardware setup alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Parthasarathy Bhuvaragan, David S . Miller, alexander.levin

From: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>

[ Upstream commit 35e22e49a5d6a741ebe7f2dd280b2052c3003ef7 ]

In tipc_server_stop(), we iterate over the connections with limiting
factor as server's idr_in_use. We ignore the fact that this variable
is decremented in tipc_close_conn(), leading to premature exit.

In this commit, we iterate until the we have no connections left.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Tested-by: John Thompson <thompa.atl@gmail.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/tipc/server.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/tipc/server.c b/net/tipc/server.c
index a538a02f869b..0411fac14226 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -579,14 +579,12 @@ int tipc_server_start(struct tipc_server *s)
 void tipc_server_stop(struct tipc_server *s)
 {
 	struct tipc_conn *con;
-	int total = 0;
 	int id;
 
 	spin_lock_bh(&s->idr_lock);
-	for (id = 0; total < s->idr_in_use; id++) {
+	for (id = 0; s->idr_in_use; id++) {
 		con = idr_find(&s->conn_idr, id);
 		if (con) {
-			total++;
 			spin_unlock_bh(&s->idr_lock);
 			tipc_close_conn(con);
 			spin_lock_bh(&s->idr_lock);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH AUTOSEL for 3.18 8/9] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers
  2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
                   ` (4 preceding siblings ...)
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 6/9] net: sctp: fix array overrun read on sctp_timer_tbl alexander.levin
@ 2017-11-22 22:24 ` alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 9/9] net: fec: fix multicast filtering hardware setup alexander.levin
  2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 7/9] tipc: fix cleanup at module unload alexander.levin
  7 siblings, 0 replies; 9+ messages in thread
From: alexander.levin @ 2017-11-22 22:24 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jan Kara, Matthew Wilcox, Andrew Morton, Linus Torvalds, alexander.levin

From: Jan Kara <jack@suse.cz>

[ Upstream commit 0911d0041c22922228ca52a977d7b0b0159fee4b ]

Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return
code (GFS2 or Lustre can definitely do this).  However VM_FAULT_RETRY
from ->page_mkwrite is completely unhandled by the mm code and results
in locking and writeably mapping the page which definitely is not what
the caller wanted.

Fix Lustre and block_page_mkwrite_ret() used by other filesystems
(notably GFS2) to return VM_FAULT_NOPAGE instead which results in
bailing out from the fault code, the CPU then retries the access, and we
fault again effectively doing what the handler wanted.

Link: http://lkml.kernel.org/r/20170203150729.15863-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +---
 include/linux/buffer_head.h                      | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index ae605a6d9dc2..dde9fd9a39b9 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -407,15 +407,13 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 		result = VM_FAULT_LOCKED;
 		break;
 	case -ENODATA:
+	case -EAGAIN:
 	case -EFAULT:
 		result = VM_FAULT_NOPAGE;
 		break;
 	case -ENOMEM:
 		result = VM_FAULT_OOM;
 		break;
-	case -EAGAIN:
-		result = VM_FAULT_RETRY;
-		break;
 	default:
 		result = VM_FAULT_SIGBUS;
 		break;
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 73b45225a7ca..f6675ffe41ed 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -236,12 +236,10 @@ static inline int block_page_mkwrite_return(int err)
 {
 	if (err == 0)
 		return VM_FAULT_LOCKED;
-	if (err == -EFAULT)
+	if (err == -EFAULT || err == -EAGAIN)
 		return VM_FAULT_NOPAGE;
 	if (err == -ENOMEM)
 		return VM_FAULT_OOM;
-	if (err == -EAGAIN)
-		return VM_FAULT_RETRY;
 	/* -ENOSPC, -EDQUOT, -EIO ... */
 	return VM_FAULT_SIGBUS;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-22 23:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 22:24 [PATCH AUTOSEL for 3.18 1/9] ARM: OMAP1: DMA: Correct the number of logical channels alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 2/9] vti6: fix device register to report IFLA_INFO_KIND alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 4/9] nfs: Don't take a reference on fl->fl_file for LOCK operation alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 3/9] net/appletalk: Fix kernel memory disclosure alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 5/9] NFSv4: Fix client recovery when server reboots multiple times alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 6/9] net: sctp: fix array overrun read on sctp_timer_tbl alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 8/9] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 9/9] net: fec: fix multicast filtering hardware setup alexander.levin
2017-11-22 22:24 ` [PATCH AUTOSEL for 3.18 7/9] tipc: fix cleanup at module unload alexander.levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.