aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-10-16 12:52:37 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2020-10-16 12:52:37 -0700
commit8119c4332d253660e0a6b8748fe0749961cfbc97 (patch)
treef0cee0b6c342034952bc00d484bd15e286634d42 /kernel
parentMerge tag 'kgdb-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux (diff)
parentprintk: ringbuffer: Wrong data pointer when appending small string (diff)
downloadlinux-dev-8119c4332d253660e0a6b8748fe0749961cfbc97.tar.xz
linux-dev-8119c4332d253660e0a6b8748fe0749961cfbc97.zip
Merge tag 'printk-for-5.10-fixup' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux
Pull printk fix from Petr Mladek: "Prevent overflow in the new lockless ringbuffer" * tag 'printk-for-5.10-fixup' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: printk: ringbuffer: Wrong data pointer when appending small string
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk/printk_ringbuffer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c
index 2493348a1631..24a960a89aa8 100644
--- a/kernel/printk/printk_ringbuffer.c
+++ b/kernel/printk/printk_ringbuffer.c
@@ -1125,7 +1125,10 @@ static char *data_realloc(struct printk_ringbuffer *rb,
/* If the data block does not increase, there is nothing to do. */
if (head_lpos - next_lpos < DATA_SIZE(data_ring)) {
- blk = to_block(data_ring, blk_lpos->begin);
+ if (wrapped)
+ blk = to_block(data_ring, 0);
+ else
+ blk = to_block(data_ring, blk_lpos->begin);
return &blk->data[0];
}