Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp941138pxb; Fri, 22 Apr 2022 14:56:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywK9gzUUaLUqySuqRkcr05f4DtXHnX34FX5w6YvojOZdivDbIAG7qTabEuEbZ/zAzg6aS7 X-Received: by 2002:a63:fd05:0:b0:3aa:127d:538a with SMTP id d5-20020a63fd05000000b003aa127d538amr5521306pgh.95.1650664583345; Fri, 22 Apr 2022 14:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650664583; cv=none; d=google.com; s=arc-20160816; b=T+3M0g1OmVz5Lpa5B4TNWnjFSxgllaat4CO5OEjueUq+/7BkZ9kJOYnngJk/8rYDW3 Bz+2oNMTt0ox3hFYDwL1MxQCb4V05mol+IK2wLTdNx9Cypw9d1rmnci+zhfTR1qZB3mZ hdbGTCAtwMcahtigex+dQeHPG530n6z+gHPRvAxVNfQnZziy7N5h6fODdfQJoiXpx3HM 9BMaIBW3pplgYLYrzLYNfKfW5znQyDzBfuIOlt/P2bZYIJeFweiY6wG1v4CbyK1HnPKb d1qv3kO7TTo1SKNLsW3FUnXoUt/NfzlL4moBl9zAm59Dr0JbbXMKxqjJ4gTFuSE58dDY kbpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wV4+wKd7iChZst/tUl6qyMcJ9gSBiiInVBm1OCVhVNo=; b=gzx83MIoRNpbAdM4rFDmv4GdirxI5EO+qglPEI1yzEo5jPWXGALf/ndseFsJWVA+HJ sHh75xdxWxffQoyYhBkLbpapdIhZr8d6cGkty0XSG+QrU6JGil5mM3WrOOnFwakMmYEw QwxcF/Ee4KLYK+kOk6FWfHe0nEQEd1N+A4dTUQgmAmXUjygHNiSIOKZvn+es030rUOa0 n0PpG2zCm7hG7+uiMYZnDJ1JUjXVs2k2z4xtWjGwCMqiTxSsoe7y/DbBADyuMJMt4vVn RJmIeOIgSDmtkKBn1zC3E4IfIZ96fTd3jKOkg6Hc1cw0oAuI6GmlHk2h2PoXG5AsMYK3 kqQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="TIHxAMM/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q11-20020a65494b000000b003a6d2c0b6f3si9326269pgs.573.2022.04.22.14.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:56:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="TIHxAMM/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1FB33241A8C; Fri, 22 Apr 2022 13:04:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1449448AbiDVPaZ (ORCPT + 99 others); Fri, 22 Apr 2022 11:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354037AbiDVPaV (ORCPT ); Fri, 22 Apr 2022 11:30:21 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821FB5D5C2; Fri, 22 Apr 2022 08:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650641247; x=1682177247; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=e11uwC3A+RGrIWC3PPNgkM7p6epgPs6roRgaCbYnPFA=; b=TIHxAMM/gjGQfiaTKF++EngJfK8zLucvnn5wfcvdJPNUELyj8xblte4j XRqfp384GBgMDuviILnOq9SwozLyifDjptiRcUkKHfjXA9yNGpuQykue9 hP+JMBxCcQ1Jk9Lxgq3wOsBZLmxfu0OBjixu9+YR2sIfeg9vQm7nKdJpA Qdqhbxx0Ex+gAcl69Nn3LK8eznyF8399qYYluWBsDsFnwKrFVUp9wPnSb cpevJZfASNWa8lUhCv0PCMC6aG7F8RXZJDm9FYrq1Q0dD5nUbQpoH+bkz BXATvqJt9v1jdIkbq/KHeGXWg5ck1XzTlJ2bb491UEzPDmJj7x/Me6pU3 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="245272949" X-IronPort-AV: E=Sophos;i="5.90,282,1643702400"; d="scan'208";a="245272949" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 08:27:27 -0700 X-IronPort-AV: E=Sophos;i="5.90,282,1643702400"; d="scan'208";a="577948682" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.162]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 08:27:24 -0700 Received: by lahna (sSMTP sendmail emulation); Fri, 22 Apr 2022 18:26:10 +0300 Date: Fri, 22 Apr 2022 18:26:10 +0300 From: Mika Westerberg To: "Rafael J. Wysocki" Cc: Linux ACPI , LKML , Bjorn Helgaas , Linux PM Subject: Re: [PATCH] ACPI: bus: Avoid non-ACPI device objects in walks over children Message-ID: References: <11974495.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11974495.O9o76ZdvQC@kreacher> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 Hi Rafael, On Fri, Apr 22, 2022 at 05:13:48PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > When walking the children of an ACPI device, take extra care to avoid > using to_acpi_device() on the ones that are not ACPI devices, because > that may lead to out-of-bounds access and memory corruption. > > While at it, make the function passed to acpi_dev_for_each_child() > take a struct acpi_device pointer argument (instead of a struct device > one), so it is more straightforward to use. > > Fixes: b7dd6298db81 ("ACPI: PM: Introduce acpi_dev_power_up_children_with_adr()") > Reported-by: kernel test robot > BugLink: https://lore.kernel.org/lkml/20220420064725.GB16310@xsang-OptiPlex-9020/ > Signed-off-by: Rafael J. Wysocki > --- > > The commit being fixed is present in linux-next. > > --- > drivers/acpi/bus.c | 24 ++++++++++++++++++++++-- > drivers/acpi/device_pm.c | 5 +---- > include/acpi/acpi_bus.h | 2 +- > 3 files changed, 24 insertions(+), 7 deletions(-) > > Index: linux-pm/drivers/acpi/bus.c > =================================================================== > --- linux-pm.orig/drivers/acpi/bus.c > +++ linux-pm/drivers/acpi/bus.c > @@ -1070,10 +1070,30 @@ int acpi_bus_for_each_dev(int (*fn)(stru > } > EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev); > > +struct acpi_dev_walk_context { > + int (*fn)(struct acpi_device *, void *); > + void *data; > +}; > + > +static int acpi_dev_for_one_check(struct device *dev, void *context) > +{ > + struct acpi_dev_walk_context *adwc = context; > + > + if (dev->bus != &acpi_bus_type) > + return 0; I wonder if it make sense to add dev_is_acpi() that does the above analoguos to dev_is_pci()? Regardless of that, Reviewed-by: Mika Westerberg