{"id":2229581,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229581/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260428131756.922303-10-dhowells@redhat.com/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.1/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260428131756.922303-10-dhowells@redhat.com>","date":"2026-04-28T13:17:39","name":"[v5,09/24] netfs: Fix overrun check in netfs_extract_user_iter()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8c155336f3086e410f0ddeea14ba23fd1c3976fe","submitter":{"id":59,"url":"http://patchwork.ozlabs.org/api/1.1/people/59/?format=json","name":"David Howells","email":"dhowells@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260428131756.922303-10-dhowells@redhat.com/mbox/","series":[{"id":501852,"url":"http://patchwork.ozlabs.org/api/1.1/series/501852/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=501852","date":"2026-04-28T13:17:35","name":"netfs: Miscellaneous fixes","version":5,"mbox":"http://patchwork.ozlabs.org/series/501852/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229581/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229581/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-11203-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=PoK3+Ude;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-11203-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.b=\"PoK3+Ude\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=170.10.133.124","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=redhat.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=redhat.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4hdw2KZvz1xrS\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 23:50:28 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 14B2A3173D72\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 13:28:09 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id B998E47DFA4;\n\tTue, 28 Apr 2026 13:19:33 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id E527147DD7C\n\tfor <linux-cifs@vger.kernel.org>; Tue, 28 Apr 2026 13:19:30 +0000 (UTC)","from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-4t6aizAbP86H_MufK2aZGw-1; Tue,\n 28 Apr 2026 09:19:24 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 0BC10186057E;\n\tTue, 28 Apr 2026 13:18:47 +0000 (UTC)","from warthog.procyon.org.com (unknown [10.44.32.126])\n\tby mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 5653019560AB;\n\tTue, 28 Apr 2026 13:18:44 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777382373; cv=none;\n b=LYMhxbN7iW7fH0PzQuHRTMNeyzqwA95DrQxlKtOx7IjDZvBxEDPOy8Ojox+cMsaQouRjGfxp9ovdVjjSlSgyUzDQoRzzESz5n2uC4L76M5roCZ7WDfTp59Vjx4Fi/OQhwrNiTMhaymrouKqx3NNVwJ/4VXHjxLFpAX8xWW4Xe7U=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777382373; c=relaxed/simple;\n\tbh=6aS16OhU7wJB8E9ZvNzMBoTTc64B5xcaExT2qrf2F8c=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=IIYNPbnbPP03gJKi4GsWugE68ihKgwJKvuZOaPhOLSe1rBAXm7rIBP1jqTMAeh5kCUUVADKBHJDx/dVa61Syxyy74GZtvhEeRBpGcJz1SgwLjq8Jrxwwy0M+yIAvl0KVoNBhDo92p7A1RxTM10xdkMK25oBsfuYpF1A4DjzF36A=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=redhat.com;\n spf=pass smtp.mailfrom=redhat.com;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.b=PoK3+Ude; arc=none smtp.client-ip=170.10.133.124","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1777382369;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=bHSQahnA7js1P4paGsZUSZ9WNRs6QCvVJJSxiV11wQI=;\n\tb=PoK3+Udej8Hpqibeltoe9U6qxEQ2eo/0TpB8AR01gIsB5+A7kVEcVMzXV65N7k8ZGCkmzI\n\tp29ScDih9LqR3MXEi6Zj5rRSZ/pV/4jjQrVqOO2VTzxKrPVBRXNcPgdiISiZkZZi47t5KK\n\tmA06ev1UFZuTwoc82fd7MwjOpQ6NmJI=","X-MC-Unique":"4t6aizAbP86H_MufK2aZGw-1","X-Mimecast-MFC-AGG-ID":"4t6aizAbP86H_MufK2aZGw_1777382362","From":"David Howells <dhowells@redhat.com>","To":"Christian Brauner <christian@brauner.io>","Cc":"David Howells <dhowells@redhat.com>,\n\tPaulo Alcantara <pc@manguebit.org>,\n\tnetfs@lists.linux.dev,\n\tlinux-afs@lists.infradead.org,\n\tlinux-cifs@vger.kernel.org,\n\tceph-devel@vger.kernel.org,\n\tlinux-fsdevel@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org","Subject":"[PATCH v5 09/24] netfs: Fix overrun check in\n netfs_extract_user_iter()","Date":"Tue, 28 Apr 2026 14:17:39 +0100","Message-ID":"<20260428131756.922303-10-dhowells@redhat.com>","In-Reply-To":"<20260428131756.922303-1-dhowells@redhat.com>","References":"<20260428131756.922303-1-dhowells@redhat.com>","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12"},"content":"Fix netfs_extract_user_iter() so that if iov_iter_extract_pages() overfills\npages[], then those pages don't get included in the iterator constructed at\nthe end of the function.  If there was an overfill, memory corruption has\nalready happened.\n\nFixes: 85dd2c8ff368 (\"netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator\")\nCloses: https://sashiko.dev/#/patchset/20260427154639.180684-1-dhowells%40redhat.com\nSigned-off-by: David Howells <dhowells@redhat.com>\ncc: Paulo Alcantara <pc@manguebit.org>\ncc: netfs@lists.linux.dev\ncc: linux-fsdevel@vger.kernel.org\n---\n fs/netfs/iterator.c | 21 ++++++++++++---------\n 1 file changed, 12 insertions(+), 9 deletions(-)","diff":"diff --git a/fs/netfs/iterator.c b/fs/netfs/iterator.c\nindex adca78747f23..932f745fa3b5 100644\n--- a/fs/netfs/iterator.c\n+++ b/fs/netfs/iterator.c\n@@ -72,21 +72,24 @@ ssize_t netfs_extract_user_iter(struct iov_iter *orig, size_t orig_len,\n \t\t\tbreak;\n \t\t}\n \n-\t\tif (ret > count) {\n-\t\t\tpr_err(\"get_pages rc=%zd more than %zu\\n\", ret, count);\n+\t\tif (WARN(ret > count,\n+\t\t\t \"%s: extract_pages overrun %zd > %zu bytes\\n\",\n+\t\t\t __func__, ret, count)) {\n+\t\t\tret = -EIO;\n \t\t\tbreak;\n \t\t}\n \n-\t\tcount -= ret;\n-\t\tret += offset;\n-\t\tcur_npages = DIV_ROUND_UP(ret, PAGE_SIZE);\n-\n-\t\tif (npages + cur_npages > max_pages) {\n-\t\t\tpr_err(\"Out of bvec array capacity (%u vs %u)\\n\",\n-\t\t\t       npages + cur_npages, max_pages);\n+\t\tcur_npages = DIV_ROUND_UP(offset + ret, PAGE_SIZE);\n+\t\tif (WARN(cur_npages > max_pages - npages,\n+\t\t\t \"%s: extract_pages overrun %u > %u pages\\n\",\n+\t\t\t __func__, npages + cur_npages, max_pages)) {\n+\t\t\tret = -EIO;\n \t\t\tbreak;\n \t\t}\n \n+\t\tcount -= ret;\n+\t\tret += offset;\n+\n \t\tfor (i = 0; i < cur_npages; i++) {\n \t\t\tlen = ret > PAGE_SIZE ? PAGE_SIZE : ret;\n \t\t\tbvec_set_page(bv + npages + i, *pages++, len - offset, offset);\n","prefixes":["v5","09/24"]}