Message ID | 20231007170448.505487-2-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1025576vqo; Sat, 7 Oct 2023 10:05:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXzEww74m/a4+XwXG5WACeBzFyCQuiEzpt7D+dVSk6TvJVyksxjQmfN32EfpqWzEdkzpvA X-Received: by 2002:a05:6a20:9699:b0:161:2bed:6b36 with SMTP id hp25-20020a056a20969900b001612bed6b36mr10129098pzc.31.1696698311494; Sat, 07 Oct 2023 10:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696698311; cv=none; d=google.com; s=arc-20160816; b=eIHOer2jCaL+OZT08n2pCsnAEMIZeX6ezjmZbMhaw2UsdHStN9gAwjsx3TpEGMKVrw N3HAlrdt1LVXQvtGPwp/mPGizrP2kPtjkl4rxtBzhJSAWDpRf+vKBpszfh8FCUBqOIGc GOXPsny0HMLueWm1jgrKMay21IVx47XoB/n+q6oAKCV4x6Vdgx+WkMICaFNad8Xh3CuZ T7rUZUW3TK5Jk2mKw/OBIoHteKgJEB1MjJ/TAdrHQHJjq4lx/gfmRPxRdUvDebKSmZcu U4a1iGKdqVuKxDAn3t5WuQPNG/6ocP/BdyoOBuTVXjFY1kP4uVVnOPNm0oDahf45r6H/ nT6A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8nEY8eNt0wOkmINbls4UM258fyfw7VxyfhsVq9XFVxg=; fh=XbpaCPHBafLZZrtF5rhcMEkabNxxoWT6OCJYwZ5VqdU=; b=nXCWydoROTLLVGCP/blzWG4IVeAagq9qlhHtV9NsJoYZEZfW0ML4U7ayEWcyKWEbmV /1ACVnWT85fxr0VSi1R82EsKFZKtyDm5G6lgq2xmMSvyBhXyuabvNkLL1VtaNHmQwHox 306X6/VD8OnaKgh9+CbMOmSC6VZ+SD/7vZNmfruuSUt6DreL5cbZThsaPTs3egiuLsug sbhQXW6nSsPqIo19DDMozmAedH1BP2/5itDUCO7bJJviHuSrUh8lnyYIxWSsW/Xwg12R NrCQEzD4Mz1j4H3oioWq/elApFUovjve6O1B8LIcMh0H5fn9oil8ZwwJ9tNosnnvrdXB Sj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eUeSBoRC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cm4-20020a056a020a0400b00578bb707e6esi5897473pgb.806.2023.10.07.10.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 10:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eUeSBoRC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 848FB805C3F9; Sat, 7 Oct 2023 10:05:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344101AbjJGRFB (ORCPT <rfc822;pusanteemu@gmail.com> + 17 others); Sat, 7 Oct 2023 13:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344046AbjJGRE6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 7 Oct 2023 13:04:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F0BBA; Sat, 7 Oct 2023 10:04:58 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDADAC433C7; Sat, 7 Oct 2023 17:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696698297; bh=13ShY6HnWg7Sx2I9hscgBsQOpo9Vq3faGjdLVYoBM5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eUeSBoRC8ODJTmKIkYd6gNHF/IrKY8Gdzo0GJtWGKXvn/Gwxg66E66zwK+R+L641h RH91OtdShkzWHuMANps+J8Tk/390bUD43IXxpuXrUmzlZ05XTXonzNYEnWWPx7X41M 2yz+S0Ez0O60sxYV+gxrOXChiiB5dI2NdlKFf2mSvqGCjH5w5iO1wDyObNm6wVEK1y 8CafTp2S7rUo6l50QfyjmNHtmXI+FjjRaK7qOO11kQeSR4vpSHgoIaidgiPSnAlanS dThJcqOhH5Y0mQPS4fb8cu0vCfja+eoOcDBKuq1Iab/VnMOtrRwqUseRmQm0ueA0/L 8jdcl8NIkKFpA== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>, Hans de Goede <hdegoede@redhat.com>, Jiri Kosina <jkosina@suse.cz>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, =?utf-8?q?Thomas?= =?utf-8?q?_Wei=C3=9Fschuh?= <linux@weissschuh.net> Subject: [PATCH 2/5] modpost: fix ishtp MODULE_DEVICE_TABLE built on big endian host Date: Sun, 8 Oct 2023 02:04:45 +0900 Message-Id: <20231007170448.505487-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231007170448.505487-1-masahiroy@kernel.org> References: <20231007170448.505487-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 07 Oct 2023 10:05:09 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779117128710883872 X-GMAIL-MSGID: 1779117128710883872 |
Series |
[1/5] modpost: fix tee MODULE_DEVICE_TABLE built on big endian host
|
|
Commit Message
Masahiro Yamada
Oct. 7, 2023, 5:04 p.m. UTC
When MODULE_DEVICE_TABLE(ishtp, ) is built on a host with a different
endianness from the target architecture, it results in an incorrect
MODULE_ALIAS().
For example, see a case where drivers/platform/x86/intel/ishtp_eclite.c
is built as a module.
If you build it on a little endian host, you will get the correct
MODULE_ALIAS:
$ grep MODULE_ALIAS drivers/platform/x86/intel/ishtp_eclite.mod.c
MODULE_ALIAS("ishtp:{6A19CC4B-D760-4DE3-B14D-F25EBD0FBCD9}");
However, if you build it on a big endian host, you will get a wrong
MODULE_ALIAS:
$ grep MODULE_ALIAS drivers/platform/x86/intel/ishtp_eclite.mod.c
MODULE_ALIAS("ishtp:{BD0FBCD9-F25E-B14D-4DE3-D7606A19CC4B}");
This issue has been unnoticed because the x86 kernel is most likely built
natively on an x86 host.
The guid field must not be reversed because guid_t is an array of __u8.
Fixes: fa443bc3c1e4 ("HID: intel-ish-hid: add support for MODULE_DEVICE_TABLE()")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/file2alias.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 2023-10-08 02:04:45+0900, Masahiro Yamada wrote: > When MODULE_DEVICE_TABLE(ishtp, ) is built on a host with a different > endianness from the target architecture, it results in an incorrect > MODULE_ALIAS(). > > For example, see a case where drivers/platform/x86/intel/ishtp_eclite.c > is built as a module. Nitpick: ... [as a module] for x86. So the statements below can be interpreted correctly. > > If you build it on a little endian host, you will get the correct > MODULE_ALIAS: > > $ grep MODULE_ALIAS drivers/platform/x86/intel/ishtp_eclite.mod.c > MODULE_ALIAS("ishtp:{6A19CC4B-D760-4DE3-B14D-F25EBD0FBCD9}"); > > However, if you build it on a big endian host, you will get a wrong > MODULE_ALIAS: > > $ grep MODULE_ALIAS drivers/platform/x86/intel/ishtp_eclite.mod.c > MODULE_ALIAS("ishtp:{BD0FBCD9-F25E-B14D-4DE3-D7606A19CC4B}"); > > This issue has been unnoticed because the x86 kernel is most likely built > natively on an x86 host. > > The guid field must not be reversed because guid_t is an array of __u8. > > Fixes: fa443bc3c1e4 ("HID: intel-ish-hid: add support for MODULE_DEVICE_TABLE()") + Cc: stable@vger.kernel.org > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Thanks! > --- > > scripts/mod/file2alias.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index 70bf6a2f585c..6583b36dbe69 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -1401,10 +1401,10 @@ static int do_mhi_ep_entry(const char *filename, void *symval, char *alias) > /* Looks like: ishtp:{guid} */ > static int do_ishtp_entry(const char *filename, void *symval, char *alias) > { > - DEF_FIELD(symval, ishtp_device_id, guid); > + DEF_FIELD_ADDR(symval, ishtp_device_id, guid); > > strcpy(alias, ISHTP_MODULE_PREFIX "{"); > - add_guid(alias, guid); > + add_guid(alias, *guid); > strcat(alias, "}"); > > return 1; > -- > 2.39.2 >
On Sun, 2023-10-08 at 09:51 +0200, Thomas Weißschuh wrote: > On 2023-10-08 02:04:45+0900, Masahiro Yamada wrote: > > When MODULE_DEVICE_TABLE(ishtp, ) is built on a host with a > > different > > endianness from the target architecture, it results in an incorrect > > MODULE_ALIAS(). > > > > For example, see a case where > > drivers/platform/x86/intel/ishtp_eclite.c > > is built as a module. > > Nitpick: > > ... [as a module] for x86. > > So the statements below can be interpreted correctly. > > > > > If you build it on a little endian host, you will get the correct > > MODULE_ALIAS: > > > > $ grep MODULE_ALIAS > > drivers/platform/x86/intel/ishtp_eclite.mod.c > > MODULE_ALIAS("ishtp:{6A19CC4B-D760-4DE3-B14D-F25EBD0FBCD9}"); > > > > However, if you build it on a big endian host, you will get a wrong > > MODULE_ALIAS: > > > > $ grep MODULE_ALIAS > > drivers/platform/x86/intel/ishtp_eclite.mod.c > > MODULE_ALIAS("ishtp:{BD0FBCD9-F25E-B14D-4DE3-D7606A19CC4B}"); > > > > This issue has been unnoticed because the x86 kernel is most likely > > built > > natively on an x86 host. > > > > The guid field must not be reversed because guid_t is an array of > > __u8. > > > > Fixes: fa443bc3c1e4 ("HID: intel-ish-hid: add support for > > MODULE_DEVICE_TABLE()") > > + Cc: stable@vger.kernel.org > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Thanks, Srinivas > > Thanks! > > > --- > > > > scripts/mod/file2alias.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > > index 70bf6a2f585c..6583b36dbe69 100644 > > --- a/scripts/mod/file2alias.c > > +++ b/scripts/mod/file2alias.c > > @@ -1401,10 +1401,10 @@ static int do_mhi_ep_entry(const char > > *filename, void *symval, char *alias) > > /* Looks like: ishtp:{guid} */ > > static int do_ishtp_entry(const char *filename, void *symval, char > > *alias) > > { > > - DEF_FIELD(symval, ishtp_device_id, guid); > > + DEF_FIELD_ADDR(symval, ishtp_device_id, guid); > > > > strcpy(alias, ISHTP_MODULE_PREFIX "{"); > > - add_guid(alias, guid); > > + add_guid(alias, *guid); > > strcat(alias, "}"); > > > > return 1; > > -- > > 2.39.2 > >
On Sun, Oct 8, 2023 at 4:51 PM Thomas Weißschuh <linux@weissschuh.net> wrote: > > On 2023-10-08 02:04:45+0900, Masahiro Yamada wrote: > > When MODULE_DEVICE_TABLE(ishtp, ) is built on a host with a different > > endianness from the target architecture, it results in an incorrect > > MODULE_ALIAS(). > > > > For example, see a case where drivers/platform/x86/intel/ishtp_eclite.c > > is built as a module. > > Nitpick: > > ... [as a module] for x86. > > So the statements below can be interpreted correctly. OK, I fixed up the comment when I applied the patch. Thanks.
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 70bf6a2f585c..6583b36dbe69 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1401,10 +1401,10 @@ static int do_mhi_ep_entry(const char *filename, void *symval, char *alias) /* Looks like: ishtp:{guid} */ static int do_ishtp_entry(const char *filename, void *symval, char *alias) { - DEF_FIELD(symval, ishtp_device_id, guid); + DEF_FIELD_ADDR(symval, ishtp_device_id, guid); strcpy(alias, ISHTP_MODULE_PREFIX "{"); - add_guid(alias, guid); + add_guid(alias, *guid); strcat(alias, "}"); return 1;