Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6207105pxb; Tue, 16 Feb 2021 20:45:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6D8A3mowEHk6FQWWRmBW0iO/oxx9ZOfUXTe6k5Z+aLFqajM75K0VwLAxOCl78WJnWKnEm X-Received: by 2002:aa7:c448:: with SMTP id n8mr16314910edr.177.1613537154341; Tue, 16 Feb 2021 20:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613537154; cv=none; d=google.com; s=arc-20160816; b=Rhi6RXAzqLQbTJkctD2BHI4UTp+XtV+DA42uR4IWE4SRAxWpuCVts5d97R/vMs9NIM B6HEAERRhQSoqv10mvlpFSgBlk9j/2If5TVLbYTK+kwXePilnfaa1zwONTCRo5Mlh246 tI/PibZgxdk5n2yC4abNNgKlbwIYBzPHuEhN+Pomn8p8DuUGqfKVVw82es1asN033qO/ BPs7ipPU5RVY1/nysnYDeG+S5Jnh4M/MSI6OAUosk9WTxZmzd0Xc7WvGWiWYYaqnSsDX F2E5u7uFHHfXdG5XvClxSrrFwb1qTzkfgP+iDKLKwcNW5N783CEwIfiY7mGRwcvTbPsu WnrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8m8v3N1mfBy+Rw2JWENvO+sd3wm4zI7IbdM3+bR1i2o=; b=uHnvjSFzZf3YkN0Ry6nHNeWDfLFK0MCScIbNSZ+sIfX+ev7Aw00Lidf7MJ+SJ/1Hg3 TSBTRM+Kz1HOvnbDzovqv/A45xEWdqMm+mNCGeewRzdPZOVHzdBasQ0zpSgksXO3Nl4d CejmTXJmdAUTKAl2WeikMJTgJn6r6L6c7YCRjpER1+4QM689LT4qD6JCNkKyVSDW+Uqx xyjBHc+jSE4dKNFNFv8tU/x7HAQx7bxoP2TwRBRGZwh4G4e5t+YQMQ0vO0+rtOk2syDd YyM5zWoJOSBkQxEdMyxIQbo5fI5ZLADRQTit0a5NkK46sNX2tNsAyk2TDnQkbTx0mZpR Kymg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQp+0wMx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zg3si770822ejb.14.2021.02.16.20.45.30; Tue, 16 Feb 2021 20:45:54 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=CQp+0wMx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbhBQEnX (ORCPT + 99 others); Tue, 16 Feb 2021 23:43:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbhBQEnJ (ORCPT ); Tue, 16 Feb 2021 23:43:09 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C63AC061574 for ; Tue, 16 Feb 2021 20:42:29 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id q8so5722459qvx.11 for ; Tue, 16 Feb 2021 20:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8m8v3N1mfBy+Rw2JWENvO+sd3wm4zI7IbdM3+bR1i2o=; b=CQp+0wMx4TvKt6+vvq9D4g27VNgYWGQn/cvb0q4cw2sVCD4eGVC4O5mLyF03jZvWWP /IiFu06UsjaLcG9CcWqPnOfCPC2rxpsuW+dWB6+VA4hx+fP6VvKu3f3DPlyGb27WmERW VTj8G1cM1PKAja4VA92N6age/9SPnCs/AIitEQPYsbdnYAMhL4al1gCw/yP89X+8oOsT sgQOBhyw+ln41OQq75An2d5ArH9wn2SYxUNQgE5jthTal3puZPHOJGyhputUC5zuwqt3 OJSgY72FSh9SUeEs7MFnb41hF6CimKxRn8Oq7ejnMO7Mv+L7SfOTC0Bja2Ru+wUBa+Wm 0glQ== 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:content-transfer-encoding; bh=8m8v3N1mfBy+Rw2JWENvO+sd3wm4zI7IbdM3+bR1i2o=; b=edeMSpIGBEGM9wFKTLvVmQe5uqA8FYfZr1ME3yeQT13ZlkrIt3tYp8VicY5LeYMBH3 ezUi3grg/18qvC6uF1aIMZTQz/3X/GDemfBYQ014UJqZr4qfD7rXaQsui7Zs9FpIG+Lv IB1JcADBdZWaszpJqNQgu5R6os6npF9nDkFAK6l/Rq/GkKdt2tYrPLGHOpJSZSt+mqGx WYPDVeu1Urq8m/nqWnjYFkdxjWQg6q6rIzcicEhJb3DiVxDsbF+RXPa9sXXhKAH80Lvp L/Pewy/PaRLeW8THRtaC8eaCLa7YRYYfybwvk9fuq1LpJoNHiIStxp2BFzVgjhKIx4ux PZMQ== X-Gm-Message-State: AOAM533mfyMF5yl+AApovI2kO3P+YDy2CvInRcGoRfsdgp4TCfaalsO0 zupS+L8URni/FCFkYtCNjwmieC66tC1hWUfO/lfahw== X-Received: by 2002:a0c:a5e2:: with SMTP id z89mr23006257qvz.37.1613536947982; Tue, 16 Feb 2021 20:42:27 -0800 (PST) MIME-Version: 1.0 References: <20210118145310.crnqnh6kax5jqicj@distanz.ch> <6e9ee3a1-0e16-b1fc-a690-f1ca8e9823a5@ghiti.fr> <24857bfc-c557-f141-8ae7-2e3da24f67f5@ghiti.fr> In-Reply-To: <24857bfc-c557-f141-8ae7-2e3da24f67f5@ghiti.fr> From: Dmitry Vyukov Date: Wed, 17 Feb 2021 05:42:16 +0100 Message-ID: Subject: Re: riscv+KASAN does not boot To: Alex Ghiti Cc: Albert Ou , Bjorn Topel , Palmer Dabbelt , LKML , nylon7@andestech.com, syzkaller , Andreas Schwab , Paul Walmsley , Tobias Klauser , linux-riscv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 16, 2021 at 9:42 PM Alex Ghiti wrote: > > Hi Dmitry, > > Le 2/16/21 =C3=A0 6:25 AM, Dmitry Vyukov a =C3=A9crit : > > On Tue, Feb 16, 2021 at 12:17 PM Dmitry Vyukov wro= te: > >> > >> On Fri, Jan 29, 2021 at 9:11 AM Dmitry Vyukov wro= te: > >>>> I was fixing KASAN support for my sv48 patchset so I took a look at = your > >>>> issue: I built a kernel on top of the branch riscv/fixes using > >>>> https://github.com/google/syzkaller/blob/269d24e857a757d09a898086a2f= a6fa5d827c3e1/dashboard/config/linux/upstream-riscv64-kasan.config > >>>> and Buildroot 2020.11. I have the warnings regarding the use of > >>>> __virt_to_phys on wrong addresses (but that's normal since this func= tion > >>>> is used in virt_addr_valid) but not the segfaults you describe. > >>> > >>> Hi Alex, > >>> > >>> Let me try to rebuild buildroot image. Maybe there was something wron= g > >>> with my build, though, I did 'make clean' before doing. But at the > >>> same time it worked back in June... > >>> > >>> Re WARNINGs, they indicate kernel bugs. I am working on setting up a > >>> syzbot instance on riscv. If there a WARNING during boot then the > >>> kernel will be marked as broken. No further testing will happen. > >>> Is it a mis-use of WARN_ON? If so, could anybody please remove it or > >>> replace it with pr_err. > >> > >> > >> Hi, > >> > >> I've localized one issue with riscv/KASAN: > >> KASAN breaks VDSO and that's I think the root cause of weird faults I > >> saw earlier. The following patch fixes it. > >> Could somebody please upstream this fix? I don't know how to add/run > >> tests for this. > >> Thanks > >> > >> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/= Makefile > >> index 0cfd6da784f84..cf3a383c1799d 100644 > >> --- a/arch/riscv/kernel/vdso/Makefile > >> +++ b/arch/riscv/kernel/vdso/Makefile > >> @@ -35,6 +35,7 @@ CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_FTRACE)= -Os > >> # Disable gcov profiling for VDSO code > >> GCOV_PROFILE :=3D n > >> KCOV_INSTRUMENT :=3D n > >> +KASAN_SANITIZE :=3D n > >> > >> # Force dependency > >> $(obj)/vdso.o: $(obj)/vdso.so > > What's weird is that I don't have any issue without this patch with the > following config whereas it indeed seems required for KASAN. But when > looking at the segfaults you got earlier, the segfault address is 0xbb0 > and the cause is an instruction page fault: this address is the PLT base > address in vdso.so and an instruction page fault would mean that someone > tried to jump at this address, which is weird. At first sight, that does > not seem related to your patch above, but clearly I may be wrong. > > Tobias, did you observe the same segfaults as Dmitry ? I noticed that not all buildroot images use VDSO, it seems to be dependent on libc settings (at least I think I changed it in the past). I also booted an image completely successfully including dhcpd/sshd start, but then my executable crashed in clock_gettime. The executable was build on linux/amd64 host with "riscv64-linux-gnu-gcc -static" (10.2.1). > > Second issue I am seeing seems to be related to text segment size. > > I check out v5.11 and use this config: > > https://gist.github.com/dvyukov/6af25474d455437577a84213b0cc9178 > > This config gave my laptop a hard time ! Finally I was able to boot > correctly to userspace, but I realized I used my sv48 branch...Either I > fixed your issue along the way or I can't reproduce it, I'll give it a > try tomorrow. Where is your branch? I could also test in my setup on your branch. > > Then trying to boot it using: > > QEMU emulator version 5.2.0 (Debian 1:5.2+dfsg-3) > > $ qemu-system-riscv64 -machine virt -smp 2 -m 4G ... > > > > It shows no output from the kernel whatsoever, even though I have > > earlycon and output shows very early with other configs. > > Kernel boots fine with defconfig and other smaller configs. > > > > If I enable KASAN_OUTLINE and CC_OPTIMIZE_FOR_SIZE, then this config > > also boots fine. Both of these options significantly reduce kernel > > size. However, I can also boot the kernel without these 2 configs, if > > I disable a whole lot of subsystem configs. This makes me think that > > there is an issue related to kernel size somewhere in > > qemu/bootloader/kernel bootstrap code. > > Does it make sense to you? Can somebody reproduce what I am seeing? > > > I did not bring any answer to your question, but at least you know I'm > working on it, I'll keep you posted. > > Thanks for taking the time to setup syzkaller. > > Alex > > > Thanks > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv > >