Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp495171lqt; Mon, 18 Mar 2024 14:09:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1/rl/KoujNN9hfslI9fpIErbo+Ep1ABZkHyN9oIWFkU+MWcaeoJeSG5sCsZHNR1A2tSpUneRq8W2PbZYo0MffJOHaWTRgMWGGBBJy+Q== X-Google-Smtp-Source: AGHT+IEVvsLFwL1w8UxrBhQJaygGz00nEEYE/Sqzf1LAUCpXoYkLPZvGtugjTHxhi7wwN5T/XPFG X-Received: by 2002:a05:6512:419:b0:513:d22c:419a with SMTP id u25-20020a056512041900b00513d22c419amr395218lfk.61.1710796175443; Mon, 18 Mar 2024 14:09:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710796175; cv=pass; d=google.com; s=arc-20160816; b=sRiknS183salo1JBKdbs2oxBqVGKtaRI3cwa68WsPMjxq/LY7qf6k0lehbwsRxhalt 6MziRRtj6ttnBuEM55c0SV0V/16xlaToKB2OJJLN08JciU3dIAvy+j3OOST0U+dZeZeb zTybdoAlAlhXkpWklG4ye+1WDgXaUwep8K4qZGqRF0k7Ej/2ywEy2g9uqyNJf7RQN6Xr GuBzfJKCXtb/qlPSFk3pOBRy4veEo0cCqunObWgkabHtjOptzXIAQhIUs3iHzj3WOlBG VpmcIcf9/mHnLgxfHewRLunD09ELSbOkq7z4ddWZITGiNxcQLcS6gdjFDtzVtjOyg/NW Xm/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FOqxWMcGpNyg6Z0UKe89d8UtFLAlVDl2Ge9RAirWCRg=; fh=BU8J3dmD4V+sEr4SNlYkVgNk7xulSNuBzBEQLnbIqK8=; b=kevF+Ay7bfLgJHM71peqoFValT34RVjaLJNkHeVIw281OZ4rSBVF/ET9pN0wcq7Tor Sme3CSxLsEQhgfo86DySYOdVLeLEQxJM1rUyw5uyvi0mCnVAbDt4owP9bmss42sNf8zg qJxIQjxL17EZRevcTEtBULRf/MvFuX0iIglB3n20+esiurvpJUGq+28J5qOw0Jew73X5 eIDJz+IBCKQmrrN7wcVaIrF+sPr8+E0t0q43eQoEwZ1NqpZtPX4v8iWtTzNL7HSKLn0X eRC/h+DpZ0ISBxcNEdruyjTVSJXG1BXGsab5kbOhljT32OUq+6xuoDRASZM2ssu4HZG7 EQXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=V9e06hcS; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-106671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dc11-20020a170906c7cb00b00a449603bea5si4687435ejb.636.2024.03.18.14.09.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:09:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=V9e06hcS; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-106671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CD4121F221F2 for ; Mon, 18 Mar 2024 21:09:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BBFE58138; Mon, 18 Mar 2024 21:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="V9e06hcS" Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF530535D3 for ; Mon, 18 Mar 2024 21:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710796167; cv=none; b=fua1E46GEhR9Qu2UKi4zTbNkrVaIGZ2/ICrzTHKKiSb0HbOLlvhFa/q8jGpOEYhlMTASx3m5LXwF62Aw1HazFmzBEJsY98NtJ0sjLVTU4jK+xXKXDXKYtbaKu8S5m+FyixeLv4S0+OY7tvfKyyeAv8fyjqlO0rpLi+PdmXz9Un8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710796167; c=relaxed/simple; bh=C/Puvl79m49Cnp0XGqjFPs+46qFbmpop8duIGHpg/9A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W3RL6DPM839RDmh/TlhMERJTbhYUUChBT/360YYbt2sMjpCVhtqw6ualIjp26B2iA6i6c22N8n1nnS4sJcl3aTf+sRBUGmbjuLOjyjcrcshSf+EXxdnLd/ND/HF+YKg3/33LBJvSeOQtGl4Edv4T6/RejUNRwtyxC3k/QyCrBcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=V9e06hcS; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-78a0ab10316so72191485a.0 for ; Mon, 18 Mar 2024 14:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1710796162; x=1711400962; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=FOqxWMcGpNyg6Z0UKe89d8UtFLAlVDl2Ge9RAirWCRg=; b=V9e06hcSG9QVHvilkhymeyCrDdZKxsSj0hf+ky4aYbz224OR+jLWm6eN2bUrya8ll0 WADLkWJvURN/Y8G6dudPbGEtJYSN+qUpT12a9rXM860i/AMsCXqExtjkwV2fhS8/Mcr+ GV/E5YSSdKTfr5WnX2UW8Xz7URxih4pLRPNghOGKD0qKlxlR3QJt9LJiVeDcS+FYwVBc prmlvPgT4fAgfGSbPyJQhKmYiG6o5eD+Ssrvp6r2gw/tTdXW/OIoyNoNVDCPc2r0paJ3 KXTY7sx+nx7miJouJymhEgknc0g+6FPUIY59YryBbCOu48RsjxtOjk7INH8EQljr0WZ1 i6oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710796162; x=1711400962; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FOqxWMcGpNyg6Z0UKe89d8UtFLAlVDl2Ge9RAirWCRg=; b=Agwb9t96G79UkY9lIGT3hRhGrUfTgvItTq7hcRWv8+MTJ9YvggNNkm2rAMUwdYxqsU WEcCpQr7yvKPgOFmBE7XLYNEzmNl7Ja8oeFa93M3RZxZ5NzrOap1atKKftgW1DgbPz1a ONwPiPMy58lRntHh7T/Wz9J+YDQI/W7OfJjYT6odj1+lwWLp2gDI4RpqRV5BFLuT0Pha AVVUsepnZdOFUmDeWn2ARrM45n0wPdqcQNL6WTp+h/DpetTBXUHRZNU7duifVYSlsXs/ YBQTnLGiwcQwaVgsDnNOJ22CP4hbEA+9/+s0JMNozHDzOwN/BGTRLnjjz8DFTHiYCTAH CPrw== X-Forwarded-Encrypted: i=1; AJvYcCVfCjoh9oio81y5/fPdCQWEjHV/fMOQvV8HX2QgRclJWJ5bXHF7kJHBsdoxM1gJzAwBq6Cx9hUpF3+cU8CWIXvnqGZa/Cp5FkhDw2K5 X-Gm-Message-State: AOJu0Ywegcz1Z5xyvBTxjAh4UcVQYq2MdazL9ZI55IyH+ea9FreszJkd w0Pzi6zsyJdhBJCpD69ZOnW19RSRfR6RPPrtW7gJdHYqrtOd4OjGUHERgCloH44= X-Received: by 2002:a05:620a:1722:b0:78a:3c3:a629 with SMTP id az34-20020a05620a172200b0078a03c3a629mr1486052qkb.23.1710796162650; Mon, 18 Mar 2024 14:09:22 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id f18-20020ae9ea12000000b007884dd207b8sm4816696qkg.55.2024.03.18.14.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:09:21 -0700 (PDT) Date: Mon, 18 Mar 2024 17:09:17 -0400 From: Johannes Weiner To: Yosry Ahmed Cc: Nhat Pham , syzbot , akpm@linux-foundation.org, chengming.zhou@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, Barry Song Subject: Re: [syzbot] [mm?] kernel BUG in sg_init_one Message-ID: <20240318210917.GA4210@cmpxchg.org> References: <000000000000bbb3d80613f243a6@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Mar 18, 2024 at 01:17:19PM -0700, Yosry Ahmed wrote: > On Mon, Mar 18, 2024 at 11:00 AM Nhat Pham wrote: > > > > On Mon, Mar 18, 2024 at 9:58 AM syzbot > > wrote: > > > > > > Hello, > > > > > > syzbot found the following issue on: > > > > > > HEAD commit: e5eb28f6d1af Merge tag 'mm-nonmm-stable-2024-03-14-09-36' .. > > > git tree: upstream > > > console output: https://syzkaller.appspot.com/x/log.txt?x=13043abe180000 > > > kernel config: https://syzkaller.appspot.com/x/.config?x=19bb57c23dffc38e > > > dashboard link: https://syzkaller.appspot.com/bug?extid=adbc983a1588b7805de3 > > > compiler: arm-linux-gnueabi-gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40 > > > userspace arch: arm > > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1706d231180000 > > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13ba7959180000 > > > > > > Downloadable assets: > > > disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/8ead8862021c/non_bootable_disk-e5eb28f6.raw.xz > > > vmlinux: https://storage.googleapis.com/syzbot-assets/0a7371c63ff2/vmlinux-e5eb28f6.xz > > > kernel image: https://storage.googleapis.com/syzbot-assets/7539441b4add/zImage-e5eb28f6.xz > > > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > > Reported-by: syzbot+adbc983a1588b7805de3@syzkaller.appspotmail.com > > > > > > ------------[ cut here ]------------ > > > kernel BUG at include/linux/scatterlist.h:187! > > > > Looks like the provided buffer is invalid: > > > > #ifdef CONFIG_DEBUG_SG > > BUG_ON(!virt_addr_valid(buf)); > > #endif > > > > which is "src" from: > > > > sg_init_one(&input, src, entry->length); > > > > Looking at the surrounding code and recent history, there's this > > commit that stands out: > > > > mm/zswap: remove the memcpy if acomp is not sleepable > > (sha: 270700dd06ca41a4779c19eb46608f076bb7d40e) > > > > which has the effect of, IIUC, using the zpool mapped memory directly > > as src, instead of acomp_ctx->buffer (which was previously the case, > > as zsmalloc was not sleepable). > > > > This might not necessarily be a bug with that commit itself, but might > > have revealed another bug elsewhere. > > > > Anyway, cc-ing the author, Barry Song, to fact check me :) Will take a > > closer look later. > > I am not a highmem expert, but the reproducer has CONFIG_HIGHMEM=y, > and it seems like zs_map_object() may return a highmem address if the > compressed object is entirely in a single page to avoid copying to a > buffer: > > if (off + class->size <= PAGE_SIZE) { > /* this object is contained entirely within a page */ > area->vm_addr = kmap_atomic(page); > ret = area->vm_addr + off; > goto out; > } > > The virt_addr_valid() check seems to indicate that we expect a direct > map address in sg_init_one(), right? If the page is highmem, kmap_atomic() establishes a temporary mapping to it in the direct map, such that we have a legit kernel pointer to the memory. Otherwise the memcpy() in zswap also wouldn't work... Am I missing something?