Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4571562pxk; Wed, 30 Sep 2020 06:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTkdwbqvp0s5C9EY+JVkd09Kx6sngEj9l2aJRjJkVjsD/elZ7l3qM5OT33awmZFpW6Lcs7 X-Received: by 2002:a17:906:cf82:: with SMTP id um2mr2787702ejb.49.1601472732522; Wed, 30 Sep 2020 06:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601472732; cv=none; d=google.com; s=arc-20160816; b=mlpCdzdP1kSV1rJsAMfkfwb1P8/Ti3LcbGgzo3wVoV65hTka2ct7ZpHRLieuscvEdA rGSZAjK1/LeO98mYw6GIGvEZbgDl8CYq00MGm8nG5dWGlkcw+/UZimuQHsr5hJ2DiJyV Ng1Kf/idz2mdzk4hCZEB8ueD/GOweRGVhIUYxfgn3pL/mafflPspXJxO+BMtvlSLdspQ VW3sX+r1LcfVFHpq1ScaRSnPXtRHlk+9p95MDXsiaY7tgdNPINrOh4drqjnJ8eRC6mIZ Dh4/2qyFeoPGGUXuRb0k6rL7Nz3eq4LhFtBVUm2BYz08juflD/cvXUtyCNwkrCRkMlT8 07fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=0aGG+CtqPGJmiOFOGGIQ/c+ZReYi/AbBk1CjcE4dLTQ=; b=Pi8Ucr9cu2kM5YyDybPUPOH93QA4lNA1F6gpxM8lHCAtgGNAEQoc4eFw/XDPrRL2qT iV8aheaHYQ+hryfZyZ25NjJGKozOSdL7/v89853VvBDxyqSJaIjFiEwryNLQJaKwhKjG 0f+FIZwGXQ6OxG78arFxj8nE25HeQel/GflGAbE0d1oQMsZE+EtMZN3LPBjsVRgLvS08 +GUvUazhJIJklz4LKsk34G1Hao1h0omtQg3hSYFpumf2E2IQc9hb19Xozy2n7p/wcfRn XJfPdywYhcDSXaMR/yCoWiu0/pkFU7Edg6GA6UbjisfcYN5BWW26LB9/AExB+zOAeZf6 rprw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="ut/k+j0q"; 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=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si1112668eds.240.2020.09.30.06.31.49; Wed, 30 Sep 2020 06:32:12 -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=@suse.com header.s=susede1 header.b="ut/k+j0q"; 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=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730267AbgI3NaB (ORCPT + 99 others); Wed, 30 Sep 2020 09:30:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:42116 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728232AbgI3NaA (ORCPT ); Wed, 30 Sep 2020 09:30:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601472599; 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=0aGG+CtqPGJmiOFOGGIQ/c+ZReYi/AbBk1CjcE4dLTQ=; b=ut/k+j0qSZgIEIYILuBPWBwhFCjWK/DChunNrFI6SL8nJwwKsf1UPFUYr4c9AFZP0Y7WY4 K1fXalm3sATwee+57R5egng0bNKov20kRqYps7s71drrHH5IIShCA0QeEnYy/Xa7Nj6Cl5 Y4cSYmSkqWiLDS2c3qr3QC76ghVP9a4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9330FABCC; Wed, 30 Sep 2020 13:29:59 +0000 (UTC) Date: Wed, 30 Sep 2020 15:29:58 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: Re: [PATCH next v2 1/2] printk: avoid and/or handle record truncation Message-ID: <20200930132958.GF29288@alley> References: <20200930090134.8723-1-john.ogness@linutronix.de> <20200930090134.8723-2-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200930090134.8723-2-john.ogness@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2020-09-30 11:07:33, John Ogness wrote: > If a reader provides a buffer that is smaller than the message text, > the @text_len field of @info will have a value larger than the buffer > size. If readers blindly read @text_len bytes of data without > checking the size, they will read beyond their buffer. > > Add this check to record_print_text() to properly recognize when such > truncation has occurred. > > Add a maximum size argument to the ringbuffer function to extend > records so that records can not be created that are larger than the > buffer size of readers. > > When extending records (LOG_CONT), do not extend records beyond > LOG_LINE_MAX since that is the maximum size available in the buffers > used by consoles and syslog. > > Fixes: f5f022e53b87 ("printk: reimplement log_cont using record extension") > Signed-off-by: John Ogness > Reported-by: Marek Szyprowski Reviewed-by: Petr Mladek Best Regards, Petr