stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	Miklos Szeredi <mszeredi@suse.cz>
Subject: [PATCH 3.12 007/107] fuse: fix pipe_buf_operations
Date: Tue, 11 Feb 2014 11:04:33 -0800	[thread overview]
Message-ID: <20140211184748.414620016@linuxfoundation.org> (raw)
In-Reply-To: <20140211184748.191276235@linuxfoundation.org>

3.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Miklos Szeredi <mszeredi@suse.cz>

commit 28a625cbc2a14f17b83e47ef907b2658576a32aa upstream.

Having this struct in module memory could Oops when if the module is
unloaded while the buffer still persists in a pipe.

Since sock_pipe_buf_ops is essentially the same as fuse_dev_pipe_buf_steal
merge them into nosteal_pipe_buf_ops (this is the same as
default_pipe_buf_ops except stealing the page from the buffer is not
allowed).

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/fuse/dev.c             |   22 +++++-----------------
 fs/splice.c               |   18 ++++++++++++++++++
 include/linux/pipe_fs_i.h |    2 ++
 net/core/skbuff.c         |   32 +-------------------------------
 4 files changed, 26 insertions(+), 48 deletions(-)

--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1296,22 +1296,6 @@ static ssize_t fuse_dev_read(struct kioc
 	return fuse_dev_do_read(fc, file, &cs, iov_length(iov, nr_segs));
 }
 
-static int fuse_dev_pipe_buf_steal(struct pipe_inode_info *pipe,
-				   struct pipe_buffer *buf)
-{
-	return 1;
-}
-
-static const struct pipe_buf_operations fuse_dev_pipe_buf_ops = {
-	.can_merge = 0,
-	.map = generic_pipe_buf_map,
-	.unmap = generic_pipe_buf_unmap,
-	.confirm = generic_pipe_buf_confirm,
-	.release = generic_pipe_buf_release,
-	.steal = fuse_dev_pipe_buf_steal,
-	.get = generic_pipe_buf_get,
-};
-
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
 				    struct pipe_inode_info *pipe,
 				    size_t len, unsigned int flags)
@@ -1358,7 +1342,11 @@ static ssize_t fuse_dev_splice_read(stru
 		buf->page = bufs[page_nr].page;
 		buf->offset = bufs[page_nr].offset;
 		buf->len = bufs[page_nr].len;
-		buf->ops = &fuse_dev_pipe_buf_ops;
+		/*
+		 * Need to be careful about this.  Having buf->ops in module
+		 * code can Oops if the buffer persists after module unload.
+		 */
+		buf->ops = &nosteal_pipe_buf_ops;
 
 		pipe->nrbufs++;
 		page_nr++;
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -555,6 +555,24 @@ static const struct pipe_buf_operations
 	.get = generic_pipe_buf_get,
 };
 
+static int generic_pipe_buf_nosteal(struct pipe_inode_info *pipe,
+				    struct pipe_buffer *buf)
+{
+	return 1;
+}
+
+/* Pipe buffer operations for a socket and similar. */
+const struct pipe_buf_operations nosteal_pipe_buf_ops = {
+	.can_merge = 0,
+	.map = generic_pipe_buf_map,
+	.unmap = generic_pipe_buf_unmap,
+	.confirm = generic_pipe_buf_confirm,
+	.release = generic_pipe_buf_release,
+	.steal = generic_pipe_buf_nosteal,
+	.get = generic_pipe_buf_get,
+};
+EXPORT_SYMBOL(nosteal_pipe_buf_ops);
+
 static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
 			    unsigned long vlen, loff_t offset)
 {
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -157,6 +157,8 @@ int generic_pipe_buf_confirm(struct pipe
 int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
 void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
 
+extern const struct pipe_buf_operations nosteal_pipe_buf_ops;
+
 /* for F_SETPIPE_SZ and F_GETPIPE_SZ */
 long pipe_fcntl(struct file *, unsigned int, unsigned long arg);
 struct pipe_inode_info *get_pipe_info(struct file *file);
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -74,36 +74,6 @@
 struct kmem_cache *skbuff_head_cache __read_mostly;
 static struct kmem_cache *skbuff_fclone_cache __read_mostly;
 
-static void sock_pipe_buf_release(struct pipe_inode_info *pipe,
-				  struct pipe_buffer *buf)
-{
-	put_page(buf->page);
-}
-
-static void sock_pipe_buf_get(struct pipe_inode_info *pipe,
-				struct pipe_buffer *buf)
-{
-	get_page(buf->page);
-}
-
-static int sock_pipe_buf_steal(struct pipe_inode_info *pipe,
-			       struct pipe_buffer *buf)
-{
-	return 1;
-}
-
-
-/* Pipe buffer operations for a socket. */
-static const struct pipe_buf_operations sock_pipe_buf_ops = {
-	.can_merge = 0,
-	.map = generic_pipe_buf_map,
-	.unmap = generic_pipe_buf_unmap,
-	.confirm = generic_pipe_buf_confirm,
-	.release = sock_pipe_buf_release,
-	.steal = sock_pipe_buf_steal,
-	.get = sock_pipe_buf_get,
-};
-
 /**
  *	skb_panic - private function for out-of-line support
  *	@skb:	buffer
@@ -1800,7 +1770,7 @@ int skb_splice_bits(struct sk_buff *skb,
 		.partial = partial,
 		.nr_pages_max = MAX_SKB_FRAGS,
 		.flags = flags,
-		.ops = &sock_pipe_buf_ops,
+		.ops = &nosteal_pipe_buf_ops,
 		.spd_release = sock_spd_release,
 	};
 	struct sk_buff *frag_iter;



  parent reply	other threads:[~2014-02-11 19:04 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11 19:04 [PATCH 3.12 000/107] 3.12.11-stable review Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 001/107] SELinux: Fix memory leak upon loading policy Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 002/107] tracing: Have trace buffer point back to trace_array Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 003/107] tracing: Check if tracing is enabled in trace_puts() Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 004/107] arch/sh/kernel/kgdb.c: add missing #include <linux/sched.h> Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 005/107] intel-iommu: fix off-by-one in pagetable freeing Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 006/107] Revert "EISA: Initialize device before its resources" Greg Kroah-Hartman
2014-02-11 19:04 ` Greg Kroah-Hartman [this message]
2014-02-11 19:04 ` [PATCH 3.12 008/107] audit: reset audit backlog wait time after error recovery Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 009/107] audit: correct a type mismatch in audit_syscall_exit() Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 010/107] xen/pvhvm: If xen_platform_pci=0 is set dont blow up (v4) Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 011/107] mm/memory-failure.c: shift page lock from head page to tail page after thp split Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 012/107] mm/memcg: iteration skip memcgs not yet fully initialized Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 013/107] mm/page-writeback.c: fix dirty_balance_reserve subtraction from dirtyable memory Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 014/107] mm/page-writeback.c: do not count anon pages as " Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 015/107] memcg: fix endless loop caused by mem_cgroup_iter Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 016/107] memcg: fix css reference leak and endless loop in mem_cgroup_iter Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 017/107] mm: ignore VM_SOFTDIRTY on VMA merging Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 018/107] mm: dont lose the SOFT_DIRTY flag on mprotect Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 019/107] mmc: fix host release issue after discard operation Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 020/107] mmc: atmel-mci: fix timeout errors in SDIO mode when using DMA Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 021/107] mmc: core: sd: implement proper support for sd3.0 au sizes Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 022/107] ARM: orion: provide C-style interrupt handler for MULTI_IRQ_HANDLER Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 023/107] ARM: mvebu: Fix kernel hang in mvebu_soc_id_init() when of_iomap failed Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 024/107] slub: Fix calculation of cpu slabs Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 025/107] turbostat: Dont put unprocessed uapi headers in the include path Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 027/107] ACPI / init: Flag use of ACPI and ACPI idioms for power supplies to regulator API Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 028/107] compat: fix sys_fanotify_mark Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 029/107] fs/compat: fix parameter handling for compat readv/writev syscalls Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 030/107] fs/compat: fix lookup_dcookie() parameter handling Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 031/107] tile: remove compat_sys_lookup_dcookie declaration to fix compile error Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 032/107] mtd: mxc_nand: remove duplicated ecc_stats counting Greg Kroah-Hartman
2014-02-11 19:04 ` [PATCH 3.12 033/107] ore: Fix wrong math in allocation of per device BIO Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 034/107] xtensa: xtfpga: fix definitions of platform devices Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 035/107] IB/qib: Fix QP check when looping back to/from QP1 Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 036/107] spi/bcm63xx: dont substract prepend length from total length Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 037/107] spidev: fix hang when transfer_one_message fails Greg Kroah-Hartman
2014-02-20 12:42   ` Geert Uytterhoeven
2014-02-20 21:41     ` Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 038/107] spi/pxa2xx: initialize DMA channels to -1 to prevent inadvertent match Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 039/107] NFSv4: OPEN must handle the NFS4ERR_IO return code correctly Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 040/107] nfs4.1: properly handle ENOTSUP in SECINFO_NO_NAME Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 042/107] NFSv4.1: Handle errors correctly in nfs41_walk_client_list Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 043/107] nfs4: fix discover_server_trunking use after free Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 044/107] pnfs: Proper delay for NFS4ERR_RECALLCONFLICT in layout_get_done Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 045/107] NFSv4: Fix a slot leak in nfs40_sequence_done Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 046/107] sunrpc: Fix infinite loop in RPC state machine Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 047/107] sunrpc: dont wait for write before allowing reads from use-gss-proxy file Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 048/107] dm thin: fix discard support to a previously shared block Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 049/107] dm thin: initialize dm_thin_new_mapping returned by get_next_mapping Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 050/107] dm thin: fix set_pool_mode exposed pool operation races Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 051/107] dm: wait until embedded kobject is released before destroying a device Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 052/107] dm space map common: make sure new space is used during extend Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 053/107] dm space map metadata: fix extending the space map Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 054/107] dm space map metadata: fix bug in resizing of thin metadata Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 056/107] drm/radeon/dpm: disable mclk switching on desktop RV770 Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 058/107] mei: mei_hbm_dispatch() returns void Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 059/107] percpu_ida: Make percpu_ida_alloc + callers accept task state bitmask Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 060/107] iscsi-target: Fix connection reset hang with percpu_ida_alloc Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 061/107] mm, oom: base root bonus on current usage Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 062/107] media: media: v4l2-dev: fix video device index assignment Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 063/107] media: anysee: fix non-working E30 Combo Plus DVB-T Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 064/107] [media] dib8000: make 32 bits read atomic Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 065/107] [media] media: s5p_mfc: remove s5p_mfc_get_node_type() function Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 066/107] [media] it913x: Add support for Avermedia H335 id 0x0335 Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 067/107] [media] nxt200x: increase write buffer size Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 068/107] [media] dib8000: fix regression with dib807x Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 069/107] [media] m88rs2000: add m88rs2000_set_carrieroffset Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 070/107] [media] m88rs2000: set symbol rate accurately Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 072/107] drm/radeon: disable ss on DP for DCE3.x Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 073/107] drm/radeon: fix surface sync in fence on cayman (v2) Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 074/107] drm/radeon: set the full cache bit for fences on r7xx+ Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 075/107] drm/radeon: add UVD support for OLAND Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 076/107] drm/radeon: fix DAC interrupt handling on DCE5+ Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 077/107] drm/radeon/DCE4+: clear bios scratch dpms bit (v2) Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 078/107] drm/radeon/dce8: workaround for atom BlankCrtc table Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 079/107] dm sysfs: fix a module unload race Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 080/107] drm/nouveau: fix m2mf copy to tiled gart Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 081/107] drm/nouveau/falcon: use vmalloc to create firwmare copies Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 082/107] drm/i915: Flush outstanding requests before allocating new seqno Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 083/107] drm/i915: Fix the offset issue for the stolen GEM objects Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 084/107] drm/i915: VLV2 - Fix hotplug detect bits Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 085/107] i915: remove pm_qos request on error Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 087/107] drm/cirrus: correct register values for 16bpp Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 088/107] drm/gem: Always initialize the gem object in object_init Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 089/107] drm/rcar-du: Update plane pitch in .mode_set_base() operation Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 090/107] drm/gma500: Lock struct_mutex around cursor updates Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 091/107] drm: ast,cirrus,mgag200: use drm_can_sleep Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 092/107] drm/vmwgfx: Fix regression caused by "drm/ttm: make ttm reservation calls behave like reservation calls" Greg Kroah-Hartman
2014-02-11 19:05 ` [PATCH 3.12 093/107] drm/mgag200: fix oops in cursor code Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 094/107] drm/mgag200: fix typo causing bw limits to be ignored on some chips Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 095/107] drm/mgag200,ast,cirrus: fix regression with drm_can_sleep conversion Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 096/107] ftrace: Synchronize setting function_trace_op with ftrace_trace_function Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 097/107] ftrace: Fix synchronization location disabling and freeing ftrace_ops Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 098/107] ftrace: Have function graph only trace based on global_ops filters Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 099/107] timekeeping: Fix lost updates to tai adjustment Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 100/107] timekeeping: Fix potential lost pv notification of time change Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 101/107] timekeeping: Avoid possible deadlock from clock_was_set_delayed Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 102/107] 3.13.y: timekeeping: Fix clock_set/clock_was_set think-o Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 103/107] timekeeping: Fix CLOCK_TAI timer/nanosleep delays Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 104/107] timekeeping: Fix missing timekeeping_update in suspend path Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 105/107] rtc-cmos: Add an alarm disable quirk Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 106/107] mmc: sdhci-pci: Fix BYT sd card getting stuck in runtime suspend Greg Kroah-Hartman
2014-02-11 19:06 ` [PATCH 3.12 107/107] mmc: sdhci-pci: Fix possibility of chip->fixes being null Greg Kroah-Hartman
2014-02-12  4:21 ` [PATCH 3.12 000/107] 3.12.11-stable review Guenter Roeck
2014-02-12 18:49 ` Shuah Khan

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=20140211184748.414620016@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mszeredi@suse.cz \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).