Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp292176ybv; Thu, 13 Feb 2020 00:20:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwZAppFovVMT93m4senUaanWMKB3yLkUQVsGm2ZaXaN2EfPwOTQkyZaeNDyD6Y2YrYC0etH X-Received: by 2002:aca:f517:: with SMTP id t23mr2035612oih.160.1581582005868; Thu, 13 Feb 2020 00:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581582005; cv=none; d=google.com; s=arc-20160816; b=N9hQmRYfFg7M6QLRFYkL4wxIIpH/8wSm69j6ESwrmGqcU4z8xtmzBOtPUvKQ7xCNH3 0XSaZ2LrzVHf4qdn6yWdzvFUeQTHO1V2eujBD0v0RFmMOQEob/xC+VIAnofgns3MMhcR L5vIRjICkBsZsLDobnn+u7IMDCRygQnBv7o11VHwPMJ7xe2GPqQTJ5Ij7pf2xX34DheA WI0B5vM0pk+MepbQi6DBCvrkQS7+dy3VaKH9u2KUKzige0voK0MQilQl/pAAy7Yaxm4B 8IZ5JVIIMMiumbddB1ttrEnv1NtIJgP5XOdJyPDq6lRWS4amsIPcpBEcIf4imrMRpxB6 bCBw== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=XYlYFpq/uEAtFeQWSEqRoXkTiLjY20HZwxOhR/Qz9Bg=; b=X5kZAGNYWmtrgl/vQfI927lTXIkjjBgdjojZG2+utn5NnwAcw2flJdXjqI/MNsmL78 xy/7bgxML7NzFOpVrSgK141c1Ysh/8SjfmA0od3WR8v6+SIUir8vCdspjdjO0RWpAK0W KtU2bW1AIGu1Xv1vufzU+LaViWLxlSsLaK/1oEDrHvVOkUxL4hp3Wz6veoj3TK89C+pc bLvjyZINq0LeDLfILDLzkifwu702Mj8+NEyal2StBbqf3wpUnCROXsM8IZvEr8ppCemN wNtZ049zPrx1R2VKsx6t1tcUPPyQieDseZ2kSYQ/woZkh3uNoprXTAH9uSRqVSPgm1g/ LphA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si909019oie.52.2020.02.13.00.19.53; Thu, 13 Feb 2020 00:20:05 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729502AbgBMITW (ORCPT + 99 others); Thu, 13 Feb 2020 03:19:22 -0500 Received: from s3.sipsolutions.net ([144.76.43.62]:57470 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbgBMITW (ORCPT ); Thu, 13 Feb 2020 03:19:22 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) (envelope-from ) id 1j29iF-0089Y1-N7; Thu, 13 Feb 2020 09:19:08 +0100 Message-ID: Subject: Re: [RFC PATCH v2] UML: add support for KASAN under x86_64 From: Johannes Berg To: Patricia Alfonso Cc: Jeff Dike , Richard Weinberger , anton.ivanov@cambridgegreys.com, Andrey Ryabinin , Dmitry Vyukov , David Gow , Brendan Higgins , kasan-dev , LKML , linux-um@lists.infradead.org Date: Thu, 13 Feb 2020 09:19:06 +0100 In-Reply-To: (sfid-20200213_013812_463819_2E8172A0) References: <20200210225806.249297-1-trishalfonso@google.com> <13b0ea0caff576e7944e4f9b91560bf46ac9caf0.camel@sipsolutions.net> (sfid-20200213_013812_463819_2E8172A0) Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 (3.34.2-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-02-12 at 16:37 -0800, Patricia Alfonso wrote: > > > That also means if I have say 512MB memory allocated for UML, KASAN will > > use an *additional* 64, unlike on a "real" system, where KASAN will take > > about 1/8th of the available physical memory, right? > > > Currently, the amount of shadow memory allocated is a constant based > on the amount of user space address space in x86_64 since this is the > host architecture I have focused on. Right, but again like below - that's just mapped, not actually used. But as far as I can tell, once you actually start running and potentially use all of your mem=1024 (MB), you'll actually also use another 128MB on the KASAN shadow, right? Unlike, say, a real x86_64 machine where if you just have 1024 MB physical memory, the KASAN shadow will have to fit into that as well. > > > +# With these files removed from instrumentation, those reports are > > > +# eliminated, but KASAN still repeatedly reports a bug on syscall_stub_data: > > > +# ================================================================== > > > +# BUG: KASAN: stack-out-of-bounds in syscall_stub_data+0x299/0x2bf > > > +# Read of size 128 at addr 0000000071457c50 by task swapper/1 > > > > So that's actually something to fix still? Just trying to understand, > > I'll test it later. > > > Yes, I have not found a fix for these issues yet and even with these > few files excluded from instrumentation, the syscall_stub_data error > occurs(unless CONFIG_STACK is disabled, but CONFIG_STACK is enabled by > default when using gcc to compile). It is unclear whether this is a > bug that KASAN has found in UML or it is a mismatch of KASAN error > detection on UML. Right, ok, thanks for the explanation. I guess then stack instrumentation should be disabled for this patch initially. > > Heh, you *actually* based it on my patch, in git terms, not just in code > > terms. I think you should just pick up the few lines that you need from > > that patch and squash them into this one, I just posted that to > > demonstrate more clearly what I meant :-) > > > I did base this on your patch. I figured it was more likely to get > merged before this patch anyway. To clarify, do you want me to include > your constructors patch with this one as a patchset? Well I had two patches: (1) the module constructors one - I guess we need to test it, but you can include it here if you like. I'm kinda swamped with other things right now, no promises I can actually test it soon, though I really do want to because that's the case I need :) (2) the [DEMO] patch - you should just take the few lines you need from that (in the linker script) and stick it into this patch. Don't even credit me for that, I only wrote it as a patch instead of a normal text email reply because I couldn't figure out how to word things in an understandable way... Then we end up with 2 patches again, the (1) and your KASAN one. There's no point in keeping the [DEMO] separate, and > > > + if (mmap(start, > > > + len, > > > + PROT_READ|PROT_WRITE, > > > + MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, > > > + -1, > > > + 0) == MAP_FAILED) > > > + os_info("Couldn't allocate shadow memory %s", strerror(errno)); > > > > If that fails, can we even continue? > > > Probably not, but with this executing before main(), what is the best > way to have an error occur? Or maybe there's a way we can just > continue without KASAN enabled and print to the console that KASAN > failed to initialize? You can always "exit(17)" or something. I'm not sure you can continue without KASAN? Arguably it's better to fail loudly anyway if something as simple as the mmap() here fails - after all, that probably means the KASAN offset in Kconfig needs to be adjusted? johannes