Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2713666rwb; Mon, 7 Aug 2023 02:06:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgVwP0PgYK2TrGRuqgV6lkRO7D87wlBEUkGH9+0lwWSNonB0743ZVFrKWKEGjLg8tA+AMN X-Received: by 2002:a05:6358:e49b:b0:139:d226:b361 with SMTP id by27-20020a056358e49b00b00139d226b361mr7878954rwb.31.1691399186524; Mon, 07 Aug 2023 02:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691399186; cv=none; d=google.com; s=arc-20160816; b=kdSzhYZOSLBkdw82vQrIGca8cSRggIihPfirfhzi3DndSfEavwwmcvX6J70UhlgRPY ApZfKwi+8jAZuf7bL6x7h50qdQoVRcpV4C6iozdqsf/gCboEjSK3M7ybYah7VrfAZ8FN X6/ZQeI9KWHmS7foUYGDlPKNMgjza4/7j4XZ16pgXykF6wguUL766Zn32/yatGyTtvPB cHd//xcNyJuhIUjZFnX7ra2rJQGoJhdwi2HaIK265za80tIuD7bGWeTwTwPDlMuHxotn pPwdxr+igURa45y6I9QpVcgRf4aKADVQmOsM9zmUmIsHCw2sRMjmZBBtnstQEKZDQsjO Pfgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=CkiLjiLMxObzy3Sb9w3oxtxHFV8IOAxBlCK+K5bcwaE=; fh=sFOmTyu2DzqhIAcsWJvGcvAamPX+l23iOXSueBZgAFM=; b=flgtFHZO0gY1yhl0vCYpRmxtEW+Uw2Nn2aPSH+sabfU3QJ4+VVfkHt2jPyYt1giWTY kL74O+YVNVil4rRxGS3E4Wb9QDxcHtV/213YShqt6UlcwOKRt1F19+eTRFnCg2IhTl6Q GyW1Nnq6C3hBBUs+fNHHYGbsk6q9IOn1+Z4ApKWu1qeRMa7NNs7PsBxq14R9MR6IaiHU 708xcuhNI5cPUnyhDz4CRKI61o1Vi/sydpvm7GzqyGsAI4GrKy8wZr0RyJpbSG2p9gYf /ouJpppR+znF/y1i+pQhi4MzEymuQlbW4Qb7eZ74CbLdPFj6OrncuSDmonA9xtK50o3F 5A3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=r+DUjLGF; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=PmOcswpF; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a63e113000000b00553c2f85085si5564910pgh.220.2023.08.07.02.06.14; Mon, 07 Aug 2023 02:06:26 -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=@suse.cz header.s=susede2_rsa header.b=r+DUjLGF; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=PmOcswpF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbjHGIeP (ORCPT + 99 others); Mon, 7 Aug 2023 04:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjHGIeO (ORCPT ); Mon, 7 Aug 2023 04:34:14 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E64710EF; Mon, 7 Aug 2023 01:34:12 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 44AAB218A9; Mon, 7 Aug 2023 08:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691397251; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CkiLjiLMxObzy3Sb9w3oxtxHFV8IOAxBlCK+K5bcwaE=; b=r+DUjLGFEllhgYp/YiieuZF0DOCjFDWeLyJoWFD0+nxlhS2s+B4eZvPMd4W3P12+txsJ5K G431i69aOhsJSqtUZcspvZ0xB1KGBCaF8Sc0PPEF5QWSdWdODP1kf6Odvb05n1/K6EP4OM 2N5m5JFtHu58v9ZyWEHYpAtkTXoamI0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691397251; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CkiLjiLMxObzy3Sb9w3oxtxHFV8IOAxBlCK+K5bcwaE=; b=PmOcswpF0o6Csfk6kbt4+f54rrFElHQs3ovyF4w1bqSUJ5n6roG5qyOxTHY7f0PI1TMtU0 9q+79oecr2eV8RBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0F71013487; Mon, 7 Aug 2023 08:34:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9RkuA4Os0GTCBwAAMHmgww (envelope-from ); Mon, 07 Aug 2023 08:34:11 +0000 From: Vlastimil Babka To: "Rafael J . Wysocki" , Pavel Machek , Jens Axboe Cc: dm-devel@redhat.com, gregkh@linuxfoundation.org, hch@lst.de, joern@lazybastard.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org, loic.poulain@linaro.org, miquel.raynal@bootlin.com, regressions@lists.linux.dev, richard@nod.at, snitzer@kernel.org, vigneshr@ti.com, Vlastimil Babka Subject: [PATCH for 6.5 regression] PM: hibernate: fix resume_store() return value when hibernation not available Date: Mon, 7 Aug 2023 10:33:57 +0200 Message-ID: <20230807083356.19222-2-vbabka@suse.cz> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL 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 a laptop with hibernation set up but not actively used, and with secure boot and lockdown enabled kernel, 6.5-rc1 gets stuck on boot with the following repeated messages: A start job is running for Resume from hibernation using device /dev/system/swap (24s / no limit) lockdown_is_locked_down: 25311154 callbacks suppressed Lockdown: systemd-hiberna: hibernation is restricted; see man kernel_lockdown.7 ... Checking the resume code leads to commit cc89c63e2fe3 ("PM: hibernate: move finding the resume device out of software_resume") which inadvertently changed the return value from resume_store() to 0 when !hibernation_available(). This apparently translates to userspace write() returning 0 as in number of bytes written, and userspace looping indefinitely in the attempt to write the intended value. Fix this by returning the full number of bytes that were to be written, as that's what was done before the commit. Fixes: cc89c63e2fe3 ("PM: hibernate: move finding the resume device out of software_resume") Signed-off-by: Vlastimil Babka Reviewed-by: Christoph Hellwig Acked-by: Greg Kroah-Hartman --- Resend with review/ack tags added and not buried in the thread. Link: https://lore.kernel.org/all/2cfa5f55-1d68-8a4f-d049-13f42e0d1484@suse.cz/ kernel/power/hibernate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index e1b4bfa938dd..2b4a946a6ff5 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -1166,7 +1166,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, int error; if (!hibernation_available()) - return 0; + return n; if (len && buf[len-1] == '\n') len--; -- 2.41.0