Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4864706rwb; Sun, 13 Nov 2022 15:54:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sobMCM7YjAscl/cE2hB1QiJi5ZZF/YeIOroGmsYVrXNV0igNNvqimulgpTOAdMe+uP7GA X-Received: by 2002:a05:6a00:bc6:b0:56d:8e07:4626 with SMTP id x6-20020a056a000bc600b0056d8e074626mr11523284pfu.70.1668383642023; Sun, 13 Nov 2022 15:54:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668383642; cv=none; d=google.com; s=arc-20160816; b=B4nxo9/PcAI74RNfbpTFTRLMk1De85nJQ8dDzcGSu0wTbjG2hEp0niTXUMvgP2rFG6 YxbuxuUQsRy80tvbNn2gHEzhBQMV5nd6Gl3S/7+k4nkAIwW/CobbBryFMtER2dAq9lE+ zFHwYZ3E/ZWhqjNE2+loRodVIslNIOrI2yb9Ef8vfBDkPKUHr9/MPkpe6fO0zGnDOA60 oNVtdTwk6RZjIJapVYXJn0ZCCzeEqE0zX3bgL+k6vtXkO0w8ieADxoV1sQybi9rBbipR Pxe+5PD1uzSo4E9DEV6kWbn1KH3VgFxHLuRJAxYYbIqvAdkik2FDuXyWYn3TOygLvT9d nBnw== 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=y7Fk4574rKiht8vH1M//ztVr0OJB5wOcoVolwca5tiM=; b=0242xNA84TF2AqzmpxxkzpEfMEUo/e4zETmVMfou9ICKxFvjovS5B3cjczOqyt7BAU LTPabNXWhqsKddPF5BRuPyWrN/kVnGyRax2pKFpcF/oKKHHhK8Ew8MHOVXMdxZGoV5Lv JBTDON1/u8nDyFvFdD6yd8zPTyMMmUev8wXBow60qg/2pGGUgKt7hEjB/IbS/Mh0lE0y Jfkm3mz2oqlpLgZOgw+qBXYHBSeMNFdVz0xmsxlfwc2Oi25yVGgLPwCDPncWB9Jaw2ao UsCMuASClgrYZ1TnA/SOgwoiogYMwT6SOwoYohF2tOEaBMEaLUjC/pJeFkRd//Hc3LKR wgNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OdcYn3Y4; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a17090ac24200b0020d3a22af84si7633144pjx.186.2022.11.13.15.53.49; Sun, 13 Nov 2022 15:54:02 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=OdcYn3Y4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235443AbiKMXoS (ORCPT + 90 others); Sun, 13 Nov 2022 18:44:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbiKMXoR (ORCPT ); Sun, 13 Nov 2022 18:44:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B49F2EAF; Sun, 13 Nov 2022 15:44:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B06BE60DE2; Sun, 13 Nov 2022 23:44:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77EF9C433B5; Sun, 13 Nov 2022 23:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668383055; bh=LoWCb3lNyJ4hJnSzs3SkHUb0L90gwz2LPeVQQzyt9xg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OdcYn3Y4o07Q0rQZk0bdOGeLqiWE/K+pGGr/a4JRvy3QoDRJrtbwzEe6XQL1zI5/1 hpm+4swzpvVby42b7sCdmRPO32IdIy996vH7qflYIS7hp27Q8PKrPGqS+9KRAbWJT4 WrO2BDTS4ygusIaePN+6/kmyvyZ/J0B6GsS2NkdmiNZeLJSy5Tz2yoWeim8/IujjhG IOb0e2d7kiojRlIxC+/v8woutyshA8um3EXmDzb6h/pwPtGmiGt00Ky8qwZIjL+ULP oe6TSiWU0/caz8ZV4gS/vQfbdmx5THKPkLgOW8Vzwn6XBjx5uzOLS+zPPD7SeE80Q8 enT7FcO9wE+DA== Date: Sun, 13 Nov 2022 15:44:12 -0800 From: Eric Biggers To: Evan Green Cc: linux-kernel@vger.kernel.org, corbet@lwn.net, linux-integrity@vger.kernel.org, gwendal@chromium.org, dianders@chromium.org, apronin@chromium.org, Pavel Machek , Ben Boeckel , rjw@rjwysocki.net, jejb@linux.ibm.com, Kees Cook , dlunev@google.com, zohar@linux.ibm.com, Matthew Garrett , jarkko@kernel.org, linux-pm@vger.kernel.org, Len Brown , "Rafael J. Wysocki" Subject: Re: [PATCH v5 09/11] PM: hibernate: Mix user key in encrypted hibernate Message-ID: References: <20221111231636.3748636-1-evgreen@chromium.org> <20221111151451.v5.9.I87952411cf83f2199ff7a4cc8c828d357b8c8ce3@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221111151451.v5.9.I87952411cf83f2199ff7a4cc8c828d357b8c8ce3@changeid> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Fri, Nov 11, 2022 at 03:16:34PM -0800, Evan Green wrote: > Limiting this to the data portion allows the kernel to receive the page > map and prepare its giant allocation even if this user key is not yet > available (ie the user has not yet finished typing in their password). What is meant by the "data portion"? > +int snapshot_set_user_key(struct snapshot_data *data, > + struct uswsusp_user_key __user *key) > +{ > + struct uswsusp_user_key user_key; > + unsigned int key_len; > + int rc; > + loff_t size; > + > + /* > + * Return the metadata size, the number of bytes that can be fed in before > + * the user data key is needed at resume time. > + */ > + size = snapshot_get_meta_data_size(); > + rc = put_user(size, &key->meta_size); > + if (rc) > + return rc; > + > + rc = copy_from_user(&user_key, key, sizeof(struct uswsusp_user_key)); > + if (rc) > + return rc; This isn't correctly checking the return value of copy_from_user(). > + > + BUILD_BUG_ON(sizeof(data->user_key) < sizeof(user_key.key)); > + > + key_len = min_t(__u32, user_key.key_len, sizeof(data->user_key)); > + if (key_len < 8) > + return -EINVAL; Shouldn't -EINVAL also be returned if key_len is too large? - Eric