From nobody Wed Feb 11 11:07:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5877AC76188 for ; Wed, 5 Apr 2023 14:02:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238379AbjDEOCp convert rfc822-to-8bit (ORCPT ); Wed, 5 Apr 2023 10:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238156AbjDEOBv (ORCPT ); Wed, 5 Apr 2023 10:01:51 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2FF46A64; Wed, 5 Apr 2023 07:01:05 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 47d973e81acfa915; Wed, 5 Apr 2023 16:01:03 +0200 Received: from kreacher.localnet (unknown [213.134.163.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 0248C1B4E9E1; Wed, 5 Apr 2023 16:01:01 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Bob Moore Subject: [PATCH 17/32] ACPICA: Avoid undefined behavior: member access within misaligned address Date: Wed, 05 Apr 2023 15:45:45 +0200 Message-ID: <2176684.Icojqenx9y@kreacher> In-Reply-To: <4845957.31r3eYUQgx@kreacher> References: <4845957.31r3eYUQgx@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-CLIENT-IP: 213.134.163.219 X-CLIENT-HOSTNAME: 213.134.163.219 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdejuddgjeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtqhertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepfeetteevgfelhfefveeutefhudekleejgfeviedufefgleeuteeftedvieelleeinecuffhomhgrihhnpegrshgrnhdrshhopdhgihhthhhusgdrtghomhenucfkphepvddufedrudefgedrudeifedrvdduleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieefrddvudelpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhosggvrhhtrdhmohhorhgvsehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tamir Duberstein ACPICA commit 60cbb20c009fd67e7b973d67b5dcb4a7b12681d9 Before this change we see the following UBSAN stack traces in Fuchsia: #0 0x0000219ce3426bd7 in acpi_rs_get_list_length(u8*, u32, acpi_size*)= ../../third_party/acpica/source/components/resources/rscalc.c:631 +0x2cbbd7 #1.2 0x00002240d84b077f in ubsan_get_stack_trace() compiler-rt/lib/ubsan= /ubsan_diag.cpp:41 +0x3d77f #1.1 0x00002240d84b077f in maybe_print_stack_trace() compiler-rt/lib/ubs= an/ubsan_diag.cpp:51 +0x3d77f #1 0x00002240d84b077f in ~scoped_report() compiler-rt/lib/ubsan/ubsan_= diag.cpp:387 +0x3d77f #2 0x00002240d84b1385 in handletype_mismatch_impl() compiler-rt/lib/ub= san/ubsan_handlers.cpp:137 +0x3e385 #3 0x00002240d84b0ead in compiler-rt/lib/ubsan/ubsan_handlers.cpp:142 = +0x3dead #4 0x0000219ce3426bd7 in acpi_rs_get_list_length(u8*, u32, acpi_size*)= ../../third_party/acpica/source/components/resources/rscalc.c:631 +0x2cbbd7 #5 0x0000219ce3423777 in acpi_rs_create_resource_list(union acpi_opera= nd_object*, struct acpi_buffer*) ../../third_party/acpica/source/components= /resources/rscreate.c:178 +0x2c8777 #6 0x0000219ce342f1b2 in acpi_rs_get_method_data(acpi_handle, const ch= ar*, struct acpi_buffer*) ../../third_party/acpica/source/components/resour= ces/rsutils.c:770 +0x2d41b2 #7 0x0000219ce342f52d in acpi_walk_resources(acpi_handle, char*, acpi_= walk_resource_callback, void*) ../../third_party/acpica/source/components/r= esources/rsxface.c:731 +0x2d452d #8 0x0000219ce3246d48 in acpi::acpi_impl::walk_resources(acpi::acpi_im= pl*, acpi_handle, const char*, acpi::Acpi::resources_callable) ../../src/de= vices/board/lib/acpi/acpi-impl.cc:41 +0xebd48 #9 0x0000219ce324c94d in acpi::device_builder::gather_resources(acpi::= device_builder*, acpi::Acpi*, fidl::any_arena&, acpi::Manager*, acpi::devic= e_builder::gather_resources_callback) ../../src/devices/board/lib/acpi/devi= ce-builder.cc:52 +0xf194d #10 0x0000219ce32d8af2 in acpi::Manager::configure_discovered_devices(a= cpi::Manager*) ../../src/devices/board/lib/acpi/manager.cc:75 +0x17daf2 #11 0x0000219ce3200b44 in publish_acpi_devices(acpi::Manager*, zx_devic= e_t*, zx_device_t*) ../../src/devices/board/drivers/x86/acpi-nswalk.cc:102 = +0xa5b44 #12 0x0000219ce32126f7 in x86::X86::do_init(x86::X86*) ../../src/device= s/board/drivers/x86/x86.cc:65 +0xb76f7 #13.1 0x0000219ce321c8ea in =CE=BB(x86::X86::ddk_init::(anon class)*) ../= ../src/devices/board/drivers/x86/x86.cc:82 +0xc18ea #13 0x0000219ce321c8ea in fit::internal::target<(lambda at../../src/dev= ices/board/drivers/x86/x86.cc:81:19), false, false, void>::invoke(void*) ..= /../sdk/lib/fit/include/lib/fit/internal/function.h:181 +0xc18ea #14.2 0x0000219ce3461b2c in fit::internal::function_base<16UL, false, voi= d()>::invoke(const fit::internal::function_base<16UL, false, void ()>*) ../= ../sdk/lib/fit/include/lib/fit/internal/function.h:505 +0x306b2c #14.1 0x0000219ce3461b2c in fit::function_impl<16UL, false, void()>::oper= ator()(const fit::function_impl<16UL, false, void ()>*) ../../sdk/lib/fit/i= nclude/lib/fit/function.h:300 +0x306b2c #14 0x0000219ce3461b2c in async::internal::retained_task::Handler(async= _dispatcher_t*, async_task_t*, zx_status_t) ../../zircon/system/ulib/async/= task.cc:25 +0x306b2c #15.1 0x000022cc55016d91 in =CE=BB(const driver_runtime::Dispatcher::post= _task::(anon class)*, std::__2::unique_ptr >, zx_status_t= ) ../../src/devices/bin/driver_runtime/dispatcher.cc:715 +0x4bd91 #15 0x000022cc55016d91 in fit::internal::target<(lambda at../../src/dev= ices/bin/driver_runtime/dispatcher.cc:714:7), true, false, void, std::__2::= unique_ptr>, int>::invoke(void*, std::__2::unique_ptr >, int) ../../sdk/lib/fit/include/lib/fit/internal/function.= h:128 +0x4bd91 #16 0x000022cc5500fbc9 in fit::internal::function_base<24UL, true, void= (std::__2::unique_ptr>, int)>::invoke(const fit::internal= ::function_base<24UL, true, void (std::__2::unique_ptr >,= int)>*, std::__2::unique_ptr >, int) ../../sdk/lib/fit/i= nclude/lib/fit/internal/function.h:505 +0x44bc9 #17 0x000022cc5500f8dd in fit::callback_impl<24UL, true, void(std::__2:= :unique_ptr>, int)>::operator()(fit::callback_impl<24UL, = true, void (std::__2::unique_ptr >, int)>*, std::__2::uni= que_ptr >, int) ../../sdk/lib/fit/include/lib/fit/functio= n.h:451 +0x448dd #18 0x000022cc550006a6 in driver_runtime::callback_request::Call(driver= _runtime::callback_request*, std::__2::unique_ptr >, zx_s= tatus_t) ../../src/devices/bin/driver_runtime/callback_request.h:67 +0x356a6 #19 0x000022cc550074c8 in driver_runtime::Dispatcher::dispatch_callback= (driver_runtime::Dispatcher*, std::__2::unique_ptr >) ../= ../src/devices/bin/driver_runtime/dispatcher.cc:1093 = +0x3c4c8 #20 0x000022cc550082c1 in driver_runtime::Dispatcher::dispatch_callback= s(driver_runtime::Dispatcher*, std::__2::unique_ptr >, fbl::ref_ptr) ../../src/devices/b= in/driver_runtime/dispatcher.cc:1169 +0x3d2c1 #21.1 0x000022cc5501381e in =CE=BB(std::__2::unique_ptr >, fbl::ref_ptr, const driver_= runtime::Dispatcher::create_with_adder::(anon class)*) ../../src/devices/bi= n/driver_runtime/dispatcher.cc:338 +0x4881e #21 0x000022cc5501381e in fit::internal::target<(lambda at../../src/dev= ices/bin/driver_runtime/dispatcher.cc:337:7), true, false, void, std::__2::= unique_ptr>, fbl::ref_ptr>::invoke(void*, std::__2::unique_ptr >, fbl::ref_ptr) ../../sdk/lib/fit/inc= lude/lib/fit/internal/function.h:128 +0x4881e #22 0x000022cc5500fe7e in fit::internal::function_base<8UL, true, void(= std::__2::unique_ptr>, fbl::ref_ptr)>::invoke(const fit::internal::function_base<8UL, tr= ue, void (std::__2::unique_ptr >, fbl::re= f_ptr)>*, std::__2::unique_ptr >, fbl::ref_ptr) ../../sdk/li= b/fit/include/lib/fit/internal/function.h:505 +0x44e7e #23.1 0x000022cc55009964 in fit::function_impl<8UL, true, void(std::__2::= unique_ptr>, fbl::ref_ptr)>::operator()(const fit::function_impl<8UL, true, void (std::_= _2::unique_ptr >, fbl::ref_ptr)>*, std::__2::unique_ptr >, fbl::ref_ptr) ../../sdk/lib/fit/include/li= b/fit/function.h:300 +0x3e964 #23 0x000022cc55009964 in driver_runtime::Dispatcher::event_waiter::inv= oke_callback(driver_runtime::Dispatcher::event_waiter*, std::__2::unique_pt= r >, fbl::ref_ptr) ../../src/devices/bin/driver_runtime/dispatcher.h:299 +0x3e964 #24 0x000022cc5500935d in driver_runtime::Dispatcher::event_waiter::han= dle_event(std::__2::unique_ptr >, async_d= ispatcher_t*, async::wait_base*, zx_status_t, zx_packet_signal_t const*) ..= /../src/devices/bin/driver_runtime/dispatcher.cc:1259 +0x3e35d #25.1 0x000022cc55013c00 in async_loop_owned_event_handler::handle_event(async_loop_owned_event_handler*, zx_status_t, zx_packet_signal_t c= onst*, async_dispatcher_t*, async::wait_base*) ../../src/devices/bin/driver= _runtime/async_loop_owned_event_handler.h:59 +0x48c00 #25 0x000022cc55013c00 in async::wait_method, &async_loop_owned_event_han= dler::handle_event>::call_handler= (async_dispatcher_t*, async_wait_t*, zx_status_t, zx_packet_signal_t const*= ) ../../zircon/system/ulib/async/include/lib/async/cpp/wait.h:201 +0x48c00 #26.1 0x000022cc55035ead in async_loop_run_once(async_loop_t*, zx_time_t)= ../../zircon/system/ulib/async-loop/loop.c:415 +0x6a= ead #26 0x000022cc55035ead in async_loop_run(async_loop_t*, zx_time_t, _Boo= l) ../../zircon/system/ulib/async-loop/loop.c:288 +0x= 6aead #27 0x000022cc5503778f in async_loop_run_thread(void*) ../../zircon/sys= tem/ulib/async-loop/loop.c:840 +0x6c78f #28 0x000042d43f9f1edc in start_c11(void*) ../../zircon/third_party/uli= b/musl/pthread/pthread_create.c:55 +0xd7edc #29 0x000042d43fb2296d in thread_trampoline(uintptr_t, uintptr_t) ../..= /zircon/system/ulib/runtime/thread.cc:100 +0x20896d and #0 0x000022db2bfa3753 in acpi_rs_get_list_length(u8*, u32, acpi_size*)= ../../third_party/acpica/source/components/resources/rscalc.c:704 +0x2cb753 #1.2 0x000020c421f9777f in ubsan_get_stack_trace() compiler-rt/lib/ubsan= /ubsan_diag.cpp:41 +0x3d77f #1.1 0x000020c421f9777f in maybe_print_stack_trace() compiler-rt/lib/ubs= an/ubsan_diag.cpp:51 +0x3d77f #1 0x000020c421f9777f in ~scoped_report() compiler-rt/lib/ubsan/ubsan_= diag.cpp:387 +0x3d77f #2 0x000020c421f98385 in handletype_mismatch_impl() compiler-rt/lib/ub= san/ubsan_handlers.cpp:137 +0x3e385 #3 0x000020c421f97ead in compiler-rt/lib/ubsan/ubsan_handlers.cpp:142 = +0x3dead #4 0x000022db2bfa3753 in acpi_rs_get_list_length(u8*, u32, acpi_size*)= ../../third_party/acpica/source/components/resources/rscalc.c:704 +0x2cb753 #5 0x000022db2bfa0777 in acpi_rs_create_resource_list(union acpi_opera= nd_object*, struct acpi_buffer*) ../../third_party/acpica/source/components= /resources/rscreate.c:178 +0x2c8777 #6 0x000022db2bfac0f2 in acpi_rs_get_method_data(acpi_handle, const ch= ar*, struct acpi_buffer*) ../../third_party/acpica/source/components/resour= ces/rsutils.c:770 +0x2d40f2 #7 0x000022db2bfac46d in acpi_walk_resources(acpi_handle, char*, acpi_= walk_resource_callback, void*) ../../third_party/acpica/source/components/r= esources/rsxface.c:731 +0x2d446d #8 0x000022db2bdc3d48 in acpi::acpi_impl::walk_resources(acpi::acpi_im= pl*, acpi_handle, const char*, acpi::Acpi::resources_callable) ../../src/de= vices/board/lib/acpi/acpi-impl.cc:41 +0xebd48 #9 0x000022db2bdc994d in acpi::device_builder::gather_resources(acpi::= device_builder*, acpi::Acpi*, fidl::any_arena&, acpi::Manager*, acpi::devic= e_builder::gather_resources_callback) ../../src/devices/board/lib/acpi/devi= ce-builder.cc:52 +0xf194d #10 0x000022db2be55af2 in acpi::Manager::configure_discovered_devices(a= cpi::Manager*) ../../src/devices/board/lib/acpi/manager.cc:75 +0x17daf2 #11 0x000022db2bd7db44 in publish_acpi_devices(acpi::Manager*, zx_devic= e_t*, zx_device_t*) ../../src/devices/board/drivers/x86/acpi-nswalk.cc:102 = +0xa5b44 #12 0x000022db2bd8f6f7 in x86::X86::do_init(x86::X86*) ../../src/device= s/board/drivers/x86/x86.cc:65 +0xb76f7 #13.1 0x000022db2bd998ea in =CE=BB(x86::X86::ddk_init::(anon class)*) ../= ../src/devices/board/drivers/x86/x86.cc:82 +0xc18ea #13 0x000022db2bd998ea in fit::internal::target<(lambda at../../src/dev= ices/board/drivers/x86/x86.cc:81:19), false, false, void>::invoke(void*) ..= /../sdk/lib/fit/include/lib/fit/internal/function.h:181 +0xc18ea #14.2 0x000022db2bfdea6c in fit::internal::function_base<16UL, false, voi= d()>::invoke(const fit::internal::function_base<16UL, false, void ()>*) ../= ../sdk/lib/fit/include/lib/fit/internal/function.h:505 +0x306a6c #14.1 0x000022db2bfdea6c in fit::function_impl<16UL, false, void()>::oper= ator()(const fit::function_impl<16UL, false, void ()>*) ../../sdk/lib/fit/i= nclude/lib/fit/function.h:300 +0x306a6c #14 0x000022db2bfdea6c in async::internal::retained_task::Handler(async= _dispatcher_t*, async_task_t*, zx_status_t) ../../zircon/system/ulib/async/= task.cc:25 +0x306a6c #15.1 0x0000216d819f2d91 in =CE=BB(const driver_runtime::Dispatcher::post= _task::(anon class)*, std::__2::unique_ptr >, zx_status_t= ) ../../src/devices/bin/driver_runtime/dispatcher.cc:715 +0x4bd91 #15 0x0000216d819f2d91 in fit::internal::target<(lambda at../../src/dev= ices/bin/driver_runtime/dispatcher.cc:714:7), true, false, void, std::__2::= unique_ptr>, int>::invoke(void*, std::__2::unique_ptr >, int) ../../sdk/lib/fit/include/lib/fit/internal/function.= h:128 +0x4bd91 #16 0x0000216d819ebbc9 in fit::internal::function_base<24UL, true, void= (std::__2::unique_ptr>, int)>::invoke(const fit::internal= ::function_base<24UL, true, void (std::__2::unique_ptr >,= int)>*, std::__2::unique_ptr >, int) ../../sdk/lib/fit/i= nclude/lib/fit/internal/function.h:505 +0x44bc9 #17 0x0000216d819eb8dd in fit::callback_impl<24UL, true, void(std::__2:= :unique_ptr>, int)>::operator()(fit::callback_impl<24UL, = true, void (std::__2::unique_ptr >, int)>*, std::__2::uni= que_ptr >, int) ../../sdk/lib/fit/include/lib/fit/functio= n.h:451 +0x448dd #18 0x0000216d819dc6a6 in driver_runtime::callback_request::Call(driver= _runtime::callback_request*, std::__2::unique_ptr >, zx_s= tatus_t) ../../src/devices/bin/driver_runtime/callback_request.h:67 +0x356a6 #19 0x0000216d819e34c8 in driver_runtime::Dispatcher::dispatch_callback= (driver_runtime::Dispatcher*, std::__2::unique_ptr >) ../= ../src/devices/bin/driver_runtime/dispatcher.cc:1093 = +0x3c4c8 #20 0x0000216d819e42c1 in driver_runtime::Dispatcher::dispatch_callback= s(driver_runtime::Dispatcher*, std::__2::unique_ptr >, fbl::ref_ptr) ../../src/devices/b= in/driver_runtime/dispatcher.cc:1169 +0x3d2c1 #21.1 0x0000216d819ef81e in =CE=BB(std::__2::unique_ptr >, fbl::ref_ptr, const driver_= runtime::Dispatcher::create_with_adder::(anon class)*) ../../src/devices/bi= n/driver_runtime/dispatcher.cc:338 +0x4881e #21 0x0000216d819ef81e in fit::internal::target<(lambda at../../src/dev= ices/bin/driver_runtime/dispatcher.cc:337:7), true, false, void, std::__2::= unique_ptr>, fbl::ref_ptr>::invoke(void*, std::__2::unique_ptr >, fbl::ref_ptr) ../../sdk/lib/fit/inc= lude/lib/fit/internal/function.h:128 +0x4881e #22 0x0000216d819ebe7e in fit::internal::function_base<8UL, true, void(= std::__2::unique_ptr>, fbl::ref_ptr)>::invoke(const fit::internal::function_base<8UL, tr= ue, void (std::__2::unique_ptr >, fbl::re= f_ptr)>*, std::__2::unique_ptr >, fbl::ref_ptr) ../../sdk/li= b/fit/include/lib/fit/internal/function.h:505 +0x44e7e #23.1 0x0000216d819e5964 in fit::function_impl<8UL, true, void(std::__2::= unique_ptr>, fbl::ref_ptr)>::operator()(const fit::function_impl<8UL, true, void (std::_= _2::unique_ptr >, fbl::ref_ptr)>*, std::__2::unique_ptr >, fbl::ref_ptr) ../../sdk/lib/fit/include/li= b/fit/function.h:300 +0x3e964 #23 0x0000216d819e5964 in driver_runtime::Dispatcher::event_waiter::inv= oke_callback(driver_runtime::Dispatcher::event_waiter*, std::__2::unique_pt= r >, fbl::ref_ptr) ../../src/devices/bin/driver_runtime/dispatcher.h:299 +0x3e964 #24 0x0000216d819e535d in driver_runtime::Dispatcher::event_waiter::han= dle_event(std::__2::unique_ptr >, async_d= ispatcher_t*, async::wait_base*, zx_status_t, zx_packet_signal_t const*) ..= /../src/devices/bin/driver_runtime/dispatcher.cc:1259 +0x3e35d #25.1 0x0000216d819efc00 in async_loop_owned_event_handler::handle_event(async_loop_owned_event_handler*, zx_status_t, zx_packet_signal_t c= onst*, async_dispatcher_t*, async::wait_base*) ../../src/devices/bin/driver= _runtime/async_loop_owned_event_handler.h:59 +0x48c00 #25 0x0000216d819efc00 in async::wait_method, &async_loop_owned_event_han= dler::handle_event>::call_handler= (async_dispatcher_t*, async_wait_t*, zx_status_t, zx_packet_signal_t const*= ) ../../zircon/system/ulib/async/include/lib/async/cpp/wait.h:201 +0x48c00 #26.1 0x0000216d81a11ead in async_loop_run_once(async_loop_t*, zx_time_t)= ../../zircon/system/ulib/async-loop/loop.c:415 +0x6a= ead #26 0x0000216d81a11ead in async_loop_run(async_loop_t*, zx_time_t, _Boo= l) ../../zircon/system/ulib/async-loop/loop.c:288 +0x= 6aead #27 0x0000216d81a1378f in async_loop_run_thread(void*) ../../zircon/sys= tem/ulib/async-loop/loop.c:840 +0x6c78f #28 0x0000417ba4b4bedc in start_c11(void*) ../../zircon/third_party/uli= b/musl/pthread/pthread_create.c:55 +0xd7edc #29 0x0000417ba4c7c96d in thread_trampoline(uintptr_t, uintptr_t) ../..= /zircon/system/ulib/runtime/thread.cc:100 +0x20896d Link: https://github.com/acpica/acpica/commit/60cbb20c Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/rscalc.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index ffb448fa51fd..6e7a152d6459 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c @@ -606,15 +606,23 @@ acpi_rs_get_list_length(u8 *aml_buffer, } break; =20 - case ACPI_RESOURCE_NAME_SERIAL_BUS: + case ACPI_RESOURCE_NAME_SERIAL_BUS:{ =20 - minimum_aml_resource_length =3D - acpi_gbl_resource_aml_serial_bus_sizes - [aml_resource->common_serial_bus.type]; - extra_struct_bytes +=3D - aml_resource->common_serial_bus.resource_length - - minimum_aml_resource_length; - break; + /* Avoid undefined behavior: member access within misaligned address */ + + struct aml_resource_common_serialbus + common_serial_bus; + memcpy(&common_serial_bus, aml_resource, + sizeof(common_serial_bus)); + + minimum_aml_resource_length =3D + acpi_gbl_resource_aml_serial_bus_sizes + [common_serial_bus.type]; + extra_struct_bytes +=3D + common_serial_bus.resource_length - + minimum_aml_resource_length; + break; + } =20 case ACPI_RESOURCE_NAME_PIN_CONFIG: =20 @@ -680,10 +688,16 @@ acpi_rs_get_list_length(u8 *aml_buffer, */ if (acpi_ut_get_resource_type(aml_buffer) =3D=3D ACPI_RESOURCE_NAME_SERIAL_BUS) { + + /* Avoid undefined behavior: member access within misaligned address */ + + struct aml_resource_common_serialbus common_serial_bus; + memcpy(&common_serial_bus, aml_resource, + sizeof(common_serial_bus)); + buffer_size =3D acpi_gbl_resource_struct_serial_bus_sizes - [aml_resource->common_serial_bus.type] + - extra_struct_bytes; + [common_serial_bus.type] + extra_struct_bytes; } else { buffer_size =3D acpi_gbl_resource_struct_sizes[resource_index] + --=20 2.35.3