[arch-commits] Commit in linux-lts/trunk (PKGBUILD bcache_fix.diff)
Andreas Radke
andyrtr at archlinux.org
Sat Jun 15 13:12:22 UTC 2019
Date: Saturday, June 15, 2019 @ 13:12:22
Author: andyrtr
Revision: 356150
upgpkg: linux-lts 4.19.51-1
upstream update 4.19.51; add upstream fix for gcc9 bcache crash
Added:
linux-lts/trunk/bcache_fix.diff
Modified:
linux-lts/trunk/PKGBUILD
-----------------+
PKGBUILD | 13 +++--
bcache_fix.diff | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 138 insertions(+), 4 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2019-06-15 01:49:48 UTC (rev 356149)
+++ PKGBUILD 2019-06-15 13:12:22 UTC (rev 356150)
@@ -3,7 +3,7 @@
pkgbase=linux-lts
#pkgbase=linux-lts-custom
_srcname=linux-4.19
-pkgver=4.19.50
+pkgver=4.19.51
pkgrel=1
arch=('x86_64')
url="https://www.kernel.org/"
@@ -16,7 +16,8 @@
'60-linux.hook' # pacman hook for depmod
'90-linux.hook' # pacman hook for initramfs regeneration
'linux-lts.preset' # standard config files for mkinitcpio ramdisk
- 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch)
+ 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
+ bcache_fix.diff)
validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds <torvalds at linux-foundation.org>
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman (Linux kernel stable release signing key) <greg at kroah.com>
)
@@ -23,12 +24,13 @@
# https://www.kernel.org/pub/linux/kernel/v4.x/sha256sums.asc
sha256sums=('0c68f5655528aed4f99dae71a5b259edc93239fa899e2df79c055275c21749a1'
'SKIP'
- '102b61a96def0de7f3a15cf614767b9b8f8128839d365c036b31b473b570fb92'
+ 'd5026e8cdbe80238a87f90499cfd5e3065eec9981efd8ffc86c9ca09b4c87ce4'
'bec3d57b04bcc04be141e60e07fceae830c204de453ad18d054bbb5bc911f7e7'
'ae2e95db94ef7176207c690224169594d49445e04249d2499e9d2fbc117a0b21'
'75f99f5239e03238f88d1a834c50043ec32b1dc568f2cc291b07d04718483919'
'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65'
- '36b1118c8dedadc4851150ddd4eb07b1c58ac5bbf3022cc2501a27c2b476da98')
+ '36b1118c8dedadc4851150ddd4eb07b1c58ac5bbf3022cc2501a27c2b476da98'
+ 'fe00e6f26f167b2041f4e60588cc60ab8169f26efb4a7c47ee7d60320e4ca27d')
_kernelname=${pkgbase#linux}
@@ -47,6 +49,9 @@
# disable USER_NS for non-root users by default
patch -Np1 -i ../0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
+ # fix bcache corruption with gcc9
+ patch -Np1 -i ../bcache_fix.diff
+
cp -Tf ../config .config
if [ "${_kernelname}" != "" ]; then
Added: bcache_fix.diff
===================================================================
--- bcache_fix.diff (rev 0)
+++ bcache_fix.diff 2019-06-15 13:12:22 UTC (rev 356150)
@@ -0,0 +1,129 @@
+From 9e50f5f4ef401c4a5cd286ee3218fcc625ef6f77 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli at suse.de>
+Date: Mon, 10 Jun 2019 06:13:34 +0800
+Subject: bcache: fix stack corruption by PRECEDING_KEY()
+
+Recently people report bcache code compiled with gcc9 is broken, one of
+the buggy behavior I observe is that two adjacent 4KB I/Os should merge
+into one but they don't. Finally it turns out to be a stack corruption
+caused by macro PRECEDING_KEY().
+
+See how PRECEDING_KEY() is defined in bset.h,
+437 #define PRECEDING_KEY(_k) \
+438 ({ \
+439 struct bkey *_ret = NULL; \
+440 \
+441 if (KEY_INODE(_k) || KEY_OFFSET(_k)) { \
+442 _ret = &KEY(KEY_INODE(_k), KEY_OFFSET(_k), 0); \
+443 \
+444 if (!_ret->low) \
+445 _ret->high--; \
+446 _ret->low--; \
+447 } \
+448 \
+449 _ret; \
+450 })
+
+At line 442, _ret points to address of a on-stack variable combined by
+KEY(), the life range of this on-stack variable is in line 442-446,
+once _ret is returned to bch_btree_insert_key(), the returned address
+points to an invalid stack address and this address is overwritten in
+the following called bch_btree_iter_init(). Then argument 'search' of
+bch_btree_iter_init() points to some address inside stackframe of
+bch_btree_iter_init(), exact address depends on how the compiler
+allocates stack space. Now the stack is corrupted.
+
+Fixes: 0eacac22034c ("bcache: PRECEDING_KEY()")
+Signed-off-by: Coly Li <colyli at suse.de>
+Reviewed-by: Rolf Fokkens <rolf at rolffokkens.nl>
+Reviewed-by: Pierre JUHEN <pierre.juhen at orange.fr>
+Tested-by: Shenghui Wang <shhuiw at foxmail.com>
+Tested-by: Pierre JUHEN <pierre.juhen at orange.fr>
+Cc: Kent Overstreet <kent.overstreet at gmail.com>
+Cc: Nix <nix at esperi.org.uk>
+Cc: stable at vger.kernel.org
+Signed-off-by: Jens Axboe <axboe at kernel.dk>
+---
+ drivers/md/bcache/bset.c | 16 +++++++++++++---
+ drivers/md/bcache/bset.h | 34 ++++++++++++++++++++--------------
+ 2 files changed, 33 insertions(+), 17 deletions(-)
+
+diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
+index 8f07fa6e1739..268f1b685084 100644
+--- a/drivers/md/bcache/bset.c
++++ b/drivers/md/bcache/bset.c
+@@ -887,12 +887,22 @@ unsigned int bch_btree_insert_key(struct btree_keys *b, struct bkey *k,
+ struct bset *i = bset_tree_last(b)->data;
+ struct bkey *m, *prev = NULL;
+ struct btree_iter iter;
++ struct bkey preceding_key_on_stack = ZERO_KEY;
++ struct bkey *preceding_key_p = &preceding_key_on_stack;
+
+ BUG_ON(b->ops->is_extents && !KEY_SIZE(k));
+
+- m = bch_btree_iter_init(b, &iter, b->ops->is_extents
+- ? PRECEDING_KEY(&START_KEY(k))
+- : PRECEDING_KEY(k));
++ /*
++ * If k has preceding key, preceding_key_p will be set to address
++ * of k's preceding key; otherwise preceding_key_p will be set
++ * to NULL inside preceding_key().
++ */
++ if (b->ops->is_extents)
++ preceding_key(&START_KEY(k), &preceding_key_p);
++ else
++ preceding_key(k, &preceding_key_p);
++
++ m = bch_btree_iter_init(b, &iter, preceding_key_p);
+
+ if (b->ops->insert_fixup(b, k, &iter, replace_key))
+ return status;
+diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
+index bac76aabca6d..c71365e7c1fa 100644
+--- a/drivers/md/bcache/bset.h
++++ b/drivers/md/bcache/bset.h
+@@ -434,20 +434,26 @@ static inline bool bch_cut_back(const struct bkey *where, struct bkey *k)
+ return __bch_cut_back(where, k);
+ }
+
+-#define PRECEDING_KEY(_k) \
+-({ \
+- struct bkey *_ret = NULL; \
+- \
+- if (KEY_INODE(_k) || KEY_OFFSET(_k)) { \
+- _ret = &KEY(KEY_INODE(_k), KEY_OFFSET(_k), 0); \
+- \
+- if (!_ret->low) \
+- _ret->high--; \
+- _ret->low--; \
+- } \
+- \
+- _ret; \
+-})
++/*
++ * Pointer '*preceding_key_p' points to a memory object to store preceding
++ * key of k. If the preceding key does not exist, set '*preceding_key_p' to
++ * NULL. So the caller of preceding_key() needs to take care of memory
++ * which '*preceding_key_p' pointed to before calling preceding_key().
++ * Currently the only caller of preceding_key() is bch_btree_insert_key(),
++ * and it points to an on-stack variable, so the memory release is handled
++ * by stackframe itself.
++ */
++static inline void preceding_key(struct bkey *k, struct bkey **preceding_key_p)
++{
++ if (KEY_INODE(k) || KEY_OFFSET(k)) {
++ (**preceding_key_p) = KEY(KEY_INODE(k), KEY_OFFSET(k), 0);
++ if (!(*preceding_key_p)->low)
++ (*preceding_key_p)->high--;
++ (*preceding_key_p)->low--;
++ } else {
++ (*preceding_key_p) = NULL;
++ }
++}
+
+ static inline bool bch_ptr_invalid(struct btree_keys *b, const struct bkey *k)
+ {
+--
+cgit v1.2.1-1-g437b
+
+
More information about the arch-commits
mailing list