Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Rémi Denis-Courmont" <remi@remlab.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avformat/file: add fd protocol
Date: Tue, 13 Dec 2022 18:27:59 +0200
Message-ID: <3165914.Kgj5vkvPNt@basile.remlab.net> (raw)
In-Reply-To: <tencent_7E023D68FA7FBEAF3E3A41C0DDB76C69420A@qq.com>

Le maanantaina 12. joulukuuta 2022, 19.23.52 EET Zhao Zhili a écrit :
> On Mon, 2022-12-12 at 18:31 +0200, Rémi Denis-Courmont wrote:
> > Le maanantaina 5. joulukuuta 2022, 4.51.34 EET zhilizhao(赵志立) a écrit
> > 
> > > > On Nov 19, 2022, at 02:48, Zhao Zhili <quinkblack@foxmail.com>
> > > > wrote:
> > > > 
> > > > From: Zhao Zhili <zhilizhao@tencent.com>
> > > > 
> > > > Unlike the pipe protocol, fd protocol has seek support if it
> > > > corresponding to a regular file.
> > > > ---
> > > > Sometimes it's the only way to access files via file descriptor,
> > > > e.g.,
> > > > requesting a shared file on Android:
> > > > https://developer.android.com/training/secure-file-sharing/request-fil
> > > > e
> > > > 
> > > > doc/protocols.texi      | 24 +++++++++++++++++++
> > > > libavformat/Makefile    |  1 +
> > > > libavformat/file.c      | 51
> > > > +++++++++++++++++++++++++++++++++++++++++
> > > > libavformat/protocols.c |  1 +
> > > > libavformat/version.h   |  4 ++--
> > > > 5 files changed, 79 insertions(+), 2 deletions(-)
> > > 
> > > Ping for review.
> > 
> > VLC does this (with a slightly different syntax, i.e. fd://$NUM) and
> > in
> > hindsight, I think that it was a big mistake.
> > 
> > It should not be possible to refer to an opaque handle from within
> > the URL.
> > This leads to all sorts of mischief, bordering on security issue, in
> > the
> > common case that the URL string is untrusted.
> 
> Could you elaborate on the security issue?

Just guess the FD of some critical process resource (.e.g D-Bus, X11 or 
Wayland connection), , and you can easily cause a DoS. It gets potentially 
worse if you can guess the FD that is used to carry sensitive data, such as 
another clients connection if FFmpeg runs inside some kind of network service.

> > To support this use case, IMO, the file descriptor should be passed
> > explicitly
> > via a trusted channel, *not* the URL.
> 
> Does an explicit option works here?
> 
>  static const AVOption pipe_options[] = {
>      { "blocksize", "set I/O operation maximum block size",
> offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX },
> 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
> +    { "fd", "set file descriptor", offsetof(FileContext, fd),
> AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM
> },
>      { NULL }
>  };

That seems more reasonable, so I cannot comment on the specifics of AVOption 
usage.


-- 
Реми Дёни-Курмон
http://www.remlab.net/



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-12-13 16:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 18:48 Zhao Zhili
2022-12-05  2:51 ` "zhilizhao(赵志立)"
2022-12-08 15:11   ` Zhao Zhili
2022-12-08 15:16     ` Marvin Scholz
2022-12-08 15:28       ` Andreas Rheinhardt
2022-12-08 16:16         ` Zhao Zhili
2022-12-12 16:31   ` Rémi Denis-Courmont
2022-12-12 17:23     ` Zhao Zhili
2022-12-13 16:27       ` Rémi Denis-Courmont [this message]
2022-12-09 14:31 ` Anton Khirnov
2022-12-10 13:45   ` Zhao Zhili

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=3165914.Kgj5vkvPNt@basile.remlab.net \
    --to=remi@remlab.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /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

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git