Skip to content

Commit 12bb321

Browse files
committed
[linux318] update pre-patch
1 parent 1874c2d commit 12bb321

File tree

1 file changed

+267
-0
lines changed

1 file changed

+267
-0
lines changed

linux318/prepatch-3.18-20170318 linux318/prepatch-3.18-20170406

+267
Original file line numberDiff line numberDiff line change
@@ -4774,3 +4774,270 @@ Signed-off-by: Greg Kroah-Hartman <[email protected]>
47744774
} /* end of n_hdlc_buf_get() */
47754775

47764776
static char hdlc_banner[] __initdata =
4777+
From 5cb13dcd0fac071b45c4bebe1801a08ff0d89cad Mon Sep 17 00:00:00 2001
4778+
From: Zhaohongjiang <[email protected]>
4779+
Date: Mon, 12 Oct 2015 15:28:39 +1100
4780+
Subject: cancel the setfilesize transation when io error happen
4781+
4782+
From: Zhaohongjiang <[email protected]>
4783+
4784+
commit 5cb13dcd0fac071b45c4bebe1801a08ff0d89cad upstream.
4785+
4786+
When I ran xfstest/073 case, the remount process was blocked to wait
4787+
transactions to be zero. I found there was a io error happened, and
4788+
the setfilesize transaction was not released properly. We should add
4789+
the changes to cancel the io error in this case.
4790+
4791+
Reproduction steps:
4792+
1. dd if=/dev/zero of=xfs1.img bs=1M count=2048
4793+
2. mkfs.xfs xfs1.img
4794+
3. losetup -f ./xfs1.img /dev/loop0
4795+
4. mount -t xfs /dev/loop0 /home/test_dir/
4796+
5. mkdir /home/test_dir/test
4797+
6. mkfs.xfs -dfile,name=image,size=2g
4798+
7. mount -t xfs -o loop image /home/test_dir/test
4799+
8. cp a file bigger than 2g to /home/test_dir/test
4800+
9. mount -t xfs -o remount,ro /home/test_dir/test
4801+
4802+
[ dchinner: moved io error detection to xfs_setfilesize_ioend() after
4803+
transaction context restoration. ]
4804+
4805+
Signed-off-by: Zhao Hongjiang <[email protected]>
4806+
Signed-off-by: Dave Chinner <[email protected]>
4807+
Signed-off-by: Nikolay Borisov <[email protected]>
4808+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
4809+
---
4810+
fs/xfs/xfs_aops.c | 13 +++++++++++--
4811+
1 file changed, 11 insertions(+), 2 deletions(-)
4812+
4813+
--- a/fs/xfs/xfs_aops.c
4814+
+++ b/fs/xfs/xfs_aops.c
4815+
@@ -153,6 +153,12 @@ xfs_setfilesize(
4816+
rwsem_acquire_read(&VFS_I(ip)->i_sb->s_writers.lock_map[SB_FREEZE_FS-1],
4817+
0, 1, _THIS_IP_);
4818+
4819+
+ /* we abort the update if there was an IO error */
4820+
+ if (ioend->io_error) {
4821+
+ xfs_trans_cancel(tp, 0);
4822+
+ return ioend->io_error;
4823+
+ }
4824+
+
4825+
xfs_ilock(ip, XFS_ILOCK_EXCL);
4826+
isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);
4827+
if (!isize) {
4828+
@@ -208,14 +214,17 @@ xfs_end_io(
4829+
ioend->io_error = -EIO;
4830+
goto done;
4831+
}
4832+
- if (ioend->io_error)
4833+
- goto done;
4834+
4835+
/*
4836+
* For unwritten extents we need to issue transactions to convert a
4837+
* range to normal written extens after the data I/O has finished.
4838+
+ * Detecting and handling completion IO errors is done individually
4839+
+ * for each case as different cleanup operations need to be performed
4840+
+ * on error.
4841+
*/
4842+
if (ioend->io_type == XFS_IO_UNWRITTEN) {
4843+
+ if (ioend->io_error)
4844+
+ goto done;
4845+
error = xfs_iomap_write_unwritten(ip, ioend->io_offset,
4846+
ioend->io_size);
4847+
} else if (ioend->io_isdirect && xfs_ioend_is_append(ioend)) {
4848+
From 9b622e2bbcf049c82e2550d35fb54ac205965f50 Mon Sep 17 00:00:00 2001
4849+
From: Tomasz Majchrzak <[email protected]>
4850+
Date: Thu, 28 Jul 2016 10:28:25 +0200
4851+
Subject: raid10: increment write counter after bio is split
4852+
4853+
From: Tomasz Majchrzak <[email protected]>
4854+
4855+
commit 9b622e2bbcf049c82e2550d35fb54ac205965f50 upstream.
4856+
4857+
md pending write counter must be incremented after bio is split,
4858+
otherwise it gets decremented too many times in end bio callback and
4859+
becomes negative.
4860+
4861+
Signed-off-by: Tomasz Majchrzak <[email protected]>
4862+
Reviewed-by: Artur Paszkiewicz <[email protected]>
4863+
Signed-off-by: Shaohua Li <[email protected]>
4864+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
4865+
4866+
---
4867+
drivers/md/raid10.c | 4 ++--
4868+
1 file changed, 2 insertions(+), 2 deletions(-)
4869+
4870+
--- a/drivers/md/raid10.c
4871+
+++ b/drivers/md/raid10.c
4872+
@@ -1171,6 +1171,8 @@ static void __make_request(struct mddev
4873+
int max_sectors;
4874+
int sectors;
4875+
4876+
+ md_write_start(mddev, bio);
4877+
+
4878+
/*
4879+
* Register the new request and wait if the reconstruction
4880+
* thread has put up a bar for new requests.
4881+
@@ -1556,8 +1558,6 @@ static void make_request(struct mddev *m
4882+
return;
4883+
}
4884+
4885+
- md_write_start(mddev, bio);
4886+
-
4887+
do {
4888+
4889+
/*
4890+
From c282222a45cb9503cbfbebfdb60491f06ae84b49 Mon Sep 17 00:00:00 2001
4891+
From: Florian Westphal <[email protected]>
4892+
Date: Wed, 8 Feb 2017 11:52:29 +0100
4893+
Subject: xfrm: policy: init locks early
4894+
4895+
From: Florian Westphal <[email protected]>
4896+
4897+
commit c282222a45cb9503cbfbebfdb60491f06ae84b49 upstream.
4898+
4899+
Dmitry reports following splat:
4900+
INFO: trying to register non-static key.
4901+
the code is fine but needs lockdep annotation.
4902+
turning off the locking correctness validator.
4903+
CPU: 0 PID: 13059 Comm: syz-executor1 Not tainted 4.10.0-rc7-next-20170207 #1
4904+
[..]
4905+
spin_lock_bh include/linux/spinlock.h:304 [inline]
4906+
xfrm_policy_flush+0x32/0x470 net/xfrm/xfrm_policy.c:963
4907+
xfrm_policy_fini+0xbf/0x560 net/xfrm/xfrm_policy.c:3041
4908+
xfrm_net_init+0x79f/0x9e0 net/xfrm/xfrm_policy.c:3091
4909+
ops_init+0x10a/0x530 net/core/net_namespace.c:115
4910+
setup_net+0x2ed/0x690 net/core/net_namespace.c:291
4911+
copy_net_ns+0x26c/0x530 net/core/net_namespace.c:396
4912+
create_new_namespaces+0x409/0x860 kernel/nsproxy.c:106
4913+
unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205
4914+
SYSC_unshare kernel/fork.c:2281 [inline]
4915+
4916+
Problem is that when we get error during xfrm_net_init we will call
4917+
xfrm_policy_fini which will acquire xfrm_policy_lock before it was
4918+
initialized. Just move it around so locks get set up first.
4919+
4920+
Reported-by: Dmitry Vyukov <[email protected]>
4921+
Fixes: 283bc9f35bbbcb0e9 ("xfrm: Namespacify xfrm state/policy locks")
4922+
Signed-off-by: Florian Westphal <[email protected]>
4923+
Signed-off-by: Steffen Klassert <[email protected]>
4924+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
4925+
4926+
---
4927+
net/xfrm/xfrm_policy.c | 10 +++++-----
4928+
1 file changed, 5 insertions(+), 5 deletions(-)
4929+
4930+
--- a/net/xfrm/xfrm_policy.c
4931+
+++ b/net/xfrm/xfrm_policy.c
4932+
@@ -3004,6 +3004,11 @@ static int __net_init xfrm_net_init(stru
4933+
{
4934+
int rv;
4935+
4936+
+ /* Initialize the per-net locks here */
4937+
+ spin_lock_init(&net->xfrm.xfrm_state_lock);
4938+
+ rwlock_init(&net->xfrm.xfrm_policy_lock);
4939+
+ mutex_init(&net->xfrm.xfrm_cfg_mutex);
4940+
+
4941+
rv = xfrm_statistics_init(net);
4942+
if (rv < 0)
4943+
goto out_statistics;
4944+
@@ -3020,11 +3025,6 @@ static int __net_init xfrm_net_init(stru
4945+
if (rv < 0)
4946+
goto out;
4947+
4948+
- /* Initialize the per-net locks here */
4949+
- spin_lock_init(&net->xfrm.xfrm_state_lock);
4950+
- rwlock_init(&net->xfrm.xfrm_policy_lock);
4951+
- mutex_init(&net->xfrm.xfrm_cfg_mutex);
4952+
-
4953+
return 0;
4954+
4955+
out:
4956+
From f843ee6dd019bcece3e74e76ad9df0155655d0df Mon Sep 17 00:00:00 2001
4957+
From: Andy Whitcroft <[email protected]>
4958+
Date: Thu, 23 Mar 2017 07:45:44 +0000
4959+
Subject: xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
4960+
4961+
From: Andy Whitcroft <[email protected]>
4962+
4963+
commit f843ee6dd019bcece3e74e76ad9df0155655d0df upstream.
4964+
4965+
Kees Cook has pointed out that xfrm_replay_state_esn_len() is subject to
4966+
wrapping issues. To ensure we are correctly ensuring that the two ESN
4967+
structures are the same size compare both the overall size as reported
4968+
by xfrm_replay_state_esn_len() and the internal length are the same.
4969+
4970+
CVE-2017-7184
4971+
Signed-off-by: Andy Whitcroft <[email protected]>
4972+
Acked-by: Steffen Klassert <[email protected]>
4973+
Signed-off-by: Linus Torvalds <[email protected]>
4974+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
4975+
4976+
---
4977+
net/xfrm/xfrm_user.c | 6 +++++-
4978+
1 file changed, 5 insertions(+), 1 deletion(-)
4979+
4980+
--- a/net/xfrm/xfrm_user.c
4981+
+++ b/net/xfrm/xfrm_user.c
4982+
@@ -386,7 +386,11 @@ static inline int xfrm_replay_verify_len
4983+
up = nla_data(rp);
4984+
ulen = xfrm_replay_state_esn_len(up);
4985+
4986+
- if (nla_len(rp) < ulen || xfrm_replay_state_esn_len(replay_esn) != ulen)
4987+
+ /* Check the overall length and the internal bitmap length to avoid
4988+
+ * potential overflow. */
4989+
+ if (nla_len(rp) < ulen ||
4990+
+ xfrm_replay_state_esn_len(replay_esn) != ulen ||
4991+
+ replay_esn->bmp_len != up->bmp_len)
4992+
return -EINVAL;
4993+
4994+
return 0;
4995+
From 677e806da4d916052585301785d847c3b3e6186a Mon Sep 17 00:00:00 2001
4996+
From: Andy Whitcroft <[email protected]>
4997+
Date: Wed, 22 Mar 2017 07:29:31 +0000
4998+
Subject: xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
4999+
5000+
From: Andy Whitcroft <[email protected]>
5001+
5002+
commit 677e806da4d916052585301785d847c3b3e6186a upstream.
5003+
5004+
When a new xfrm state is created during an XFRM_MSG_NEWSA call we
5005+
validate the user supplied replay_esn to ensure that the size is valid
5006+
and to ensure that the replay_window size is within the allocated
5007+
buffer. However later it is possible to update this replay_esn via a
5008+
XFRM_MSG_NEWAE call. There we again validate the size of the supplied
5009+
buffer matches the existing state and if so inject the contents. We do
5010+
not at this point check that the replay_window is within the allocated
5011+
memory. This leads to out-of-bounds reads and writes triggered by
5012+
netlink packets. This leads to memory corruption and the potential for
5013+
priviledge escalation.
5014+
5015+
We already attempt to validate the incoming replay information in
5016+
xfrm_new_ae() via xfrm_replay_verify_len(). This confirms that the user
5017+
is not trying to change the size of the replay state buffer which
5018+
includes the replay_esn. It however does not check the replay_window
5019+
remains within that buffer. Add validation of the contained
5020+
replay_window.
5021+
5022+
CVE-2017-7184
5023+
Signed-off-by: Andy Whitcroft <[email protected]>
5024+
Acked-by: Steffen Klassert <[email protected]>
5025+
Signed-off-by: Linus Torvalds <[email protected]>
5026+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
5027+
5028+
---
5029+
net/xfrm/xfrm_user.c | 3 +++
5030+
1 file changed, 3 insertions(+)
5031+
5032+
--- a/net/xfrm/xfrm_user.c
5033+
+++ b/net/xfrm/xfrm_user.c
5034+
@@ -393,6 +393,9 @@ static inline int xfrm_replay_verify_len
5035+
replay_esn->bmp_len != up->bmp_len)
5036+
return -EINVAL;
5037+
5038+
+ if (up->replay_window > up->bmp_len * sizeof(__u32) * 8)
5039+
+ return -EINVAL;
5040+
+
5041+
return 0;
5042+
}
5043+

0 commit comments

Comments
 (0)