diff mbox

[FFmpeg-devel] avutil/hwcontext_d3d11va: Use secure dlopen.

Message ID CAHVN4mjopJAg+jaC9_N_iNHjzL2p1_9Z3fvhf91pr0Lc-DviUw@mail.gmail.com
State Accepted
Headers show

Commit Message

Matt Oliver Dec. 30, 2019, 4:02 p.m. UTC
dlopen contains additional security to prevent dll hijacking compared to
standard LoadLibrary.
---
 libavutil/hwcontext_d3d11va.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


@@ -55,8 +56,8 @@ static av_cold void load_functions(void)
     // from too many LoadLibrary calls.
     HANDLE d3dlib, dxgilib;

-    d3dlib  = LoadLibrary("d3d11.dll");
-    dxgilib = LoadLibrary("dxgi.dll");
+    d3dlib  = dlopen("d3d11.dll", 0);
+    dxgilib = dlopen("dxgi.dll", 0);
     if (!d3dlib || !dxgilib)
         return;

--

Comments

Andriy Gelman Dec. 30, 2019, 4:31 p.m. UTC | #1
On Tue, 31. Dec 03:02, Matt Oliver wrote:
> dlopen contains additional security to prevent dll hijacking compared to
> standard LoadLibrary.
> ---
>  libavutil/hwcontext_d3d11va.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> index 6670c47579..c8ae58f908 100644
> --- a/libavutil/hwcontext_d3d11va.c
> +++ b/libavutil/hwcontext_d3d11va.c
> @@ -39,6 +39,7 @@
>  #include "pixdesc.h"
>  #include "pixfmt.h"
>  #include "thread.h"
> +#include "compat/w32dlfcn.h"
> 
>  typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void
> **ppFactory);
> 
> @@ -55,8 +56,8 @@ static av_cold void load_functions(void)
>      // from too many LoadLibrary calls.
>      HANDLE d3dlib, dxgilib;
> 
> -    d3dlib  = LoadLibrary("d3d11.dll");
> -    dxgilib = LoadLibrary("dxgi.dll");
> +    d3dlib  = dlopen("d3d11.dll", 0);
> +    dxgilib = dlopen("dxgi.dll", 0);
>      if (!d3dlib || !dxgilib)
>          return;
> 
> --

Hello Matt, 

This patch doesn't apply:

error: corrupt patch at line 16
Patch failed at 0001 avutil/hwcontext_d3d11va: Use secure dlopen.

https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/patch/CAHVN4mjopJAg+jaC9_N_iNHjzL2p1_9Z3fvhf91pr0Lc-DviUw@mail.gmail.com/
Andriy Gelman Dec. 30, 2019, 4:37 p.m. UTC | #2
On Mon, 30. Dec 11:31, Andriy Gelman wrote:
> On Tue, 31. Dec 03:02, Matt Oliver wrote:
> > dlopen contains additional security to prevent dll hijacking compared to
> > standard LoadLibrary.
> > ---
> >  libavutil/hwcontext_d3d11va.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> > index 6670c47579..c8ae58f908 100644
> > --- a/libavutil/hwcontext_d3d11va.c
> > +++ b/libavutil/hwcontext_d3d11va.c
> > @@ -39,6 +39,7 @@
> >  #include "pixdesc.h"
> >  #include "pixfmt.h"
> >  #include "thread.h"
> > +#include "compat/w32dlfcn.h"
> > 
> >  typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void
> > **ppFactory);
> > 
> > @@ -55,8 +56,8 @@ static av_cold void load_functions(void)
> >      // from too many LoadLibrary calls.
> >      HANDLE d3dlib, dxgilib;
> > 
> > -    d3dlib  = LoadLibrary("d3d11.dll");
> > -    dxgilib = LoadLibrary("dxgi.dll");
> > +    d3dlib  = dlopen("d3d11.dll", 0);
> > +    dxgilib = dlopen("dxgi.dll", 0);
> >      if (!d3dlib || !dxgilib)
> >          return;
> > 
> > --
> 
> Hello Matt, 
> 
> This patch doesn't apply:
> 
> error: corrupt patch at line 16
> Patch failed at 0001 avutil/hwcontext_d3d11va: Use secure dlopen.
> 
> https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/patch/CAHVN4mjopJAg+jaC9_N_iNHjzL2p1_9Z3fvhf91pr0Lc-DviUw@mail.gmail.com/
> 

sorry, my git am failed because the patch was sent as text and an attachment.
Applying just one of them works.
Matt Oliver Jan. 11, 2020, 7:50 p.m. UTC | #3
On Tue, 31 Dec 2019 at 03:37, Andriy Gelman <andriy.gelman@gmail.com> wrote:

> On Mon, 30. Dec 11:31, Andriy Gelman wrote:
> > On Tue, 31. Dec 03:02, Matt Oliver wrote:
> > > dlopen contains additional security to prevent dll hijacking compared
> to
> > > standard LoadLibrary.
> > > ---
> > >  libavutil/hwcontext_d3d11va.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/libavutil/hwcontext_d3d11va.c
> b/libavutil/hwcontext_d3d11va.c
> > > index 6670c47579..c8ae58f908 100644
> > > --- a/libavutil/hwcontext_d3d11va.c
> > > +++ b/libavutil/hwcontext_d3d11va.c
> > > @@ -39,6 +39,7 @@
> > >  #include "pixdesc.h"
> > >  #include "pixfmt.h"
> > >  #include "thread.h"
> > > +#include "compat/w32dlfcn.h"
> > >
> > >  typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void
> > > **ppFactory);
> > >
> > > @@ -55,8 +56,8 @@ static av_cold void load_functions(void)
> > >      // from too many LoadLibrary calls.
> > >      HANDLE d3dlib, dxgilib;
> > >
> > > -    d3dlib  = LoadLibrary("d3d11.dll");
> > > -    dxgilib = LoadLibrary("dxgi.dll");
> > > +    d3dlib  = dlopen("d3d11.dll", 0);
> > > +    dxgilib = dlopen("dxgi.dll", 0);
> > >      if (!d3dlib || !dxgilib)
> > >          return;
> > >
> > > --
> >
> > Hello Matt,
> >
> > This patch doesn't apply:
> >
> > error: corrupt patch at line 16
> > Patch failed at 0001 avutil/hwcontext_d3d11va: Use secure dlopen.
> >
> >
> https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/patch/CAHVN4mjopJAg+jaC9_N_iNHjzL2p1_9Z3fvhf91pr0Lc-DviUw@mail.gmail.com/
> >
>
> sorry, my git am failed because the patch was sent as text and an
> attachment.
> Applying just one of them works.
>
> --
> Andriy
>

ping
Matt Oliver Feb. 9, 2020, 3:30 p.m. UTC | #4
final ping. If no objections still ill apply this later.

On Sun, 12 Jan 2020 at 06:50, Matt Oliver <protogonoi@gmail.com> wrote:

> On Tue, 31 Dec 2019 at 03:37, Andriy Gelman <andriy.gelman@gmail.com>
> wrote:
>
>> On Mon, 30. Dec 11:31, Andriy Gelman wrote:
>> > On Tue, 31. Dec 03:02, Matt Oliver wrote:
>> > > dlopen contains additional security to prevent dll hijacking compared
>> to
>> > > standard LoadLibrary.
>> > > ---
>> > >  libavutil/hwcontext_d3d11va.c | 5 +++--
>> > >  1 file changed, 3 insertions(+), 2 deletions(-)
>> > >
>> > > diff --git a/libavutil/hwcontext_d3d11va.c
>> b/libavutil/hwcontext_d3d11va.c
>> > > index 6670c47579..c8ae58f908 100644
>> > > --- a/libavutil/hwcontext_d3d11va.c
>> > > +++ b/libavutil/hwcontext_d3d11va.c
>> > > @@ -39,6 +39,7 @@
>> > >  #include "pixdesc.h"
>> > >  #include "pixfmt.h"
>> > >  #include "thread.h"
>> > > +#include "compat/w32dlfcn.h"
>> > >
>> > >  typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void
>> > > **ppFactory);
>> > >
>> > > @@ -55,8 +56,8 @@ static av_cold void load_functions(void)
>> > >      // from too many LoadLibrary calls.
>> > >      HANDLE d3dlib, dxgilib;
>> > >
>> > > -    d3dlib  = LoadLibrary("d3d11.dll");
>> > > -    dxgilib = LoadLibrary("dxgi.dll");
>> > > +    d3dlib  = dlopen("d3d11.dll", 0);
>> > > +    dxgilib = dlopen("dxgi.dll", 0);
>> > >      if (!d3dlib || !dxgilib)
>> > >          return;
>> > >
>> > > --
>> >
>> > Hello Matt,
>> >
>> > This patch doesn't apply:
>> >
>> > error: corrupt patch at line 16
>> > Patch failed at 0001 avutil/hwcontext_d3d11va: Use secure dlopen.
>> >
>> >
>> https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/patch/CAHVN4mjopJAg+jaC9_N_iNHjzL2p1_9Z3fvhf91pr0Lc-DviUw@mail.gmail.com/
>> >
>>
>> sorry, my git am failed because the patch was sent as text and an
>> attachment.
>> Applying just one of them works.
>>
>> --
>> Andriy
>>
>
> ping
>
diff mbox

Patch

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 6670c47579..c8ae58f908 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -39,6 +39,7 @@ 
 #include "pixdesc.h"
 #include "pixfmt.h"
 #include "thread.h"
+#include "compat/w32dlfcn.h"

 typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void
**ppFactory);