From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender-of-o57.zoho.eu (sender-of-o57.zoho.eu [136.143.169.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 532BE35295C for ; Tue, 24 Mar 2026 20:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.57 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774385665; cv=pass; b=te7q2IPAHbdv/S0bXLBFCnsykTWkGRliuMXVuJHGNSNlYLPb9zJV0p2YRzm6XCYkjBz77o+x5jJHgcnYuwXFTMUmULw4GxCZD/sc5q73K7eYKEHH265kXJ4cSW9TP9XizYMMvWQ+wBfGR7i9n+z1lxqdaZKP6tKS8wLPCAAG9SQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774385665; c=relaxed/simple; bh=NqLAIKljFZbAzzaLSeaInMQzUGN3gOw56cVHMTUF+N4=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=rCiquxDn91zQZaGk8pqOIOSYL31TJuKj/SC6PZkNNFXJkHOMxOCmFZ22CJrHRQoJCJeLP9bHWW8RmoSZhygYIYT8HB12FIuP82xI3AWXqv4DVSzxHZ0A8ORFofC72/2Gfz2ZLxjtJMuLHAzAsJoTJIDzjgg8zLqPG9EoKSh90fY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=KmR8A0Vh; arc=pass smtp.client-ip=136.143.169.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="KmR8A0Vh" ARC-Seal: i=1; a=rsa-sha256; t=1774385649; cv=none; d=zohomail.eu; s=zohoarc; b=hlKQo9Ca9V6bVj3UFeWRQY5IH9X0HQVJ2G4xc1/l6Gs/ghwUPnOKHJXWHJ0oE+XpcUJVr7qIkLw9hOHclxuJ8fZAa2vICbFi4IAT58qthU/969CVfXzrt4x7AOXT7+N2n+d6bG7CoglnpyVy2dddAfEYBhRLTexJoOWePBgkCoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1774385649; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pld4Hcmo2iBE72mKaPQHZLKC7kLxTCmtDBDw6mXKd78=; b=IFgvdUO+AvPfs6p7/SolCga+Vqwc/VYKBkV1znrNsbqBwtwFPsUA6ieIUzNQDXMZuFI/dqbw+xr9XOTaNbK+0Df8WHZFU3qt4BVpstoSAugtXjDdba+XWdddVvKa3v00fxTWmxvj/jO8j2d6Hd3hG6jfVZjf0+Qf2MJIvQAQGho= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1774385649; s=zmail; d=objecting.org; i=objecting@objecting.org; h=Date:Date:From:From:To:To:CC:Subject:Subject:In-Reply-To:References:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=Pld4Hcmo2iBE72mKaPQHZLKC7kLxTCmtDBDw6mXKd78=; b=KmR8A0VhymjPOHYRGKTQntp/b+COb2Hvq0bKK4od8IczJlEHxeJGdeFPHPnaC3oa O8aofa/9JyGHSoRjoDPfpFT+72/JvVlQVq6e/yHqewpK0OlezY88Q493o+7+eczGs1R S4W5avHUe7BANFih91FhL4gSnVCek7FMDmZHUd3Q= Received: by mx.zoho.eu with SMTPS id 1774385646256303.2831795474084; Tue, 24 Mar 2026 21:54:06 +0100 (CET) Date: Tue, 24 Mar 2026 20:54:04 +0000 From: Josh Law To: "Christian A. Ehrhardt" , linux-kernel@vger.kernel.org, Andrew Morton , David Howells CC: Kees Cook , Petr Mladek , David Gow Subject: Re: [PATCH v2 2/3] lib: Fix length calculations in extract_kvec_to_sg User-Agent: Thunderbird for Android In-Reply-To: <20260324203453.810499-3-lk@c--e.de> References: <20260324203453.810499-1-lk@c--e.de> <20260324203453.810499-3-lk@c--e.de> Message-ID: 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-Transfer-Encoding: quoted-printable X-ZohoMailClient: External On 24 March 2026 20:34:52 GMT, "Christian A=2E Ehrhardt" wr= ote: >When extracting from a kvec to a scatterlist, do not >cross page boundaries=2E The required length is already >calculated but not used as intended=2E > >Adjust the copied length if the loop runs out auf >sglist entries=2E Nit: "auf" > of?? (Probably a typo) >While there return immediately from extract_iter_to_sg >if there are no sglist entries at all=2E Suggestion: You could change it to "While there**,** return immediately f= rom extract_iter_to_sg if there are no sglist entries at all=2E" It is some= thing a bit "silly" so it doesn't matter much >The changes to the kunit_iov_iter=2Ec in the next commit >demonstrate that the patch is necessary=2E > >Cc: David Howells >Cc: Andrew Morton >Cc: stable@vger=2Ekernel=2Eorg # v6=2E5+ >Fixes: 018584697533 ("netfs: Add a function to extract an iterator into a= scatterlist") >Signed-off-by: Christian A=2E Ehrhardt >--- > lib/scatterlist=2Ec | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > >diff --git a/lib/scatterlist=2Ec b/lib/scatterlist=2Ec >index d773720d11bf=2E=2Ebefdc4b9c11d 100644 >--- a/lib/scatterlist=2Ec >+++ b/lib/scatterlist=2Ec >@@ -1247,7 +1247,7 @@ static ssize_t extract_kvec_to_sg(struct iov_iter *= iter, > else > page =3D virt_to_page((void *)kaddr); >=20 >- sg_set_page(sg, page, len, off); >+ sg_set_page(sg, page, seg, off); > sgtable->nents++; > sg++; > sg_max--; >@@ -1256,6 +1256,7 @@ static ssize_t extract_kvec_to_sg(struct iov_iter *= iter, > kaddr +=3D PAGE_SIZE; > off =3D 0; > } while (len > 0 && sg_max > 0); >+ ret -=3D len; >=20 > if (maxsize <=3D 0 || sg_max =3D=3D 0) > break; >@@ -1409,7 +1410,7 @@ ssize_t extract_iter_to_sg(struct iov_iter *iter, s= ize_t maxsize, > struct sg_table *sgtable, unsigned int sg_max, > iov_iter_extraction_t extraction_flags) > { >- if (maxsize =3D=3D 0) >+ if (maxsize =3D=3D 0 || sg_max =3D=3D 0) > return 0; >=20 > switch (iov_iter_type(iter)) { This C is absolutely perfect! No nits here V/R=20 Josh Law