All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: David Howells <dhowells@redhat.com>
Cc: Steve French <smfrench@gmail.com>,
	Shyam Prasad N <nspmangalore@gmail.com>,
	Rohith Surabattula <rohiths.msft@gmail.com>,
	Jeff Layton <jlayton@kernel.org>,
	linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/9] iov_iter: Add a general purpose iteration function
Date: Fri, 27 May 2022 14:33:04 +0000	[thread overview]
Message-ID: <YpDhIDacnktXvMpS@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <165364824973.3334034.10715738699511650662.stgit@warthog.procyon.org.uk>

On Fri, May 27, 2022 at 11:44:09AM +0100, David Howells wrote:
> Add a function, iov_iter_scan(), to iterate over the buffers described by
> an I/O iterator, kmapping and passing each contiguous chunk the supplied
> scanner function in turn, up to the requested amount of data or until the
> scanner function returns an error.
> 
> This can be used, for example, to hash all the data in an iterator by
> having the scanner function call the appropriate crypto update function.

> +ssize_t iov_iter_scan(struct iov_iter *i, size_t bytes,
> +		      ssize_t (*scanner)(struct iov_iter *i, const void *p,
> +					 size_t len, size_t off, void *priv),
> +		      void *priv)
> +{
> +	ssize_t ret = 0, scanned = 0;
> +
> +	if (!bytes)
> +		return 0;
> +	if (iter_is_iovec(i))
> +		might_fault();
> +
> +	iterate_and_advance(
> +		i, bytes, base, len, off, ({
> +				ret = scanner(i, base, len, off, priv);
> +				if (ret < 0)
> +					break;
> +				scanned += ret;
> +			}), ({
> +				ret = scanner(i, base, len, off, priv);
> +				if (ret < 0)
> +					break;
> +				scanned += ret;
> +			})
> +	);
> +	return ret < 0 ? ret : scanned;
> +}

Have you even tried to run sparse on that?  How could that possibly work?
You are feeding the same callback both userland and kernel pointers;
that makes no sense.

NAK.

  reply	other threads:[~2022-05-27 14:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 10:43 [PATCH v3 0/9] cifs: Use iov_iters down to the network transport David Howells
2022-05-27 10:44 ` [PATCH v3 1/9] iov_iter: Add a function to extract an iter's buffers to a bvec iter David Howells
2022-05-31  6:03   ` Christoph Hellwig
2022-05-27 10:44 ` [PATCH v3 2/9] iov_iter: Add a general purpose iteration function David Howells
2022-05-27 14:33   ` Al Viro [this message]
2022-05-27 10:44 ` [PATCH v3 3/9] cifs: Add some helper functions David Howells
2022-05-27 10:44 ` [PATCH v3 4/9] cifs: Add a function to read into an iter from a socket David Howells
2022-05-27 10:44 ` [PATCH v3 5/9] cifs: Change the I/O paths to use an iterator rather than a page list David Howells
2022-05-27 10:44 ` [PATCH v3 6/9] cifs: Remove unused code David Howells
2022-05-27 10:44 ` [PATCH v3 7/9] cifs: Trace writedata page wrangling David Howells
2022-05-27 10:44 ` [PATCH v3 8/9] cifs: Add some RDMA send tracepoints David Howells
2022-05-27 10:45 ` [PATCH v3 9/9] cifs, ksmbd: Fix MAX_SGE count for softiwarp David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YpDhIDacnktXvMpS@zeniv-ca.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=dhowells@redhat.com \
    --cc=jlayton@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nspmangalore@gmail.com \
    --cc=rohiths.msft@gmail.com \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.