Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2364373rdb; Fri, 8 Dec 2023 06:12:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeMpxzsPmwjV7GQGPtpCsXulODju9u79WMv6+WQpgd+lMrKy8m7RDJ2N1PeCHZ18JkWPZ7 X-Received: by 2002:a05:6a21:3398:b0:18f:d2a9:da50 with SMTP id yy24-20020a056a21339800b0018fd2a9da50mr72956pzb.30.1702044750616; Fri, 08 Dec 2023 06:12:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702044750; cv=none; d=google.com; s=arc-20160816; b=ZllfLK3pWj172zLbSZ3H3JoMcahK+GOikcApQbdiUXI9CtAL13avrMl1oNDmHV9nvw ey2rQnivr3iGCytaZ7kY870odjuMtR6N4C9oaZGy3PNTbyyYSLMR2qtZLpRJMA2yuFbx E4hul2B68mc0JhbVzHWTkf1dR5PhKT8fV+s2k71tkAQuh6DoSxVw4q623prnsza3urNO EdqHrEtIAqEFly6YpNqIQm0BPzsbqBAvalykYVnnUqRnyYcakH/ONH6ojIZDlwtG/7nO b3EoPY9TtbTPetj8wqDjKgRl79NPSUvGYL/pdU8Wn4F8tYsVTy0VrNUeUJ4losfIEg2k +Wrw== 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=/ABC8R/IhSJq1v/g+J7leg1/ZK2tJ16+5uzlBgeMWDk=; fh=cGQRan6hLBS3BDuXzttUEU2Jc4w348kD8PmEuCSNo4s=; b=uOQe6cnj2p8WY44+TSi7ieWYkFPuvA7AQT6MD6fkU92FSyUwS0fRzAS2Bk4IxnLCmv UYgJ5bKiRev5Qgo8zhe0kxXlZWfj50/QD9drT+XFr9gDu5100W5jG8ciBBaiYrIVxnbk lxkaZ0JXHGnOwWMCRnOqVnwbXfkpehZSDYaKNJm+Y982BYcTmCOAzR9MgkQdjB5QtOjW 8BKsYxYpj7ZseIEyJPbgRH+e/h6ylnIVYmykRdIuM1wI3dQe2xSXMG+s/5dxTSOi7ZWZ q+tRyAH2DZYzlZsushwyypooNBl/D0MhQqIeeeB21rubspkTOCdm1cB2UNAKtIctYhBu COYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EJaxmLR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k4-20020a6568c4000000b005c69246e16fsi1550075pgt.357.2023.12.08.06.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 06:12:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EJaxmLR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 583F480681DC; Fri, 8 Dec 2023 06:12:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573900AbjLHOMN (ORCPT + 99 others); Fri, 8 Dec 2023 09:12:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573881AbjLHOML (ORCPT ); Fri, 8 Dec 2023 09:12:11 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CAAC10F1 for ; Fri, 8 Dec 2023 06:12:18 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-54c77d011acso7711a12.1 for ; Fri, 08 Dec 2023 06:12:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702044736; x=1702649536; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/ABC8R/IhSJq1v/g+J7leg1/ZK2tJ16+5uzlBgeMWDk=; b=EJaxmLR5V6yud+2PaLx+l4h09Qf9gZSNcFIIZrr938Cs3ZgZ6SpGgpTm/1TiGWSZcw dLccmN44eYDEQ6wPQ85ObxmpPryxn/a4AJPFpZn2C/GDyvGSaVbDFOJNfEXfC02OpJ/C jdWEa5x0OuBsKGMMRDLgLMo//hxxFycdREL6eJeRFlPigGv6lDgAL/XKKjeD70azxJSN tVQHdthmZdvMVDCW+I1RMJ2kRRgo7HtTfmdwQ8uHELiwYy/dJOiDNcOBWbmbjuijY+w2 AKpyPg/wNR3HJARpbQ1akl75OhQa2cyVzNdoiot6vtLJ7h3T8yMF8D9K9hVyCg6VYWDq MUpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702044736; x=1702649536; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ABC8R/IhSJq1v/g+J7leg1/ZK2tJ16+5uzlBgeMWDk=; b=YmMhGB73Bhr01zEl7jeeo0ODp/kwvZuFjZw4JiEbqUOsQjzVhQN0JqFaIE6iWVJxUv +pF+rJ0Tnqf8D7H8UBkx8noElXJNI7/NDjyglYWSAMvGsdWMO8veWOGuVmG2g1UATysy hN7J1cpouUiv4x43wx8Fy0ChyrsQgJw3LR8dktB/41e3IrT5c+BJzY7P3WLN+/sai8zS Vv0COeBbob1lqTDK9CQT67XCx2wp39BPLIbh535KZH8HzbxYq/vOj8qt7WPhHB0hjxRU KepD8gGZ0kUQCh8SQ39HtV1K+QJPODclHziBPsffeLJ/RwDoYBEdTFgrQpgB1suEHRr+ 0v2A== X-Gm-Message-State: AOJu0YzcKOX9N/nlDe5jt4tY0ziu5S5iK3BpQyWu+K+qdNI41GgmGlRC iF+7xnDoyqjRP5om6/tjv7IiY1ExAejl2AiDfFMAow== X-Received: by 2002:a50:f618:0:b0:54c:79ed:a018 with SMTP id c24-20020a50f618000000b0054c79eda018mr53716edn.2.1702044736317; Fri, 08 Dec 2023 06:12:16 -0800 (PST) MIME-Version: 1.0 References: <000000000000c84343060a850bd0@google.com> <87jzqb1133.ffs@tglx> In-Reply-To: <87jzqb1133.ffs@tglx> From: Jann Horn Date: Fri, 8 Dec 2023 15:11:38 +0100 Message-ID: Subject: Re: [syzbot] [mm?] BUG: unable to handle kernel paging request in copy_from_kernel_nofault To: Thomas Gleixner , Alexei Starovoitov , Daniel Borkmann , John Fastabend , bpf Cc: syzbot , akpm@linux-foundation.org, bp@alien8.de, bp@suse.de, dave.hansen@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, luto@kernel.org, mingo@redhat.com, netdev@vger.kernel.org, peterz@infradead.org, syzkaller-bugs@googlegroups.com, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 06:12:27 -0800 (PST) On Tue, Nov 21, 2023 at 6:13=E2=80=AFPM Thomas Gleixner wrote: > On Sun, Nov 19 2023 at 09:53, syzbot wrote: > > HEAD commit: 1fda5bb66ad8 bpf: Do not allocate percpu memory at init= st.. > > git tree: bpf > > console+strace: https://syzkaller.appspot.com/x/log.txt?x=3D12d99420e80= 000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=3D2ae0ccd6bfd= e5eb0 > > dashboard link: https://syzkaller.appspot.com/bug?extid=3D72aa0161922eb= a61b50e > > compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for= Debian) 2.40 > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D16dff22f6= 80000 > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D1027dc70e80= 000 > > > > Downloadable assets: > > disk image: https://storage.googleapis.com/syzbot-assets/3e24d257ce8d/d= isk-1fda5bb6.raw.xz > > vmlinux: https://storage.googleapis.com/syzbot-assets/eaa9caffb0e4/vmli= nux-1fda5bb6.xz > > kernel image: https://storage.googleapis.com/syzbot-assets/16182bbed726= /bzImage-1fda5bb6.xz > > > > The issue was bisected to: > > > > commit ca247283781d754216395a41c5e8be8ec79a5f1c > > Author: Andy Lutomirski > > Date: Wed Feb 10 02:33:45 2021 +0000 > > > > x86/fault: Don't run fixups for SMAP violations > > Reverting that makes the Ooops go away, but wrongly so. > > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=3D103d92db= 680000 > > final oops: https://syzkaller.appspot.com/x/report.txt?x=3D123d92db= 680000 > > console output: https://syzkaller.appspot.com/x/log.txt?x=3D143d92db680= 000 > > > > IMPORTANT: if you fix the issue, please add the following tag to the co= mmit: > > Reported-by: syzbot+72aa0161922eba61b50e@syzkaller.appspotmail.com > > Fixes: ca247283781d ("x86/fault: Don't run fixups for SMAP violations") > > > > BUG: unable to handle page fault for address: ffffffffff600000 > > This is VSYSCALL_ADDR. > > So the real question is why the BPF program tries to copy from the > VSYSCALL page, which is not mapped. The linked syz repro is: r0 =3D bpf$PROG_LOAD(0x5, &(0x7f00000000c0)=3D{0x11, 0xb, &(0x7f0000000180)=3D@framed=3D{{}, [@printk=3D{@integer, {}, {}, {}, {}, {0x7, 0x0, 0xb, 0x3, 0x0, 0x0, 0xff600000}, {0x85, 0x0, 0x0, 0x71}}]}, &(0x7f0000000200)=3D'GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, '\x00', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0x90) bpf$BPF_RAW_TRACEPOINT_OPEN(0x11, &(0x7f0000000540)=3D{&(0x7f0000000000)=3D'kfree\x00', r0}, 0x10) So syzkaller generated a BPF tracing program. 0x85 is BPF_JMP | BPF_CALL, which is used to invoke BPF helpers; 0x71 is 113, which is the number of the probe_read_kernel helper, which basically takes arbitrary values as input and casts them to kernel pointers, and then probe-reads them. And before that is some kinda ALU op with 0xff600000 as immediate. So it looks like the answer to that question is "the BPF program tries to copy from the VSYSCALL page because syzkaller decided to write BPF code that does specifically that, and the BPF helper let it do that". copy_from_kernel_nofault() does check copy_from_kernel_nofault_allowed() to make sure the pointer really is a kernel pointer, and the X86 version of that rejects anything in the userspace part of the address space. But it does not know about the vsyscall area.