Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2071707ybe; Thu, 12 Sep 2019 04:11:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUngA+BXdPwLwo0YFcmTkSPasC3TlGHwqZV3yb2bHko1He0dSIs36sKAd477o6xSoHVeW5 X-Received: by 2002:aa7:d34a:: with SMTP id m10mr40294920edr.3.1568286673050; Thu, 12 Sep 2019 04:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568286673; cv=none; d=google.com; s=arc-20160816; b=D8FX9L6YO7LVE8Vrh+C5bG64BihX5uMuZIfljwuv0BXSYR7mNlU/8odIO+Ilhvfwjh 4C5DO5UanxyXl3Prtn1sbZhXkd+gs5sG43r98wstoEGOHU4OZ8DEPnaW8gp3q0CGy1ep pfVfE3zh2c3iy6e73qZViQ81UrDsH/418QGTj5tGdO1b76u7iFu64/SV3F1FpSXqSNr2 zQx/dod9n0krI/uftxFRqH4xFZ8yko5ZlcWuIdR/G2uXtQFZpnzHjkZdGYnHOmNPgV3h p7PPNSgzZxWlHDE9Eyj8Ri473tVY1jj+/BUFSMIEV+dueclBaHRYHVTjobuM3QJa9YWi sdhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=yVN1ZZSWQYVoC1SXpA9tvMNsHfil1JB5rK1LZOaqGPg=; b=tK5j9L2xPfDfZxTr28VDbmsHexrBci5zEbzlVZvuTRzocGdXWT37sZA+wIHmyI22Xl 7dlbXc2YMg/6GR0BgMZPohAYFT13fpsjskLWw6uUV3ma3n7kZCOG0dWZ694TK4fiTGjO KUQTkxIm2xQTdxZLa0Ra2fVcXT9wTO5TETHtWHKUNj9MliPa9xtHCmPdH690IpIEtIbv dl84fP64abtgXGWJL1KicNHPPDhdQOWDbZOzhuI3/B4N7hDsEfeiTdkuLFoW3SR/3Zf+ 27FeO8lkRwzadUYS3UzjxQLXs2L0oU/jD2hvNKvLZ1qYGdxLt3IoBkBW5b2ryszkiYHt Y9ZA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 z11si8789177ejm.28.2019.09.12.04.10.48; Thu, 12 Sep 2019 04:11:13 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731278AbfILLIk (ORCPT + 99 others); Thu, 12 Sep 2019 07:08:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37110 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbfILLIk (ORCPT ); Thu, 12 Sep 2019 07:08:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4C53A37195; Thu, 12 Sep 2019 11:08:39 +0000 (UTC) Received: from thuth.remote.csb (ovpn-204-41.brq.redhat.com [10.40.204.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97FA41001948; Thu, 12 Sep 2019 11:08:34 +0000 (UTC) Subject: Re: [PATCH] KVM: s390: Do not leak kernel stack data in the KVM_S390_INTERRUPT ioctl To: Christian Borntraeger , Janosch Frank , kvm@vger.kernel.org Cc: David Hildenbrand , Cornelia Huck , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190912090050.20295-1-thuth@redhat.com> <4ed0c815-c598-bb0f-9841-d579fc62877f@de.ibm.com> From: Thomas Huth Openpgp: preference=signencrypt Autocrypt: addr=thuth@redhat.com; prefer-encrypt=mutual; keydata= mQINBFH7eUwBEACzyOXKU+5Pcs6wNpKzrlJwzRl3VGZt95VCdb+FgoU9g11m7FWcOafrVRwU yYkTm9+7zBUc0sW5AuPGR/dp3pSLX/yFWsA/UB4nJsHqgDvDU7BImSeiTrnpMOTXb7Arw2a2 4CflIyFqjCpfDM4MuTmzTjXq4Uov1giGE9X6viNo1pxyEpd7PanlKNnf4PqEQp06X4IgUacW tSGj6Gcns1bCuHV8OPWLkf4hkRnu8hdL6i60Yxz4E6TqlrpxsfYwLXgEeswPHOA6Mn4Cso9O 0lewVYfFfsmokfAVMKWzOl1Sr0KGI5T9CpmRfAiSHpthhHWnECcJFwl72NTi6kUcUzG4se81 O6n9d/kTj7pzTmBdfwuOZ0YUSqcqs0W+l1NcASSYZQaDoD3/SLk+nqVeCBB4OnYOGhgmIHNW 0CwMRO/GK+20alxzk//V9GmIM2ACElbfF8+Uug3pqiHkVnKqM7W9/S1NH2qmxB6zMiJUHlTH gnVeZX0dgH27mzstcF786uPcdEqS0KJuxh2kk5IvUSL3Qn3ZgmgdxBMyCPciD/1cb7/Ahazr 3ThHQXSHXkH/aDXdfLsKVuwDzHLVSkdSnZdt5HHh75/NFHxwaTlydgfHmFFwodK8y/TjyiGZ zg2Kje38xnz8zKn9iesFBCcONXS7txENTzX0z80WKBhK+XSFJwARAQABtB5UaG9tYXMgSHV0 aCA8dGh1dGhAcmVkaGF0LmNvbT6JAjgEEwECACIFAlVgX6oCGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheAAAoJEC7Z13T+cC21EbIP/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, 12 Sep 2019 13:08:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <4ed0c815-c598-bb0f-9841-d579fc62877f@de.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Thu, 12 Sep 2019 11:08:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/09/2019 12.47, Christian Borntraeger wrote: > > > On 12.09.19 11:00, Thomas Huth wrote: >> When the userspace program runs the KVM_S390_INTERRUPT ioctl to inject >> an interrupt, we convert them from the legacy struct kvm_s390_interrupt >> to the new struct kvm_s390_irq via the s390int_to_s390irq() function. >> However, this function does not take care of all types of interrupts >> that we can inject into the guest later (see do_inject_vcpu()). Since we >> do not clear out the s390irq values before calling s390int_to_s390irq(), >> there is a chance that we copy unwanted data from the kernel stack >> into the guest memory later if the interrupt data has not been properly >> initialized by s390int_to_s390irq(). > > You mean by using the migration callbacks to get all interrupts back to > userspace? Oh, I was not thinking about GET_IRQ_STATE yet, I was thinking about __deliver_pfault_init() which would deliver the value into the guest memory (from where the userspace program could extract it again). >> Specifically, the problem exists with the KVM_S390_INT_PFAULT_INIT >> interrupt: s390int_to_s390irq() does not handle it, but the function >> __deliver_pfault_init() will later copy the uninitialized stack data >> from the ext.ext_params2 into the guest memory. > > Shouldnt we add some more detailed description how this can happen? > Something like > "By using the KVM_S390_INTERRUPT ioctl with a KVM_S390_INT_PFAULT_INIT > interrupt followed by the KVM_S390_GET_IRQ_STATE ioctl the user can > extract a value from the kernel stack." GET_IRQ_STATE certainly deserves to be mentioned here, I'll add it to the patch description and will send a v2. Thomas