lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <AANLkTimFqQ=FRVtPZT2B6TSbugE_+Wh6TRGzck5Wf8xr@mail.gmail.com>
Date:	Mon, 4 Oct 2010 19:43:53 +0800
From:	Hillf Danton <dhillf@...il.com>
To:	Jens Axboe <jens.axboe@...cle.com>,
	David Miller <davem@...emloft.net>,
	linux-kernel@...r.kernel.org, axboe@...nel.dk,
	robert.w.love@...el.com,
	"James E.J. Bottomley" <James.Bottomley@...e.de>
Subject: Ask For Comment: add offset_in_sg parameter for data copy in scatter list

Two routines, modeled from sg_copy_from/to_buffer, are added for cases that
offset_in_sg has to be taken as a parameter.

Then it seems that the procedure of sg_miter_start/next/stop in
sg_copy_buffer()
will no longer be modeled, and all __xyz elements of miter are
untouched as well,
outside scatter list.

Signed-off-by: Hillf Danton <dhillf@...il.com>
---

--- o/linux-2.6.36-rc4/include/linux/scatterlist.h	2010-09-13
07:07:38.000000000 +0800
+++ m/linux-2.6.36-rc4/include/linux/scatterlist.h	2010-10-04
18:56:00.000000000 +0800
@@ -217,6 +217,12 @@ size_t sg_copy_from_buffer(struct scatte
 			   void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			 void *buf, size_t buflen);
+size_t sg_copy_from_buffer_offset(struct scatterlist *sgl, unsigned int nents,
+			   void *buf, size_t buflen,
+			   unsigned int offset_in_sg);
+size_t sg_copy_to_buffer_offset(struct scatterlist *sgl, unsigned int nents,
+			 void *buf, size_t buflen,
+			 unsigned int offset_in_sg);

 /*
  * Maximum number of entries that will be allocated in one piece, if
--- o/linux-2.6.36-rc4/lib/scatterlist.c	2010-09-13 07:07:38.000000000 +0800
+++ m/linux-2.6.36-rc4/lib/scatterlist.c	2010-10-04 19:14:10.000000000 +0800
@@ -449,7 +449,8 @@ EXPORT_SYMBOL(sg_miter_stop);
  *
  **/
 static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
-			     void *buf, size_t buflen, int to_buffer)
+			     void *buf, size_t buflen, int to_buffer,
+			     unsigned int offset_in_sg)
 {
 	unsigned int offset = 0;
 	struct sg_mapping_iter miter;
@@ -462,6 +463,7 @@ static size_t sg_copy_buffer(struct scat
 		sg_flags |= SG_MITER_TO_SG;

 	sg_miter_start(&miter, sgl, nents, sg_flags);
+	miter.__offset = offset_in_sg;

 	local_irq_save(flags);

@@ -497,7 +499,7 @@ static size_t sg_copy_buffer(struct scat
 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			   void *buf, size_t buflen)
 {
-	return sg_copy_buffer(sgl, nents, buf, buflen, 0);
+	return sg_copy_buffer(sgl, nents, buf, buflen, 0, 0);
 }
 EXPORT_SYMBOL(sg_copy_from_buffer);

@@ -514,6 +516,28 @@ EXPORT_SYMBOL(sg_copy_from_buffer);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			 void *buf, size_t buflen)
 {
-	return sg_copy_buffer(sgl, nents, buf, buflen, 1);
+	return sg_copy_buffer(sgl, nents, buf, buflen, 1, 0);
 }
 EXPORT_SYMBOL(sg_copy_to_buffer);
+
+/*
+ * Like the above, and with parameter offset_in_sg
+ */
+
+size_t
+sg_copy_from_buffer_offset(struct scatterlist *sgl, unsigned int nents,
+			   void *buf, size_t buflen,
+			   unsigned int offset_in_sg)
+{
+	return sg_copy_buffer(sgl, nents, buf, buflen, 0, offset_in_sg);
+}
+EXPORT_SYMBOL(sg_copy_from_buffer_offset);
+
+size_t
+sg_copy_to_buffer_offset(struct scatterlist *sgl, unsigned int nents,
+			 void *buf, size_t buflen,
+			 unsigned int offset_in_sg);
+{
+	return sg_copy_buffer(sgl, nents, buf, buflen, 1, offset_in_sg);
+}
+EXPORT_SYMBOL(sg_copy_to_buffer_offset);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ