Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp849924rdg; Fri, 11 Aug 2023 01:33:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvptsRMc8G5lFvwHizWXM8NRLAjwbaufOPe9aqwDjp/cioMN66CJFfzwLeOabf3sJsYbt/ X-Received: by 2002:a05:6a21:3d89:b0:13d:17cc:5bca with SMTP id bj9-20020a056a213d8900b0013d17cc5bcamr1030089pzc.18.1691742819208; Fri, 11 Aug 2023 01:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691742819; cv=none; d=google.com; s=arc-20160816; b=ZcLI0aLQpKlMNa/exgS3eDr8g6qeT43v7ESLoSjPIk4GzKOV600BroccDtI1oQDBoH Ud6msC5UyHmvNNa21+0ZZiNm5qSTM0Y29dCcXXPz3EKDM0b/3fK1uqSG7q+FFWTnD4l6 otXPN05HX5QtYHjdFnfYTZHVodhNlPBzFpPktyhoqOWpMQ0+FkqMvGrzVKtv1siam3Jr BKJlUGGkR4qPu5eoXJUo0ThpyoBovmuSKfI3fI0EUXW4lm4GUPOOUA87JXtj5CAzxUGl mDhBZc54sIBzH9NlqhaamqxcA0OVfdiRKMuuwd9AwUXwp7B6xJCdWulC0I03VxQ6uQKn v1QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=p1s2g6vEJ1Twwe0mdUoYDxKmhQkIYtpm5zhaKOh73WE=; fh=yVulcgBkkbgVkVQRVStUsTcrvSuDQNpUW/EnQJn4gJ4=; b=A8qZuQnJp1LOZmYr/kqjMRa3GQKMbSthuBa5lMk9+4h/vyo4N7VTb09i+yB2VE+jyS ik441QvqHlc6h62GOykz3MqmK64YClZAALS/Ek0S6tPJHNHFXyObWl56Flk9X7USXN0z 4KPh6TJO6MByA0DnjLHqBUWXPgaNOhUgN4f/HGQFG5erD9QHUPWZPjP2/NeStL+cExvG SI/2Uez27XiH5enAFaQp3wirPPHI/mCVe0V7bJBfJxBP+6TWTSEZQXxjrCftJLgnxmzn 4H3uRsW14FYYFxRS0gV4hnFhe/EWOSHWI32mYvXjBJz/TMB9zEWv+QPOI7+6gTrXPczi OJMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EgTkTip8; 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=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a62a214000000b006871a4b2295si2927157pff.402.2023.08.11.01.33.27; Fri, 11 Aug 2023 01:33:39 -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=@linux.microsoft.com header.s=default header.b=EgTkTip8; 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=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233485AbjHKGQJ (ORCPT + 99 others); Fri, 11 Aug 2023 02:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjHKGQI (ORCPT ); Fri, 11 Aug 2023 02:16:08 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F7C72D48; Thu, 10 Aug 2023 23:16:07 -0700 (PDT) Received: from [192.168.5.50] (cpe-70-95-196-11.san.res.rr.com [70.95.196.11]) by linux.microsoft.com (Postfix) with ESMTPSA id 1D5C120FD073; Thu, 10 Aug 2023 23:16:06 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1D5C120FD073 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1691734566; bh=p1s2g6vEJ1Twwe0mdUoYDxKmhQkIYtpm5zhaKOh73WE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=EgTkTip86gNCpNNraKu2tapl1kNx4npnKbq5vz8mGLBty7SNk9rAbPOM2VgtPSJOj TIuCpdhTqhTb4NPj8XH91CYm5lQ0w4i9cbzHrRpKCnt1iZ3pDXjhjWVcV5DbI6N65j Jxd/pqbxT90HwsplMSbzpJRPwvXgct3z7a6nCjyg= Message-ID: <55a22e2f-bc95-62e3-69b0-1f9daf64935d@linux.microsoft.com> Date: Thu, 10 Aug 2023 23:16:05 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] printk: ringbuffer: Fix truncating buffer size min_t cast Content-Language: en-US To: Kees Cook , Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , John Ogness , stable@vger.kernel.org, Tony Luck , "Guilherme G. Piccoli" , "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20230811054528.never.165-kees@kernel.org> From: Vijay Balakrishna In-Reply-To: <20230811054528.never.165-kees@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-19.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 8/10/23 22:45, 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/ > Fixes: b6cf8b3f3312 ("printk: add lockless ringbuffer") > Cc: stable@vger.kernel.org > Signed-off-by: Kees Cook Excellent. I have verified on v5.10. Tested-by: Vijay Balakrishna Thanks, Vijay