Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp595204pxu; Thu, 15 Oct 2020 11:26:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpMuMKZUo5VCIePrghoDp9yYSykDIwBek2LNW9tb9A6ros8NG8JG1nCKw2Yw842ewSfzIY X-Received: by 2002:a17:906:ad5:: with SMTP id z21mr5600704ejf.461.1602786408997; Thu, 15 Oct 2020 11:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602786408; cv=none; d=google.com; s=arc-20160816; b=uW+0wEbvx8EedMufV16RSvPr1UgxstTlCxJ+TLxbCj+QcC7UpbimgV/wzz2INeva6Z hfKUCYUyXytNDYIXVvDkBjkEIcvN5Yd3KoE0iZ21Za66sp+Jfkzp4h1RjVOP2Y5GIFx6 ssosh5tQB5s4V+RJjsMcvb9zkxOAp7x7eqlgEn9IPOAtVVi++PwvgpuNmnDZVfJdvd0B Q/P/SSrN/R0CFKeTUo+ycIJ1CloN611tOPgQfbFV/KQMA5/e1mZUxyneFpp75I7p5+Zf h+0dp+Zq3fIb0w6LWuZ784RKYE+zof91ycgkYraEDGQuLj6KbC4ZHlwqFomdedOUCopC znEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=PlevN6yVm2HnwK034FXsfndh/959DVQqNZzufhIKA04=; b=Mp3+qND1IsHhIwTNaggxvVAaLvG0E7G5ETFXFnS+P2+2Ml0MeKKE085LKQcxY3gQJ1 qR0HUWrZOH4gyOUsN3ztlYz619PgaWKWZftC4aB96V8Ldxkdt75n7QUd51MSaQ660d4d sEYirLew66oB8lYW+2Rje1agJAxVT1HJ4xTzpFwIpEw2iKtrhARE8i4NUWGv2G0YBW3b TJZpjSy5E8F9Ou1VG3fBw+tiIsPyiaEGCTT8Eu+sE7mgViK3mfoDjH9mEsNAgcBwmZzD AeAByyFemqNJQAexK+v8muO4XU1h+fqssA937ZF3MDylEw7YtrCId7r9J4X1ws7aRO8E lzXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="MUall/o1"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l26si2554618edw.348.2020.10.15.11.26.21; Thu, 15 Oct 2020 11:26:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="MUall/o1"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729561AbgJOJ7q (ORCPT + 99 others); Thu, 15 Oct 2020 05:59:46 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:36628 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgJOJ7q (ORCPT ); Thu, 15 Oct 2020 05:59:46 -0400 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1602755983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PlevN6yVm2HnwK034FXsfndh/959DVQqNZzufhIKA04=; b=MUall/o1Ep8FjtYpBzVZioQvmMADRw3NIf1+4jtH439kFEfQO7IzV5DdgPPCuGe2H9dcGg kuu4rqtx+yhEcLgMy77E1udhVGeD1SpMD6+LIqDmauOIw/EzjDa5bySQgnqsejbxLWB3TI zewbm0x4K1tJDEVb0E7B3pReYa+RFBME9ESzd3mAC9KkGi+vLmrdRk2rcJVFoSUvmYyDoG vtDgcaxRqaQ3+XQL9exk1Nfn+io2ZeTAxqvet3P6eKF1KDU75BbTTuenrT6Qjkz4Dh3QFo McKE19QQLuWbQTNXsHTndMUA3JAixGCJVy472NJCg1EkDdciYAR0CS1bGMeMOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1602755983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PlevN6yVm2HnwK034FXsfndh/959DVQqNZzufhIKA04=; b=z7V9dWcnjheORrqANNNbcItCw4NhNMjaxJ1idCJ71t24jY3QPie81gGDA7E7nctNIdESAb 3zo7jyQ72+1K7TCQ== To: Sergey Senozhatsky , Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Linux-Next Mailing List , linux-mm , open list , lkft-triage@lists.linaro.org, LTP List , Andrew Morton , Mike Rapoport , Stephen Rothwell , Rasmus Villemoes , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , Naresh Kamboju Subject: Re: [PATCH] printk: ringbuffer: Wrong data pointer when appending small string In-Reply-To: <20201015063137.GA3668@jagdpanzerIV.localdomain> References: <20201014140514.GB17231@alley> <20201014151311.GB13775@alley> <20201014175051.GC13775@alley> <20201015063137.GA3668@jagdpanzerIV.localdomain> Date: Thu, 15 Oct 2020 12:05:42 +0206 Message-ID: <875z7bhks1.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-10-15, Sergey Senozhatsky wrote: >> 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]; >> } > > Great catch. Indeed. I don't know how we missed that one. :-/ Reviewed-by: John Ogness