From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AF22150985 for ; Wed, 27 Mar 2024 18:46:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711565218; cv=none; b=QS6mv0YWlN8ZJrv9VXAz5Q6OaeAd1mP4PsrTycqCA7iPu+s+9D7fyC5tLqrL8AJorIHb7iiu/wuNzOY994Mk129OB4bOpXvxG3Y78ZKrANy1TqBkqtOdAgE0biA2xoQZyFVSymHJFzdKlVfH9b5RXnKnwnw3BTLvVfMOKLdZyvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711565218; c=relaxed/simple; bh=wOYDqXQBwndxLNpGzVpA/alUz261GjYTc0wTNh/rnrg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qFqpaKNY0U8Zce0QRGYiF6MsEQpyjioSeNUNczmU5VAJEgzNN9r7RxIl9xefF2eW0oOkpFNmeJwY6dnArkcbB3b3ZwosrsBkyB9hQTZr0EnNHqV97WYYFGX+u1Kz6p6k9FJy22tH1fb9nyGKdlvAqpuZWDxzzz1udgBEQKWmjJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Vz588ZcO; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Vz588ZcO" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1711565213; 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=Yx1UbkHwdHZLLbNuRcSx7DJyIY0QwP+4nFSmm21yDtQ=; b=Vz588ZcOD6FrUivNA4zc/O2aYjnlG2CqGtHPSocyox7umNsKF3yrwoGxP1Xubf7bKxC3qD PdLQbAW86bvNr3QJAtjD+9zFfsK5J7mP1o1wTd3mzIRv2X7ddNDqhmGbirF6+MM4bUQ+Ib vU6poku+UMDG74k7C13EYaeERKDSLeA= Date: Wed, 27 Mar 2024 11:46:42 -0700 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [syzbot] [bpf?] [net?] KMSAN: uninit-value in dev_map_lookup_elem Content-Language: en-US To: Yonghong Song , Alexei Starovoitov , syzkaller-bugs Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , syzbot , bpf , "David S. Miller" , Eddy Z , Hao Luo , Jesper Dangaard Brouer , John Fastabend , Jiri Olsa , KP Singh , Jakub Kicinski , LKML , Network Development , Stanislav Fomichev , Song Liu References: <0000000000006f876b061478e878@google.com> <5063d525-d9df-4aaf-991d-bcb9f495c041@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <5063d525-d9df-4aaf-991d-bcb9f495c041@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 3/26/24 9:47 PM, Yonghong Song wrote: > > On 3/26/24 6:07 PM, Alexei Starovoitov wrote: >> On Tue, Mar 26, 2024 at 5:54 PM Martin KaFai Lau wrote: >>> On 3/25/24 2:36 AM, syzbot wrote: >>>> Hello, >>>> >>>> syzbot found the following issue on: >>>> >>>> HEAD commit:    5e74df2f8f15 Merge tag 'x86-urgent-2024-03-24' of git://gi.. >>>> git tree:       upstream >>>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=148872a5180000 >>>> kernel config:  https://syzkaller.appspot.com/x/.config?x=e6bd769cb793b98a >>>> dashboard link: https://syzkaller.appspot.com/bug?extid=1a3cf6f08d68868f9db3 >>>> compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for >>>> Debian) 2.40 >>>> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15921a6e180000 >>>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12e081f1180000 >>>> >>>> Downloadable assets: >>>> disk image: >>>> https://storage.googleapis.com/syzbot-assets/1a82880723a7/disk-5e74df2f.raw.xz >>>> vmlinux: >>>> https://storage.googleapis.com/syzbot-assets/fd3046ac43b9/vmlinux-5e74df2f.xz >>>> kernel image: >>>> https://storage.googleapis.com/syzbot-assets/2097be59cbc1/bzImage-5e74df2f.xz >>>> >>>> IMPORTANT: if you fix the issue, please add the following tag to the commit: >>>> Reported-by: syzbot+1a3cf6f08d68868f9db3@syzkaller.appspotmail.com >>>> >>>> ===================================================== >>>> BUG: KMSAN: uninit-value in __dev_map_lookup_elem kernel/bpf/devmap.c:441 >>>> [inline] >>>> BUG: KMSAN: uninit-value in dev_map_lookup_elem+0xf3/0x170 >>>> kernel/bpf/devmap.c:796 >>>>    __dev_map_lookup_elem kernel/bpf/devmap.c:441 [inline] >>>>    dev_map_lookup_elem+0xf3/0x170 kernel/bpf/devmap.c:796 >>>>    ____bpf_map_lookup_elem kernel/bpf/helpers.c:42 [inline] >>>>    bpf_map_lookup_elem+0x5c/0x80 kernel/bpf/helpers.c:38 >>>>    ___bpf_prog_run+0x13fe/0xe0f0 kernel/bpf/core.c:1997 >>>>    __bpf_prog_run256+0xb5/0xe0 kernel/bpf/core.c:2237 >>> It should be in the interpreter mode. >>> >>> The C reproducer is trying to run the following bpf prog: >>> >>>      0: (18) r0 = 0x0 >>>      2: (18) r1 = map[id:49] >>>      4: (b7) r8 = 16777216 >>>      5: (7b) *(u64 *)(r10 -8) = r8 >>>      6: (bf) r2 = r10 >>>      7: (07) r2 += -229 >>>              ^^^^^^^^^^ >>> >>>      8: (b7) r3 = 8 >>>      9: (b7) r4 = 0 >>>     10: (85) call dev_map_lookup_elem#1543472 >>>     11: (95) exit >>> >>> I think this KMSAN report (and a few others related to lookup/delete_elem) >>> should only happen in the interpreter mode. >>> >>> Does it worth to suppress it by always initializing the stack in the interpreter >>> mode considering the interpreter is not very speed sensitive ? >> Maybe we can mark it as initialized from kmsan pov ? >> There are kasan_poison/unpoison helpers that may fit ? > > Maybe use kmsan_unpoison_memory()? Good idea. It should do. My qemu cannot boot with CONFIG_KMSAN somehow. I will ask syzbot to test. #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/martin.lau/bpf-next.git interpreter.kmsan