diff options
author | Ramiro Polla <ramiro.polla@gmail.com> | 2009-08-13 18:29:54 +0000 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2009-08-13 18:29:54 +0000 |
commit | 072877888521ffd81a56821350cde68939789560 (patch) | |
tree | 755465fc0dab8eae0da76cbddc1a98e5573349fc /libswscale/swscale.c | |
parent | b0e1343b85ad83e753bf18bb86144c735916fffc (diff) | |
download | ffmpeg-072877888521ffd81a56821350cde68939789560.tar.gz |
Protect mmx2 filter code buffers so they are not executable and writeable at
the same time (only mmap for now).
Originally committed as revision 29509 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
Diffstat (limited to 'libswscale/swscale.c')
-rw-r--r-- | libswscale/swscale.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c index e1767d9692..4a69ab8ea1 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2814,8 +2814,8 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) { #ifdef MAP_ANONYMOUS - c->lumMmx2FilterCode = mmap(NULL, MAX_MMX2_FILTER_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); - c->chrMmx2FilterCode = mmap(NULL, MAX_MMX2_FILTER_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + c->lumMmx2FilterCode = mmap(NULL, MAX_MMX2_FILTER_CODE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + c->chrMmx2FilterCode = mmap(NULL, MAX_MMX2_FILTER_CODE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); #elif HAVE_VIRTUALALLOC c->lumMmx2FilterCode = VirtualAlloc(NULL, MAX_MMX2_FILTER_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); c->chrMmx2FilterCode = VirtualAlloc(NULL, MAX_MMX2_FILTER_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); @@ -2831,6 +2831,11 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->lumMmx2Filter, c->lumMmx2FilterPos, 8); initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->chrMmx2Filter, c->chrMmx2FilterPos, 4); + +#ifdef MAP_ANONYMOUS + mprotect(c->lumMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE, PROT_EXEC | PROT_READ); + mprotect(c->chrMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE, PROT_EXEC | PROT_READ); +#endif } #endif /* defined(COMPILE_MMX2) */ } // initialize horizontal stuff |