Commit 5c04c46aec16b3267d8fe03af886f2d41e448cd0

Authored by J. Bruce Fields
Committed by Linus Torvalds
1 parent e142ede8e0

[PATCH] knfsd: nfsd: mark rqstp to prevent use of sendfile in privacy case

Add a rq_sendfile_ok flag to svc_rqst which will be cleared in the privacy
case so that the wrapping code will get copies of the read data instead of
real page cache pages.  This makes life simpler when we encrypt the response.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 3 changed files with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -837,7 +837,7 @@
837 837 if (ra && ra->p_set)
838 838 file->f_ra = ra->p_ra;
839 839  
840   - if (file->f_op->sendfile) {
  840 + if (file->f_op->sendfile && rqstp->rq_sendfile_ok) {
841 841 svc_pushback_unused_pages(rqstp);
842 842 err = file->f_op->sendfile(file, &offset, *count,
843 843 nfsd_read_actor, rqstp);
include/linux/sunrpc/svc.h
... ... @@ -159,7 +159,9 @@
159 159 * determine what device number
160 160 * to report (real or virtual)
161 161 */
162   -
  162 + int rq_sendfile_ok; /* turned off in gss privacy
  163 + * to prevent encrypting page
  164 + * cache pages */
163 165 wait_queue_head_t rq_wait; /* synchronization */
164 166 };
165 167  
... ... @@ -281,6 +281,8 @@
281 281 rqstp->rq_res.page_len = 0;
282 282 rqstp->rq_res.buflen = PAGE_SIZE;
283 283 rqstp->rq_res.tail[0].iov_len = 0;
  284 + /* Will be turned off only in gss privacy case: */
  285 + rqstp->rq_sendfile_ok = 1;
284 286 /* tcp needs a space for the record length... */
285 287 if (rqstp->rq_prot == IPPROTO_TCP)
286 288 svc_putu32(resv, 0);