Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp856062ybb; Fri, 20 Mar 2020 09:10:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vviCfjoSnAJilhjlQRTloywd0Awto3I33Nx7SWYN73Y9R5rXrxS5FfhyQ2VmeTrHiNzkRei X-Received: by 2002:a9d:64ca:: with SMTP id n10mr7548026otl.325.1584720629058; Fri, 20 Mar 2020 09:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584720629; cv=none; d=google.com; s=arc-20160816; b=MEgw+WF55KXUAQ+GIlD9ee9wDnj8gz8/eBBWu/5yGXr9+4JFCMrSZH5wy89MwG8Gdu Js7e6yM8THOwRNDD5aObLR8PeZy5q+mv7SvqpIA3cwMIN+KU24xmur/vu9fGY6gI2UiQ MuqKoiTKQOhHTsGPGaWZAagdcKGz6WtaLFdjJ6pxWO4+WxVIU0xCcuoRyU0cH6x2xMJP HIll+UO39P62qS9D9OE219LbzZn+AIapumxJPLHhgFypU4yqPuzwAse87mXKXFDKdz80 tWkSiox0EiWT9Lnzj905C6SxZ6HC09Q8ORjvvu8x/+lIsI+k9jLOH96h8DKDXnLTEn+s EPPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=R+2BZLljduDR4gY9kJvfaxoG77rg51FKrPLFzBeLubM=; b=AEuOXfuPDgESnrM26OdUFH/Q3rXtkTgl31rRILf0zaYm/9bgLuj3yeb+5dBDx+WsF1 XGAvh79SuTBKanoX/p84tiU90owXLg3of3W/aWQzeX3/rlcie4Qo/1fIEPSJhE639bho YzZtwEVVdEaJMKHZ/nhLGq+jNDy1Ktid5y60gQEEg8u1eYmjEp1EvhQaW/5jfEsGAI7F nGBT6fmBsJmb80evIaDyN9a5ZKPtMMzG5ibLIG4lGBJqVrUY+LEYporuYA10n62xoOac /oKDD2QUBZ/A2IGOmt4xnRtGBqgAmljTqBDfs09xFrekWgBx3+vqsty5J/4nimvL1t8R rKRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KZhx8ody; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a190si2898572oib.146.2020.03.20.09.09.58; Fri, 20 Mar 2020 09:10:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KZhx8ody; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbgCTQIw (ORCPT + 99 others); Fri, 20 Mar 2020 12:08:52 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:25665 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726843AbgCTQIv (ORCPT ); Fri, 20 Mar 2020 12:08:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584720530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R+2BZLljduDR4gY9kJvfaxoG77rg51FKrPLFzBeLubM=; b=KZhx8odyDLqY/cCqwW445AjCK9R7MnjzROOB/V0psd2U1rzrG9On1cjxWYvk0XxfNvipyH VU/06jYO9lk8oUgJ8nDs/uVqaMi5FHx3Xo70bwfbx5SmfpnSYgJHpUhRtlH/EM0koWv/vR GKBNP05f/YrFQmsPS/iVxtwONL+u46s= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-463-iyaH6NcLOuildf2WJdn0Wg-1; Fri, 20 Mar 2020 12:08:48 -0400 X-MC-Unique: iyaH6NcLOuildf2WJdn0Wg-1 Received: by mail-wm1-f71.google.com with SMTP id v184so1971715wme.7 for ; Fri, 20 Mar 2020 09:08:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=R+2BZLljduDR4gY9kJvfaxoG77rg51FKrPLFzBeLubM=; b=P6mLRvX0uBwPDmi8ma80LfeTDqXjDm6s3o8nq4CKrP0YwYcjeAUNcw5fH2xrfji1bD mpTZb6GmqCXYZf3BQSDLfc3mANXh5Wmkp5aGz3ShM2Li5Sf8j4UOkteIyjjK8g6gy4OI CHE7j4NFRq0JeizYBIpb1ljIWMsMHL/kB3yBJL8/WeIjEl1ye2SEcP338gqyRf7nSsxA 4raxkMc4o7JNrCBhAVQPwfhYm5JXdHmGPg0FtQLcRylpUTn2WgH/8dySZbcaszC8Uacp D1ioGSCINpqPY6DENxGoEk+tTHXkmEfJmwHHXaK++rZFNcP7eEHZcciw8nc6Vk0+81P4 y6Kg== X-Gm-Message-State: ANhLgQ0hj+csYMbWYQeeo81Mbkk1cW0ITDeSGuY3qLiEVsUV83tEYqCd grvbCVcRN0H3mOkh394U9rwKGrWXPY1/DS0woGv4fbQSoiUHHq1dYcL74OqsIQZcEbaIuvlCb4C MJznBcnGRNBuAnNM+v20YKy3Z X-Received: by 2002:a05:6000:370:: with SMTP id f16mr12276234wrf.9.1584720527390; Fri, 20 Mar 2020 09:08:47 -0700 (PDT) X-Received: by 2002:a05:6000:370:: with SMTP id f16mr12276192wrf.9.1584720527078; Fri, 20 Mar 2020 09:08:47 -0700 (PDT) Received: from xz-x1 (CPEf81d0fb19163-CMf81d0fb19160.cpe.net.fido.ca. [72.137.123.47]) by smtp.gmail.com with ESMTPSA id x5sm9157795wrv.67.2020.03.20.09.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 09:08:46 -0700 (PDT) Date: Fri, 20 Mar 2020 12:08:42 -0400 From: Peter Xu To: Sean Christopherson Cc: Qian Cai , Paolo Bonzini , kvm@vger.kernel.org, LKML , Marc Zyngier , Christoffer Dall Subject: Re: slab-out-of-bounds due to "KVM: Dynamically size memslot array based on number of used slots" Message-ID: <20200320160842.GE127076@xz-x1> References: <8922D835-ED2A-4C48-840A-F568E20B5A7C@lca.pw> <20200320043403.GH11305@linux.intel.com> <5FF6AF4E-EB99-4111-BBB2-FE09FFBEF5C4@lca.pw> <20200320135346.GA16533@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200320135346.GA16533@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 20, 2020 at 06:53:46AM -0700, Sean Christopherson wrote: > On Fri, Mar 20, 2020 at 09:49:03AM -0400, Qian Cai wrote: > > > > > > > On Mar 20, 2020, at 12:34 AM, Sean Christopherson wrote: > > > > > > On Thu, Mar 19, 2020 at 11:59:23PM -0400, Qian Cai wrote: > > >> Reverted the linux-next commit 36947254e5f98 (“KVM: Dynamically size memslot array based on number of used slots”) > > >> fixed illegal slab object redzone accesses. > > >> > > >> [6727.939776][ T1818] BUG: KASAN: slab-out-of-bounds in gfn_to_hva+0xc1/0x2b0 [kvm] > > >> search_memslots at include/linux/kvm_host.h:1035 > > > > > > Drat. I'm guessing lru_slot is out of range after a memslot is deleted. > > > This should fix the issue, though it may not be the most proper fix, e.g. > > > it might be better to reset lru_slot when deleting a memslot. I'll try and > > > reproduce tomorrow, unless you can confirm this does the trick. > > > > It works fine. > > Thanks! I'll send a proper patch in a bit, tweaking a selftest to try and > hit this as well. Would resetting lru_slot be better? So to avoid other potential references to an obsolete lru_slot outside search_memslots(). E.g., I see that s390 has another function (gfn_to_memslot_approx) used it. Thanks, -- Peter Xu