From nobody Wed Apr 1 10:02:08 2026 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (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 8506F30E0D5 for ; Mon, 30 Mar 2026 23:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774911829; cv=none; b=uTesWwbpMQ3kYveyJtrn1LtGlM+t9rWdU+bcRv/M01z1/qGylKyKIiySALHbVcNAZsWtWxW+1R4aosmCAcG4hsVDqOSCjg4o8BDZZ/n1gqPFXvaAqTFxXESrm8gXjsAMG+n1M2PMQ/eyQi+pNxrUIXnFkLksXJdsmr1/UQ6BFhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774911829; c=relaxed/simple; bh=58Y3MgzcWVqssUvgjLqAF5hQOHL/SA5OJelNCB0y6IQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lYhqF2ASqJka1H9Dz3ytYHRAui1tqXb2Y/KGzq/KCO2UgPd9vVvDWPiNhcrdHifkeGlqjr6t9nhOqlxBxuy1BGsiiRgpnwpQb4WIdOZ8txSY2J7ObcPfi+2yxg3y5VkBfIF515YKPDfl0hh5X5eZSx53JaY89lhyeb20NoNUT1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=74.125.224.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-650158138d9so3498089d50.3 for ; Mon, 30 Mar 2026 16:03:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774911827; x=1775516627; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qAf2oXhrArWRQHuBF1UUaD/CmTI4JKEJyktvpmLV08o=; b=elesCffW7fY8xH8s+eO2Adc0uNRwyAYBGLYMkSDb/ZQfUZZCClQrQw7ifdzm/p0E9H aHg33JX/O7DZKrdapbwLYmdJZs9zTR3MZXxipHylFYdRW88veCBDQD+g58ZVk31NaoqX mC2yMlPI+zOGIKDKnhVLqG8j3bXsofyjQsjgYfZMHGJF+G+O35neJyc4oGm9omTvkWJ7 vvSVSKat+bMPeAdMLzjpLEcbkG7uIhd+ApmxHhZ7k7qnlg2eidCs8yAMSBxgxZuMErBj bhP4f/yJD75QkPl2AfUXVBSd3h+KiRhSLbnyWir7OmcmdEV/a8YhLaA8YMCW7JVsaMir 7olw== X-Forwarded-Encrypted: i=1; AJvYcCUs5GnFSEnNFpKPHJvQ6VZJWftJ2xAjdvV5qPFI1b5r5y8PAoeMooIiAJFXWWu463SEJV2OCriETD2MVPo=@vger.kernel.org X-Gm-Message-State: AOJu0YyJJKFGlExFRZ47gyfiC8lbQ/pmtmUVe5foezWrqRF4kJsx84Af uXduN9udE2U8gkkMBHWxcubNTY+9iQjuYwizS1DWQQMWak0sekmvxbe8 X-Gm-Gg: ATEYQzwxnKW8vgN9i/fZIxYJR4iGun7mF/d2eut9+MqZGpT4mziucSPt5jXQ2+awc3V qleDIMomd+dDUJoxqMGn1uDpXmzWWdcMNJ1eoJZ3+/OagtCUKnNaT5IYW7TGmLMHJCnZNM13qcm gaNVxmOGpvywEUtFaMCG4eCwNn8rV6OKgAHmLPrHHHzZab/T73NySussSrwIQRKLTD3sJ5i6mMG /k4YnGZONswXYX5chSDkmGwm9SyWuuW0SEvL5/z3Ku9IxayahABh3BmoQdXxkiMS7MOWnD/x8u3 uoLIPTMVFvTN0fbdZNsHkhwd19XHPHK5CHClOLF7qWeNI47ZbjlvDoQUxpDqnGcZadjzkjX88JJ 1XGCB2ySj7FuQpMH7d9pLKluL2aSxDaNqcYR9cDOxIGxkl+WXLvS57gWNPdjB/Oi/tZyILhze3o dzIQfHXkjTqW2kcuID/293 X-Received: by 2002:a05:690c:74ca:b0:79a:4b22:5e35 with SMTP id 00721157ae682-79bde22821amr141067577b3.58.1774911827600; Mon, 30 Mar 2026 16:03:47 -0700 (PDT) Received: from tofu.. ([128.210.0.165]) by smtp.googlemail.com with ESMTPSA id 00721157ae682-79cba47147bsm42052177b3.41.2026.03.30.16.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 16:03:47 -0700 (PDT) From: Sungwoo Kim To: Jens Axboe , Keith Busch Cc: Sungwoo Kim , Chao Shi , Weidong Zhu , Dave Tian , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] block: Fix general protection fault in bio_integrity_map_user() Date: Mon, 30 Mar 2026 19:02:56 -0400 Message-ID: <20260330230256.4160820-2-iam@sung-woo.kim> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pin_user_pages_fast() can partially succeed and return the number of pages that were actually pinned. However, the bio_integrity_map_user() does not handle this partial pinning. This leads to a general protection fault since bvec_from_pages() dereferences an unpinned page address, which is 0. To fix this, add a check to verify that all requested memory is pinned. KASAN splat: Oops: general protection fault, probably for non-canonical address 0xdffffc= 0000000001: 0000 [#1] PREEMPT SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] RIP: 0010:_compound_head home/wukong/fuzznvme/linux/./include/linux/page-fl= ags.h:240 [inline] RIP: 0010:bvec_from_pages home/wukong/fuzznvme/linux/block/bio-integrity.c:= 290 [inline] Fixes: 492c5d455969 ("block: bio-integrity: directly map user buffers") Acked-by: Chao Shi Acked-by: Weidong Zhu Acked-by: Dave Tian Signed-off-by: Sungwoo Kim --- V1: https://lore.kernel.org/linux-block/20260308001358.1675543-2-iam@sung-w= oo.kim/T/#u V1->V2: - v1 incorrectly assumed pin_user_pages_fast() returns bytes. Fixed. block/bio-integrity.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 20f5d301d32d..992ce39e8ab9 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -338,6 +338,15 @@ int bio_integrity_map_user(struct bio *bio, struct iov= _iter *iter) extraction_flags, &offset); if (unlikely(ret < 0)) goto free_bvec; + if (unlikely(ret !=3D nr_vecs)) { + for (int i =3D 0; i < ret; i++) + unpin_user_page(pages[i]); + + if (pages !=3D stack_pages) + kvfree(pages); + ret =3D -EFAULT; + goto free_bvec; + } =20 nr_bvecs =3D bvec_from_pages(bvec, pages, nr_vecs, bytes, offset, &is_p2p); --=20 2.47.3