diff options
author | Nick Piggin <npiggin@suse.de> | 2008-02-01 21:08:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-02-04 10:55:38 -0500 |
commit | 2f98735c9c24ea1f0d40a364d4e63611b689b795 (patch) | |
tree | a42b3802449af474d36cda3b6f9fb190a717defb /sound | |
parent | fe2528b96b02173395f5a75e37714c07f3e25e73 (diff) |
vm audit: add VM_DONTEXPAND to mmap for drivers that need it
Drivers that register a ->fault handler, but do not range-check the
offset argument, must set VM_DONTEXPAND in the vm_flags in order to
prevent an expanding mremap from overflowing the resource.
I've audited the tree and attempted to fix these problems (usually by
adding VM_DONTEXPAND where it is not obvious).
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/oss/via82cxxx_audio.c | 14 | ||||
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.c | 2 | ||||
-rw-r--r-- | sound/usb/usx2y/usx2yhwdeppcm.c | 2 |
3 files changed, 8 insertions, 10 deletions
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c index 5d3c0372df32..f95aa0946758 100644 --- a/sound/oss/via82cxxx_audio.c +++ b/sound/oss/via82cxxx_audio.c | |||
@@ -2104,6 +2104,7 @@ static struct page * via_mm_nopage (struct vm_area_struct * vma, | |||
2104 | { | 2104 | { |
2105 | struct via_info *card = vma->vm_private_data; | 2105 | struct via_info *card = vma->vm_private_data; |
2106 | struct via_channel *chan = &card->ch_out; | 2106 | struct via_channel *chan = &card->ch_out; |
2107 | unsigned long max_bufs; | ||
2107 | struct page *dmapage; | 2108 | struct page *dmapage; |
2108 | unsigned long pgoff; | 2109 | unsigned long pgoff; |
2109 | int rd, wr; | 2110 | int rd, wr; |
@@ -2127,14 +2128,11 @@ static struct page * via_mm_nopage (struct vm_area_struct * vma, | |||
2127 | rd = card->ch_in.is_mapped; | 2128 | rd = card->ch_in.is_mapped; |
2128 | wr = card->ch_out.is_mapped; | 2129 | wr = card->ch_out.is_mapped; |
2129 | 2130 | ||
2130 | #ifndef VIA_NDEBUG | 2131 | max_bufs = chan->frag_number; |
2131 | { | 2132 | if (rd && wr) |
2132 | unsigned long max_bufs = chan->frag_number; | 2133 | max_bufs *= 2; |
2133 | if (rd && wr) max_bufs *= 2; | 2134 | if (pgoff >= max_bufs) |
2134 | /* via_dsp_mmap() should ensure this */ | 2135 | return NOPAGE_SIGBUS; |
2135 | assert (pgoff < max_bufs); | ||
2136 | } | ||
2137 | #endif | ||
2138 | 2136 | ||
2139 | /* if full-duplex (read+write) and we have two sets of bufs, | 2137 | /* if full-duplex (read+write) and we have two sets of bufs, |
2140 | * then the playback buffers come first, sez soundcard.c */ | 2138 | * then the playback buffers come first, sez soundcard.c */ |
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 6495534e5bf6..1558a5c4094f 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -84,7 +84,7 @@ static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct v | |||
84 | us428->us428ctls_sharedmem->CtlSnapShotLast = -2; | 84 | us428->us428ctls_sharedmem->CtlSnapShotLast = -2; |
85 | } | 85 | } |
86 | area->vm_ops = &us428ctls_vm_ops; | 86 | area->vm_ops = &us428ctls_vm_ops; |
87 | area->vm_flags |= VM_RESERVED; | 87 | area->vm_flags |= VM_RESERVED | VM_DONTEXPAND; |
88 | area->vm_private_data = hw->private_data; | 88 | area->vm_private_data = hw->private_data; |
89 | return 0; | 89 | return 0; |
90 | } | 90 | } |
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 800b5cecfc80..117946f2debb 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c | |||
@@ -722,7 +722,7 @@ static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, st | |||
722 | return -ENODEV; | 722 | return -ENODEV; |
723 | } | 723 | } |
724 | area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; | 724 | area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; |
725 | area->vm_flags |= VM_RESERVED; | 725 | area->vm_flags |= VM_RESERVED | VM_DONTEXPAND; |
726 | area->vm_private_data = hw->private_data; | 726 | area->vm_private_data = hw->private_data; |
727 | return 0; | 727 | return 0; |
728 | } | 728 | } |