Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2376042rdg; Sun, 13 Aug 2023 23:42:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFIIW6sOnYprnLZKDsLoMEUD0sqAABzHm9FQmTR7b9tZgVpf5cVelXagDflAh/Z5jf+gk5 X-Received: by 2002:a05:6402:750:b0:523:437b:44ff with SMTP id p16-20020a056402075000b00523437b44ffmr6772817edy.12.1691995327755; Sun, 13 Aug 2023 23:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691995327; cv=none; d=google.com; s=arc-20160816; b=ZqjdJe7HQ9EePrPlNcwwkR5o0HRTVxAp4wGh8iW27o3LSUSgfASiOFS6SWhdDWB+Y+ BzBMx8enphepbY+liyKid32rSJBVKy3+nabLmgHPK8wHjHQEF689xQa+K7HJF/DN5x5X QB3/6AosGVUcAksTi43Eohzyfh2jpzMQOgu86++yLbVsWp1+Yw/3PYKBYl/9z+OahSKW lZjqwqIhy7+d/Oua5VP9db0ODnmZo/UoCNtN8nHg4tvydIncQXwhef/m1ua4YRWBdXUu P+qHt9OwDykledK+M8FR1wzhtY78lR0h9j2SiNDPu95ql86WygAYWz0Np4bW1u4aZ3J2 ra/g== 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=7Oz708AoYWC0zOYG+tE6hDqHP4W2kJ5mwj7u+JyTgAE=; fh=ypLtwTra+aY2lPLZSnlzmX1LaSClSw9Tl6AlXZsdLBc=; b=UZFxJJNzTCvwIQ9YqaV5PxeQXyJWOHMUgbO5Pl93Szdj3zMvHGtTrOSz0R5s2F/8MP pVfO6nUeYz4dNjuzOuvqiRfuFzvnWiI97KSYgeFnfWkICFsXZbDDoUjfri7AkSMN4i4U S2zpFrZ9cM7MoVu7agjovXUH+x/+1o0ml5fXeqzIA2KPOpY9ktvHRlmu2SINUCcse2CB hSj6KYrHFemn1fPeGS5idVs19+wIKXHC3LS7+ExoZBEAVpNDEoeIRaGeEgGQLqcqnyw5 C0HvYk6OsSj6d2pEeyiAxfhAv/vvmWL047lWUSS8fHELyPCXZQXdbcQU/dMLFUnti6Mb p94g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="dm/UjTTd"; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020aa7d7d7000000b00521d0a2c5adsi7282751eds.379.2023.08.13.23.41.43; Sun, 13 Aug 2023 23:42:07 -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=@linutronix.de header.s=2020 header.b="dm/UjTTd"; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbjHNGVf (ORCPT + 99 others); Mon, 14 Aug 2023 02:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233780AbjHNGVR (ORCPT ); Mon, 14 Aug 2023 02:21:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B1F10C2; Sun, 13 Aug 2023 23:20:46 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691994040; 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=7Oz708AoYWC0zOYG+tE6hDqHP4W2kJ5mwj7u+JyTgAE=; b=dm/UjTTd/8x22YbB7VS/B7ZT3pTXbi6W/6bHhOLqnQXB2co2TDmv+XkmkO2sEXLL4v3hk+ fol0pL+c9/Oov6a18DICfnVwLVTa/6QucbsmEJ/CVb1qN6vlYWd9HaDjMYm26T+g2d8qYD E/Mx4AFaaWRN0G60Xgsdf1xL7dmF3RzOD0YKd9RPeMbePG9GRd7IsRyHvXo+oX0tCjZWC/ BeNqSIOTkKsBV+Pr6ZJc18nz/biBLF4wcN3JDtBKajndbC8GTnHB0rwsmvdkuyS43BKN7T NzQCjYkaXX0AfipWEQnZi0WQBnY6Hq4TtkHzqMk7WRVC1HqZXyeNR8mPXpLmkQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691994040; 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=7Oz708AoYWC0zOYG+tE6hDqHP4W2kJ5mwj7u+JyTgAE=; b=Lb80vFXQENVRyRX+3SY/NPNoMTTDxzxL7pzj6t1f5OlvHN/ns3wEc1lBrLrhYqtVh1cljj xXwlev3efGPeGpDA== To: Kees Cook , Petr Mladek Cc: Kees Cook , Sergey Senozhatsky , Steven Rostedt , 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 In-Reply-To: <20230811054528.never.165-kees@kernel.org> References: <20230811054528.never.165-kees@kernel.org> Date: Mon, 14 Aug 2023 08:26:28 +0206 Message-ID: <875y5i16xf.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=no 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 2023-08-10, 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. Thanks for tracking this down. Reviewed-by: John Ogness