Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4396054ioa; Wed, 27 Apr 2022 02:58:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsTjDhjokd/QsliZdoKgGxMe44cd1sTVC3nfyo9w1wIj5zSWO3EDPBQU2MMpWSR5oRDMYe X-Received: by 2002:a17:902:f64e:b0:14d:20db:8478 with SMTP id m14-20020a170902f64e00b0014d20db8478mr28821912plg.158.1651053496496; Wed, 27 Apr 2022 02:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651053496; cv=none; d=google.com; s=arc-20160816; b=k1wnMg2IndpcYKGkoR1jRm1eQHS3lIgtx8KKaF0O0JtvRu842CHmNFn4VVV3+xfqzL l/FSHS4nYzWk8gB0MeWPIOHnI+hgJ+x+6AL0KEdLSpW0xdcGydU4ROsschVZNajVv7OU TFjBlmxM19PAf8FOYG1kjIM3oWoc93FZhBjfRtu0QvJ7J29QQeNTY6A9S/D/IE4f9LVb Bjd3aMsOIcKKpr9yusDlWmH+jRKciLCiC+3sEJxbHbGvdP4zqGN2Www9LJ47uQsJXQVW NQTMCMHWMNKKZA8z1ob5h/XxSO3Itb01OmJJ5WNNTTeXcqGd5GrM240lTigQCdxnpC6L Mc7A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+1hp2ncrSq7G8MR03J7UOPUrk0+fHOvwm5EcRaW9448=; b=LwKAYYoOP23euvu3lCuhQxCfxcy/zVhl4fNWJNq9gPQzlluS0y7U+y+D6aYWvLUl5i Xg6BAsfKx+TZfMvQX/sSHJ/5E9PHKM57kDX5PZ3m7TgQmAoW348DniOdbw8ANWmuYFOn CJmwaatqVoOPR18Q920x4Gl+RTIHncoPcE1JxplvLWCXPFR1qtv59uelVbm3jB9SyEZS Jaj28HEOHNl0NWMUG0dCe1ZkEM97XfBJaascidGpWLuteTub0IJUey0IvZSjS6rRxTvB dfwI8wUck0+6xXlSXhiDM3V1NZI37uIq8a+0EFIPnWFyKIkuqE6eMrt5TYzJUToRFHpp ktnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cHox6g8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z23-20020a17090ab11700b001d6b07a30aasi4708084pjq.90.2022.04.27.02.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:58:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cHox6g8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3E84C2C3931; Wed, 27 Apr 2022 02:26:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345519AbiDZJVc (ORCPT + 99 others); Tue, 26 Apr 2022 05:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343871AbiDZI5l (ORCPT ); Tue, 26 Apr 2022 04:57:41 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B2BCE98; Tue, 26 Apr 2022 01:42:10 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 78149CE1BC9; Tue, 26 Apr 2022 08:42:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A672C385A4; Tue, 26 Apr 2022 08:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962526; bh=Q/NB08VUd3vxv4x7BsltP3dVqaSoPQUEhqVzMWg51P8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHox6g8qUbPSs2toTNfp0qRyhXxP0+3OL85qATCiSx+8sfydZjxhKUuV4BOmu79/Q LjiJ7LeMOnyBZ8gfrnupSyKuCwMzMdp5YKI3GBzyRT6nybglVfRCxGl/dnWXBiNDSE Au0COdKDfOxhvQhVIfbzaPOSWFmoEyLH6otmpULs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, koo5 , Manuel Ullmann , "David S. Miller" Subject: [PATCH 5.15 086/124] net: atlantic: invert deep par in pm functions, preventing null derefs Date: Tue, 26 Apr 2022 10:21:27 +0200 Message-Id: <20220426081749.745559934@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 From: Manuel Ullmann commit cbe6c3a8f8f4315b96e46e1a1c70393c06d95a4c upstream. This will reset deeply on freeze and thaw instead of suspend and resume and prevent null pointer dereferences of the uninitialized ring 0 buffer while thawing. The impact is an indefinitely hanging kernel. You can't switch consoles after this and the only possible user interaction is SysRq. BUG: kernel NULL pointer dereference RIP: 0010:aq_ring_rx_fill+0xcf/0x210 [atlantic] aq_vec_init+0x85/0xe0 [atlantic] aq_nic_init+0xf7/0x1d0 [atlantic] atl_resume_common+0x4f/0x100 [atlantic] pci_pm_thaw+0x42/0xa0 resolves in aq_ring.o to ``` 0000000000000ae0 : { /* ... */ baf: 48 8b 43 08 mov 0x8(%rbx),%rax buff->flags = 0U; /* buff is NULL */ ``` The bug has been present since the introduction of the new pm code in 8aaa112a57c1 ("net: atlantic: refactoring pm logic") and was hidden until 8ce84271697a ("net: atlantic: changes for multi-TC support"), which refactored the aq_vec_{free,alloc} functions into aq_vec_{,ring}_{free,alloc}, but is technically not wrong. The original functions just always reinitialized the buffers on S3/S4. If the interface is down before freezing, the bug does not occur. It does not matter, whether the initrd contains and loads the module before thawing. So the fix is to invert the boolean parameter deep in all pm function calls, which was clearly intended to be set like that. First report was on Github [1], which you have to guess from the resume logs in the posted dmesg snippet. Recently I posted one on Bugzilla [2], since I did not have an AQC device so far. #regzbot introduced: 8ce84271697a #regzbot from: koo5 #regzbot monitor: https://github.com/Aquantia/AQtion/issues/32 Fixes: 8aaa112a57c1 ("net: atlantic: refactoring pm logic") Link: https://github.com/Aquantia/AQtion/issues/32 [1] Link: https://bugzilla.kernel.org/show_bug.cgi?id=215798 [2] Cc: stable@vger.kernel.org Reported-by: koo5 Signed-off-by: Manuel Ullmann Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c @@ -444,22 +444,22 @@ err_exit: static int aq_pm_freeze(struct device *dev) { - return aq_suspend_common(dev, false); + return aq_suspend_common(dev, true); } static int aq_pm_suspend_poweroff(struct device *dev) { - return aq_suspend_common(dev, true); + return aq_suspend_common(dev, false); } static int aq_pm_thaw(struct device *dev) { - return atl_resume_common(dev, false); + return atl_resume_common(dev, true); } static int aq_pm_resume_restore(struct device *dev) { - return atl_resume_common(dev, true); + return atl_resume_common(dev, false); } static const struct dev_pm_ops aq_pm_ops = {