Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp312130pxu; Thu, 7 Jan 2021 05:49:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdatZZ3wpSbhQM3tB18oWvU21yscgDu4mFAeiHeOjxggDuDUHfxY6P/H1mRnZR1OfPNi93 X-Received: by 2002:a50:bb44:: with SMTP id y62mr1759846ede.103.1610027395046; Thu, 07 Jan 2021 05:49:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610027395; cv=none; d=google.com; s=arc-20160816; b=JF45DR6vJAEz53k0sEnSxX769cCG6L3JLsOedzPoTxUNP+RvFP2PJTs5WHJzhI+viv ZJBhdaeioX8aY8IPnMbRuKpY0A4iCas3fLTIl2oluQ9NkWu4fxwViUi9mPQZHg3xW1vk cWm0ApjnAU6G3byrCQrjE8IAcBhgCxUWcj420LL0u0X7Fcns2fZENIf+M9KsEtEsHpZj dF4BpcUb6/1MkvTH4W71y8dMLQ1V8ufB5mH5ZMohOpwE6XfzcLXmxamXNpiBPUsZTNVx 1lJYhj8Afj+KX3OmEh6T2y2Jc9FKsr3oAv9MB1FB0P5FJtg5gOTm3lMHHu3Ug2P4TmcZ LeXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=FxOc7uHglOoDfD1fFSW1c40P0G5PgpxQwefSb6uXKX0=; b=Ei19JxhJIAieiTwK71ZfrzMHiOvtg1/jWzL9eHhqg8l+tCKKB8gPdpSdGFTA+woHhR cLvByYegkF4YiBH7r2BkDcrWUesX0gOvhl/+YCSeGgInLmh6DsTFKvQpVi0gqlJp+/6Z JydEurpkJZ5gtNXD2N/08sTLppl19NtOqTdKzlDwn4TULd2kvWaqJTlDM3i/6LdcwluT zCcOSl903AGvAQRRQl6TyQ2NyQ4D8qny84V4B/Sv8Y/haafan+/08pz3Xbvhc73fI6K/ kFlY7u4G+QZ5nH/0lWNfGNksSo6bQ43Btt2yNOmm0aZQVneCukmXSUgGP8aRHTdkGEt1 eyvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si2175078ejp.228.2021.01.07.05.49.31; Thu, 07 Jan 2021 05:49:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728602AbhAGNsw (ORCPT + 99 others); Thu, 7 Jan 2021 08:48:52 -0500 Received: from mail-ot1-f50.google.com ([209.85.210.50]:34719 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728167AbhAGNsw (ORCPT ); Thu, 7 Jan 2021 08:48:52 -0500 Received: by mail-ot1-f50.google.com with SMTP id a109so6314199otc.1; Thu, 07 Jan 2021 05:48:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FxOc7uHglOoDfD1fFSW1c40P0G5PgpxQwefSb6uXKX0=; b=UGg5UZQVM3Gi3eSa+RqFiRAjA0wgmqpMLEiRDydpJ1RDflXwLZTe41E2UkIeTwCi8e xTrZ9uLl0rb+hJGJGiyyDurN1MJuVrfDxKVeUMgL1i2y63VoPCg4PE4ef1LBFnxSSF3U KEgWVHF5BhQUtFEJuM5qqtUFjhdH3KIx84gCt8fprQEoXB3UY5Vs8FSHjSb06rhjDYoh b9Wy02YPn/wLDG7kB5WCaNITGOdyQPEd11LC4vqys5+cxrk7RHKLLlOhDJhqqWiy8OW5 tyuCh0Py8IC0wcd08cPbp/JXQY2drkeYFwYYb3aKFHHgsR6DSq3j9rbEnGIIESoUj0XL UiAQ== X-Gm-Message-State: AOAM530XbL94yaYQbqD8Hy3dTrXjXu+SYS5llrkPc7EzL2Sm39GPoQof 4WSSDUOU+wtyARYkZxWZEPHXm6Pe/ppBf6kV5xE= X-Received: by 2002:a9d:208a:: with SMTP id x10mr6538983ota.260.1610027290930; Thu, 07 Jan 2021 05:48:10 -0800 (PST) MIME-Version: 1.0 References: <20201218040826.57203-1-decui@microsoft.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 7 Jan 2021 14:47:34 +0100 Message-ID: Subject: Re: [PATCH] ACPI: scan: Fix a Hyper-V Linux VM panic caused by buffer overflow To: Dexuan Cui Cc: Michael Kelley , "linux-acpi@vger.kernel.org" , "rjw@rjwysocki.net" , "len.brown@intel.com" , "wei.liu@kernel.org" , "linux-kernel@vger.kernel.org" , Stephen Hemminger , Haiyang Zhang , KY Srinivasan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 5, 2021 at 11:02 PM Dexuan Cui wrote: > > > From: Michael Kelley > > Sent: Tuesday, December 22, 2020 5:56 AM > > From: Dexuan Cui > > Sent: Thursday, December 17, 2020 > > 8:08 PM > > > > > > Linux VM on Hyper-V crashes with the latest mainline: > > > ... > > > --- a/drivers/acpi/scan.c > > > +++ b/drivers/acpi/scan.c > > > @@ -674,7 +674,8 @@ int acpi_device_add(struct acpi_device *device, > > > } > > > if (!found) { > > > acpi_device_bus_id = new_bus_id; > > > - strcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device)); > > > + strlcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device), > > > + sizeof(acpi_device_bus_id->bus_id)); > > > acpi_device_bus_id->instance_no = 0; > > > list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); > > > } > > > > Reviewed-by: Michael Kelley > > Hi, ACPI maintainers, > Would you please take a look at the small fix? Currently the mainline Linux > kernel, running in a VM on Hyper-V, has been broken for almost 3 weeks, > i.e. the VM always panics when it boots. The root cause is a VM issue AFAICS, though. > The patch has already had Michael's Reviewed-by. > > BTW, the patch should have a stable tag: > Cc: > > Or, do you want the patch to go through the Hyper-V tree? > https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/log/?h=hyperv-fixes > > The small patch is unlikely to cause a merge conflict, and it only affects > Linux VMs on Hyper-V so far. It doesn't look like the right fix to me, though. The problem appears to be that the string coming from _HID is too long (which is a spec violation). The patch truncates it to match the length of the target buffer, but that is not particularly useful. It would be better to use something like kstrdup_const() to initialize acpi_device_bus_id->bus_id IMV.