Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2416155rdg; Mon, 14 Aug 2023 01:31:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGQYyOKfhbhjNWVUMEzzR25WopCbHRC3Uan8j1bgQxAIVeh/VkE4GBbnR34HWjEoRIpo76 X-Received: by 2002:a17:906:220f:b0:99b:5161:8e0d with SMTP id s15-20020a170906220f00b0099b51618e0dmr7886013ejs.21.1692001895887; Mon, 14 Aug 2023 01:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692001895; cv=none; d=google.com; s=arc-20160816; b=kjG0f9fOfF/6rNIofPCd3HL3Rh9hGEmuCi5FENDnmedLukwcZw02QnwcY7Y1QzZqrE b68Ws7abhAcSfoMu31W1gt+Tu+o8r62RNHwdq1/rMTNlcdXInIr6J7KaLkfwPKREyoEA t5c3Znr7Jj0gLRCDHz4RRmWCZxEgHw4zaYMRdeUtlgApULu7Y3M84hJbsHKtPNWpINaI uMq6TEXY4tI7YAW0VijSbGAyBm6osn4q06jCpgVJMe0tAE9MsFDo1DlEnHgKk1vFAB5f h+mT3ada66QTsY++4ibS7h3tDCxVwJEeJEsgvFLbZyDTXJ+BWOVVucnwcKe7nJzQWgvK HGhg== 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=osUjcaEHtBFUKHlMgydGCW0+LXDmW2BKWDOjMgrl0H4=; fh=TQkoFg4cjG1/eDmN70m56haU9giPhH3aE4DzLPZMVrU=; b=jSPRL/Ye2NZSairW3zJfikOxDJaBSlCjUXHhyVOE/9ivGSu0cvOjxe3dNOhJjaWgja sYkRDPxDiuz97oXtxxOIMfKTWDEDMrRFPTxIV+jGMHvql5C/LW1rROK09G2Jsl9GoxdN HiLOoNl5K1nMYsQrn64WWxDO0SjZJLydOKRzj/4KVfqQTGMeSKvpYlWEXkEKoFBadZjU AbRPDcBQiJ7zsQs0nWXZcBgDzPgPHmnqkZXnaNmA95iHF4ggWfo/QwI8/YmpwOMdaY+9 Tip/ppzErVfHX4qiAeEBcUheAkvKHFpTl/3Nu3JwH9av1kbfO7+5yr/4+xxXeLohVqlu /ktg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gYElgx4Y; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t21-20020a1709064f1500b0099b6becb10fsi7189683eju.449.2023.08.14.01.31.11; Mon, 14 Aug 2023 01:31:35 -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=@chromium.org header.s=google header.b=gYElgx4Y; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234215AbjHNHle (ORCPT + 99 others); Mon, 14 Aug 2023 03:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbjHNHlL (ORCPT ); Mon, 14 Aug 2023 03:41:11 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DA110D5 for ; Mon, 14 Aug 2023 00:41:05 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bc7e65ea44so26875645ad.1 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=XZEZh+5YdJfWclJzGYBV16yeqf9uqiMXxfOWGMCBVOlZE4Ou147EfzGvQ1EXox7lPP HyD4mdQpdGv6ZILKt6DbIUVPGuIw3qvzO01imk5Ik2neNwKwIda9KJdJQASKzGkI1gWO vDe97kpB6yWqWmP54Pthkqd/JJIUEgRT6bMlq/dBAkvy7wpoVkTx+KoxII1V/OEVn0y9 WCJcnT8CITdLgl2XyeBDE2P02qQir43+L101wqsBcHdpNPOda7NEHvR3xUNgS1oOJphC TI+VGDlJnlZNqpV57pBpaD7B/Fdel2RqkFerLvtCVLAsawSW1UY8x5V+OmSOQYS/t3hj 36iA== X-Gm-Message-State: AOJu0YxShoAqP1DWXbP8G5aGS2iAYmrY/KC7+mZ0SeG7I8AJBJqww30o lMw1tg5Ik6uZzvw+THb4+tggjA== 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> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FSL_HELO_FAKE, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 (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