Skip to content

Commit 90fb702

Browse files
committed
autofs: use __kernel_write() for the autofs pipe writing
autofs got broken in some configurations by commit 13c164b ("autofs: switch to kernel_write") because there is now an extra LSM permission check done by security_file_permission() in rw_verify_area(). autofs is one if the few places that really does want the much more limited __kernel_write(), because the write is an internal kernel one that shouldn't do any user permission checks (it also doesn't need the file_start_write/file_end_write logic, since it's just a pipe). There are a couple of other cases like that - accounting, core dumping, and splice - but autofs stands out because it can be built as a module. As a result, we need to export this internal __kernel_write() function again. We really don't want any other module to use this, but we don't have a "EXPORT_SYMBOL_FOR_AUTOFS_ONLY()". But we can mark it GPL-only to at least approximate that "internal use only" for licensing. While in this area, make autofs pass in NULL for the file position pointer, since it's always a pipe, and we now use a NULL file pointer for streaming file descriptors (see file_ppos() and commit 438ab72: "vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files") This effectively reverts commits 9db9775 ("fs: unexport __kernel_write") and 13c164b ("autofs: switch to kernel_write"). Fixes: 13c164b ("autofs: switch to kernel_write") Reported-by: Ondrej Mosnacek <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Acked-by: Acked-by: Ian Kent <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ccc1d05 commit 90fb702

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fs/autofs/waitq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int autofs_write(struct autofs_sb_info *sbi,
5353

5454
mutex_lock(&sbi->pipe_mutex);
5555
while (bytes) {
56-
wr = kernel_write(file, data, bytes, &file->f_pos);
56+
wr = __kernel_write(file, data, bytes, NULL);
5757
if (wr <= 0)
5858
break;
5959
data += wr;

fs/read_write.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,14 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t
538538
inc_syscw(current);
539539
return ret;
540540
}
541+
/*
542+
* This "EXPORT_SYMBOL_GPL()" is more of a "EXPORT_SYMBOL_DONTUSE()",
543+
* but autofs is one of the few internal kernel users that actually
544+
* wants this _and_ can be built as a module. So we need to export
545+
* this symbol for autofs, even though it really isn't appropriate
546+
* for any other kernel modules.
547+
*/
548+
EXPORT_SYMBOL_GPL(__kernel_write);
541549

542550
ssize_t kernel_write(struct file *file, const void *buf, size_t count,
543551
loff_t *pos)

0 commit comments

Comments
 (0)