From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAB92C001B0 for ; Mon, 14 Aug 2023 07:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234186AbjHNHle (ORCPT ); Mon, 14 Aug 2023 03:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234238AbjHNHlK (ORCPT ); Mon, 14 Aug 2023 03:41:10 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8692E7E for ; Mon, 14 Aug 2023 00:41:05 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bddac1b7bfso5085395ad.0 for ; Mon, 14 Aug 2023 00:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691998865; x=1692603665; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=osUjcaEHtBFUKHlMgydGCW0+LXDmW2BKWDOjMgrl0H4=; b=gYElgx4Y9XpD+x4CIpjkhq1bSiJGmw+awZyz2AmlDe9X4vT6PAI2iQUwqtPfe8zi83 pvDVGp8ijRjc1l1skHpiyisdBKMoRdQe824oVY48DrMfzCTi8qguLt58prjnuWSNDJ0B ZDa3alWhOkSQjrQkoMm7k5Pajfa4/E5jhFikE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691998865; x=1692603665; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=osUjcaEHtBFUKHlMgydGCW0+LXDmW2BKWDOjMgrl0H4=; b=W4dEAafvEYj/n7NHGkUepphpNxFWP4ajJGHFb64L9IPK0rF3HViLVK+MBhuV8HDnr7 3C9Erj7CrD26kggbpzxpI6ly0wLVQH8r6y5kXrb9MRn4g2sKA/pXBhTFyOxJOCId7G1F 4GHyV9fgmDqHMEBU21ggVQlBimbg/p2IuyeWpBU0CSaqq4fsXZYuR6HtXm9gLUZgpbH4 tzL6V1VaLXZBPZCbOE+MfqtkViBwpnNdRk5/Lq/leOt/zODJ2EDyWxsjTaWtkr26cWn4 qsqqAuDdDYkf1E8kWzXly4ZL2P1hZApmiUeH5fBRHECN1Yh1bXjnGsCRyvnMhTShmb6A Q6KA== X-Gm-Message-State: AOJu0Yx0dXszd1/aXPIdqk4bCXy8fEeh9aPKWHhbiuNQZhskhIaLnHwn yuFjLTcjkwB5z0B+wUmapnYIhg== X-Google-Smtp-Source: AGHT+IGzAzUfBdp29beWjVa3J5Q0XpfJkc7H0CgGQ+XJNgLDognagfaqgl+ZzbOysdJfBVX6PH+nPQ== X-Received: by 2002:a17:903:1cb:b0:1bc:40ce:e1ec with SMTP id e11-20020a17090301cb00b001bc40cee1ecmr10624727plh.30.1691998865050; Mon, 14 Aug 2023 00:41:05 -0700 (PDT) Received: from google.com (KD124209188001.ppp-bb.dion.ne.jp. [124.209.188.1]) by smtp.gmail.com with ESMTPSA id jf7-20020a170903268700b001b9f032bb3dsm8732882plb.3.2023.08.14.00.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 00:41:04 -0700 (PDT) Date: Mon, 14 Aug 2023 16:40:59 +0900 From: Sergey Senozhatsky To: Kees Cook Cc: Petr Mladek , 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: <20230814074059.GA907749@google.com> 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> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On (23/08/10 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 Thanks a lot! Reviewed-by: Sergey Senozhatsky