Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2774844rwl; Mon, 27 Mar 2023 05:15:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ZlmRCReyLK7A3nUIEyFyzgMsymGPPKttzmZCn5Il+i/1kt/rVeLn7HyLv60muITV0Mdb5G X-Received: by 2002:a17:906:ad98:b0:930:6d59:d1f8 with SMTP id la24-20020a170906ad9800b009306d59d1f8mr11350611ejb.10.1679919355062; Mon, 27 Mar 2023 05:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679919355; cv=none; d=google.com; s=arc-20160816; b=YU7Wn/1nON3JhmovBxVVXK7id+Cy1vTM6YFuFkyTQNNTClfkKZ214oJ1VCSQ0EtB8F gOFSSlmEgbggOREoD6Hmgy+hvK8iKMbuLaol8ASg8b9FAvAOuhgc8YKB4toH1e0qOabl 7Q8jb8CTTmsjQQYeZByWQEELB/gvsHwKW54sDoNKn/ydhZHH2xQqEC4eQpuuUmhIkZH5 ERe5tdyZ4TYEWSAgyQKIGoF9EUZvV2+WREU8Yy0Ox3tQGJDov/z30pr6e156JMPoYuLq jD8MPXUK5uTICxgorabF+cMbuEQPiMLRcZUdyg1eo1262Qr82hQWF7Svo1EaCRdrvxeJ W5hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=XMY8R0e+ZJv/3a0nthMAQ1uPdCov4lxVWDHPj3misVs=; b=CA/A290oqn17SES9m+zchhh9kKDnHM1xn2fycUyYATll3uxdtK9NYvUbHtSh0aOxr+ BNesR3wRlNQD8RwM1O9XiARfD/iYn46rVOouicmCPE4tZMbisYzj5Hkz5ikBlYPDBdRm MFXdH6NbbaLW6uZK7DhI8PhH0B3GPfvzFucRMUcySkxuHiJnBGIWHIvF7qKgxyCoBIlS 4mI4GoD8L79HbZ55/dKwolYX8yxnLcVAftdcsP+Po4atI72M7QtKcI5yG8S4WyjLER4S Lpeo9aIplR/AgBAexZb3yEv7U5B6B9zow2U+3D3nLjMnSdmXpZB8n6sOYp0attln85l5 8j/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZO2D4pJk; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf19-20020a1709077f1300b009453c587583si2120106ejc.995.2023.03.27.05.15.30; Mon, 27 Mar 2023 05:15:55 -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=@intel.com header.s=Intel header.b=ZO2D4pJk; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232643AbjC0MKU (ORCPT + 99 others); Mon, 27 Mar 2023 08:10:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbjC0MKT (ORCPT ); Mon, 27 Mar 2023 08:10:19 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339BA19BF; Mon, 27 Mar 2023 05:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679919017; x=1711455017; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=jeepVfFfCQsHZs+6635Pz6VkoXSevOib+Apjcl9UAno=; b=ZO2D4pJkE/Us1O38/CbkB9XFN0DYEDCBeBG5lzX/qXaNrR5WuZsCn0cO WbxJvGTb1eejoljqDcu4wN2wBNeffo2l2ObLpQcJfkhMexLDej2rNW5qw KrmeDI35PZfHYT6/Es4vQVuDGXTIMqXKtGGg3ujoyXtfIvlltsPV/pVy6 MjcTgPZ85aSvbAv1r9O9nsEJ654eEn9qA8mSh0vB/TF0xT9fMBxFoEgpt gARkXQmwe+yqrtF4n+i6g1RyeHMHFnEc21lk2fAcQrqR1+i86dux/6Wfn W6s+PagIHuPbNGHTZ11cVmcE1rk7n5MdnsjI4QresmKCbBH7EGl4qFIx1 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="341821758" X-IronPort-AV: E=Sophos;i="5.98,294,1673942400"; d="scan'208";a="341821758" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 05:10:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="633583683" X-IronPort-AV: E=Sophos;i="5.98,294,1673942400"; d="scan'208";a="633583683" Received: from biyengar-mobl.amr.corp.intel.com ([10.213.176.16]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 05:10:16 -0700 Message-ID: Subject: Re: [PATCH] HID: intel-ish-hid: Fix kernel panic during warm reset From: srinivas pandruvada To: Tanu Malhotra , jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, even.xu@intel.com, Shaunak Saha Date: Mon, 27 Mar 2023 05:10:14 -0700 In-Reply-To: <20230327032310.2416272-1-tanu.malhotra@intel.com> References: <20230327032310.2416272-1-tanu.malhotra@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_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 On Sun, 2023-03-26 at 20:23 -0700, Tanu Malhotra wrote: some minor nits below. > During warm reset device->fw_client is set to NULL. If a bus driver > is > registered after this NULL setting and before new firmware clients > are > enumerated by ISHTP, kernel panic will result in the function > ishtp_cl_bus_match(). This is because of reference to > device->fw_client->props.protocol_name. >=20 > ISH firmware after getting successfully loaded, sends a warm reset > notification to remove all clients from the bus and sets > device->fw_client to NULL. Until kernel v5.15, all enabled ISHTP > kernel > module drivers were loaded after any of the first ISHTP device was > registered, regardless of whether it was a matched or an unmatched > device. This resulted in all drivers getting registered much before > the > warm reset notification from ISH. Starting kernel v5.16, this issue > got > exposed after the change was introduced to load only bus drivers for > the > respective matching devices. One paragraph break will be better. > In this scenario, cros_ec_ishtp device and > cros_ec_ishtp driver are registered after the warm reset > device_fw_client NULL setting. cros_ec_ishtp driver_register() > triggers > the callback to ishtp_cl_bus_match() to match driver to the device > and > causes kernel panic in guid_equal() when dereferencing fw_client NULL > pointer to get protocol_name. >=20 > Fixes: f155dfeaa4ee ("platform/x86: isthp_eclite: only load for > matching devices") > Fixes: facfe0a4fdce ("platform/chrome: chros_ec_ishtp: only load for > matching devices") > Fixes: 0d0cccc0fd83 ("HID: intel-ish-hid: hid-client: only load for > matching devices") > Fixes: 44e2a58cb880 ("HID: intel-ish-hid: fw-loader: only load for > matching devices") >=20 No need of blank line. > Signed-off-by: Tanu Malhotra > Tested-by: Shaunak Saha You can also add=20 Acked-by: Srinivas Pandruvada Also add Cc: # 5.16+ > --- When you submit "PATCH v2", Add change log here. (That is below "---"). Something like this: v2 - Updated commit description - Added CC to stable > =C2=A0drivers/hid/intel-ish-hid/ishtp/bus.c | 4 ++-- > =C2=A01 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c > b/drivers/hid/intel-ish-hid/ishtp/bus.c > index 81385ab37fa9..4f540906268f 100644 > --- a/drivers/hid/intel-ish-hid/ishtp/bus.c > +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c > @@ -241,8 +241,8 @@ static int ishtp_cl_bus_match(struct device *dev, > struct device_driver *drv) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct ishtp_cl_device *d= evice =3D to_ishtp_cl_device(dev); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct ishtp_cl_driver *d= river =3D to_ishtp_cl_driver(drv); > =C2=A0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return guid_equal(&driver->id[= 0].guid, > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &d= evice->fw_client->props.protocol_name); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return(device->fw_client ? gui= d_equal(&driver->id[0].guid, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &device->fw_client- > >props.protocol_name) : 0); Align the second line to char "d" after "(". Thanks, Srinivas > =C2=A0} > =C2=A0 > =C2=A0/**