Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2559116rdg; Mon, 14 Aug 2023 06:31:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzRNC/Gks1K1ekBMwD9Cu1upDnnNYHpA94XuZyDXpJnSG/uCYN9D5C082LlLg4Cb86W4yR X-Received: by 2002:a05:6512:3b81:b0:4f9:58ed:7bba with SMTP id g1-20020a0565123b8100b004f958ed7bbamr7348938lfv.16.1692019897272; Mon, 14 Aug 2023 06:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692019897; cv=none; d=google.com; s=arc-20160816; b=uZ7SWvpYK/9oLdTWlPpY3GJexOgOJZtZKwePhiiWFQRVmKMBHekOeCYYlaukBGbcNX OFq6rL0G3SZxYIO1C477A1CYx+dFv2iEKXXEKPOB2mogjHwBAKbQ3HpDhM+uAdU0mgcL b4DcIPgwEXaCQslOfo7Lv7nzZ8su+jolFkb2LzPY2Pii3dc5EGOYQ3r1H3CKVcscfVzj NQ7YONz6Hynq78QO7cxs7TGlkGdKAWVd7+nG0OcDxyOvkP2wJmqFS/gug8UB8KrUdIKM m345gXNJQhDockON2ElJoe/yBUIwojMsOuixLDI+jNKViQ6vNNH1WrCuVPwWQQKt+OKo Q1jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1EwJnpDzSZ9Tq3Xj5sEIz1mrOXITnbkSLBxYcSSAIHU=; fh=81K8uGi7hNyuqqtzsrvyq6+Zg43ctBHd5XK9Yds+cR4=; b=QDioHhSuGfDBWwWxqP7KqFHZhxV5Vnf2yv2nXPY7DAGyCzrfszTa4pfFzuSYA24FZN VxgXOBHAKGCB7cmUQd0p0ogn7SG234TqNOKpohNguzozJsLA3KhBHSq5HJfKyHyy+yY0 0TnZzTSc53rTHv1t81mZjS1YwtQfJWWWKl55rOkhCTCkG9lDYF05OhMhLJM1buvVt6jy 3uON0fpl1rqsLFuFicMdTthnzFhAErhmDiYZ9M6NSJfFTseaNS1CLh7yprXgajz9Pwhg atggcPaefmoGZaOwG6NqS79i/jmn5OnYWNsrDzIynJm1bdD2GyIbNSNiOWmO+3lVSUn8 zgug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=VmxuValf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020aa7de0b000000b0052570917661si51804edv.615.2023.08.14.06.31.11; Mon, 14 Aug 2023 06:31:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=VmxuValf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232842AbjHNLlR (ORCPT + 99 others); Mon, 14 Aug 2023 07:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234812AbjHNLlJ (ORCPT ); Mon, 14 Aug 2023 07:41:09 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2054510C0; Mon, 14 Aug 2023 04:41:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D643F1F383; Mon, 14 Aug 2023 11:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1692013260; h=from:from:reply-to: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=1EwJnpDzSZ9Tq3Xj5sEIz1mrOXITnbkSLBxYcSSAIHU=; b=VmxuValf5Fwxkz7hUuJ61A9Gvfy9sooXGrvxm9KrVHDWcHELWVvrxuN1vRKAVUxJW7xXkT /gNFDY44YN3fit1KwlOLDEcjb41FA3htMqEqsKoH7aix2AGYE4Ex7det+uM87jI4imO0r1 9xNuvisDHI3GauYqLGeLBZTbiHgypxY= Received: from suse.cz (pmladek.tcp.ovpn2.prg.suse.de [10.100.208.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 4E5DF2C143; Mon, 14 Aug 2023 11:40:59 +0000 (UTC) Date: Mon, 14 Aug 2023 13:40:57 +0200 From: Petr Mladek To: Kees Cook Cc: Sergey Senozhatsky , Steven Rostedt , John Ogness , Vijay Balakrishna , stable@vger.kernel.org, Tony Luck , "Guilherme G. Piccoli" , "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] printk: ringbuffer: Fix truncating buffer size min_t cast Message-ID: References: <20230811054528.never.165-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230811054528.never.165-kees@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_PASS, T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2023-08-10 22:45:32, Kees Cook wrote: > If an output buffer size exceeded U16_MAX, the min_t(u16, ...) cast in > copy_data() was causing writes to truncate. This manifested as output > bytes being skipped, seen as %NUL bytes in pstore dumps when the available > record size was larger than 65536. Fix the cast to no longer truncate > the calculation. > > Cc: Petr Mladek > Cc: Sergey Senozhatsky > Cc: Steven Rostedt > Cc: John Ogness > Reported-by: Vijay Balakrishna > Closes: https://lore.kernel.org/lkml/d8bb1ec7-a4c5-43a2-9de0-9643a70b899f@linux.microsoft.com/ checkpatch.pl suggested that "Link:" should be used instead of "Closes:". > Fixes: b6cf8b3f3312 ("printk: add lockless ringbuffer") > Cc: stable@vger.kernel.org > Signed-off-by: Kees Cook Reviewed-by: Petr Mladek Thanks a lot for tracking this down. The patch has been comitted into printk/linux.git, branch for-6.6. I though about pushing it for 5.5-rc7. But it is pretty old issue. It does not break the system. I wanted to give it some spin in linux-next. And I leave for vacation on Thursday. I will not have internet connection until Aug 28. Best Regards, Petr