Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3573995imd; Mon, 29 Oct 2018 09:06:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5dH2+o2byhnuHfHYDcABZBBUsHbiFxmoUdCuo5k6WLvLOakQTLg1SPKsV9Lxk4DFFlzt/8K X-Received: by 2002:a62:5bc4:: with SMTP id p187-v6mr13139218pfb.94.1540829176200; Mon, 29 Oct 2018 09:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540829176; cv=none; d=google.com; s=arc-20160816; b=r6Py2CdraBqtockMyUEqwNi3uEmFdZF+79orCR9NJ4QcswjNisA87BaKskEM531d9O V5SiV/d6xrbHf5zhIgUeOlfSfs20LPDDBj1m5KW6e7VfW/9mqcSBKEgCGOAG/7b9mqN3 fhJLgFyHh8riQqPvqajHkySuwPTRDfEjkbKrWTlDFeHtCZGWzJf80O2eZserllUbg3YK aKR/T4uq/APN3ACVavk4FjDee+/wRex6t0teb5zWkDrUTHdKj90wsNSkCIfKkfoQk6iC oU8izEzUepHJ9A0UvAdw9EYDpWUHeBZZEm6TPXdSRrgGK+YXMwJuka9wntL2W2q7eCAs mnVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=22zDYaBQAQTYUANz4bSW6gERVTj33l72WDZyoYh36PU=; b=nbzR+oiDRpiajSGYY2RO8pJc4DeCLkbEWqgFeQB1Q5kiwHV55P8DzAmK4kCEUpLvA1 eJY8COXqs5anGF3qX/QrZCQMuTHjCzVfVh+KhqyGcrvAp/lqK4gjE9DfIH7MOapbSMW1 9bDEdSc+ApCE/fWspqgGNNdDrNzgvXJipr2t/wI9aMaPxauoYJI+vIEC4OiTX11z+vex QNuXin+hwKmOdsaX1IB+QUtLgvMf6wmAuYC2Vy1MKPmySnoq+HnGXjQSJ0xfL90x+neY zwBtFBzh0t2a/jx1S+jqxdVuSsJ506ZPljcsJ0aQ8PZ5NgTvTXlrx8t/qUD/oMcHWaA5 j8Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BOcaQ2Dh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a31-v6si19898086pgl.280.2018.10.29.09.05.51; Mon, 29 Oct 2018 09:06:16 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=BOcaQ2Dh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbeJ3AwY (ORCPT + 99 others); Mon, 29 Oct 2018 20:52:24 -0400 Received: from mail-qt1-f171.google.com ([209.85.160.171]:45114 "EHLO mail-qt1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbeJ3AwY (ORCPT ); Mon, 29 Oct 2018 20:52:24 -0400 Received: by mail-qt1-f171.google.com with SMTP id l9-v6so9791550qtj.12 for ; Mon, 29 Oct 2018 09:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=22zDYaBQAQTYUANz4bSW6gERVTj33l72WDZyoYh36PU=; b=BOcaQ2DhF6mDhIhAzD7HLM5Nnm2FFEHtei2KuWTX1s0CmpTXVadi3WLa730GTbovzS mwtM6uDqHrVi5ar8lL3im6AQxk94HR2f1ZtiQ+zGImrPPEWVmJ1ekX6XNrofA8FjdAvV aQItXO7XoUaojOzrMSlaw5WRzHgS6aUU7gLPA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=22zDYaBQAQTYUANz4bSW6gERVTj33l72WDZyoYh36PU=; b=ib8GOQ5/u7DGCjY4UOqAhYUtichtAh6b59rGSZwIYDaSUnO1Zfwb8Y7Kde+o3F88+O ovzcGw6dWQK9H2no/ZvXOJdz+ZsLp7ReRvJwlhj/p2w7BMWbNgYx8vf9/hSg6cXhKBtV CCPS8z6XKnW34BGNkVPqBQ1ZQyUuDWSsb2kOzjEiGxS1u0NThZWpWF9dAGDgF7pOZJA2 P0+gBsyo9K0S7h3ovLx6OYX8W/bQcMXq0jeSTwPAbC3OXH5FfXd6NzGX8Rry2Nyzow5D nqCgnnuidVn1DTVMdH5u3Cq4P8kSLJ0fOsOF//D3ruMc5Pc838Y9DfF/Gi8ig0YPNrOd xA5Q== X-Gm-Message-State: AGRZ1gKu5FfWv5Qc7WHkAw35QD5RRejzEcADRnAnf5pIORowAgClrBA+ aFNInWfENrIvErQDz9P1h1A0Tu36CsE= X-Received: by 2002:a05:6214:18e:: with SMTP id q14mr1247482qvr.173.1540828990622; Mon, 29 Oct 2018 09:03:10 -0700 (PDT) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id h187sm12601374qke.46.2018.10.29.09.03.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Oct 2018 09:03:09 -0700 (PDT) Date: Mon, 29 Oct 2018 12:03:08 -0400 (EDT) From: Nicolas Pitre To: Anatoly Trosinenko cc: linux-kernel@vger.kernel.org Subject: Re: Cramfs: "unable to handle kernel paging request" when reading a file from a fuzzed FS image In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 29 Oct 2018, Anatoly Trosinenko wrote: > > How do I populate /vtmp? Mine is empty at this point. I imagine I > > should put the cramfs image somewhere on the host, but I'm not that > > familiar withkvm. > > Oops, forgot to say, it is the /tmp/kvm-xfstests-$USER directory on > the host (it will be created when you first launch kvm-xfstests and it > is "live", i.e. like NFS, not like "pack to ext4 image then boot and > mount"). OK, I reproduced it. The fix is as follows: diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index f408994fc6..6e000392e4 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset, continue; blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT; blk_offset += offset; - if (blk_offset + len > BUFFER_SIZE) + if (blk_offset > BUFFER_SIZE || + blk_offset + len > BUFFER_SIZE) continue; return read_buffers[i] + blk_offset; } User space will get a bunch of zeroes rather than an explicit error in this case. There is just so many ways to corrupt a cramfs image without detecting it afterwards that I don't think it is worth doing more than making sure the system won't be compromized. > > Hmmm... It doesn't show up on my test system. > > Mounted it on my host Ubuntu 18.10 amd64, executed `cat /mnt/xyz` and > it was "Killed". Maybe it is something freshly added or > arch-dependent... It actually depends on whether there is something mapped immediately next to the cramfs cache buffer. In any case, this is a nice catch. Thank you for reporting it. Nicolas