Midori fills /tmp with html5 videos
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Midori Web Browser |
Incomplete
|
Undecided
|
Unassigned | ||
WebKit |
Fix Released
|
Medium
|
Bug Description
When Midori plays an html5 video from the web, it seems to save a copy to /tmp with filenames like "midori4-733L0W". These files will eventually fill the filesystem because they aren't automatically deleted in some cases (e.g. if Midori crashes).
To reproduce, play a video like http://
gue5t gue5t (gue5t) wrote : | #2 |
Likely /tmp is the fallback for unset XDG_CACHE_HOME as I have in my current setup--strange, given that the basedir spec says $HOME/.cache should be used--but that's immaterial.
The real issue is a user-experience one: when we crash (fairly often, unfortunately), we leave behind a lot of potentially large video files, and disk or tmpfs space can disappear with midori implicated as the culprit. I don't know if webkit can do much about this, since it doesn't know about application lifetimes but maybe we should push it upstream just in case they can. Or maybe we can get webkit to namespace these temporary files to the midori config dir (e.g put them in a subdir that's a hash of the config path?) and delete the config dir's old ones on startup.
In bugs.webkit.org/ #119477, Pnormand (pnormand) wrote : | #4 |
Right now preloaded videos go to ~/.cache but they should be stored in the webkit's cache folder instead.
The cache location can be configured using queue2:
Changed in webkit-open-source: | |
importance: | Unknown → Medium |
status: | Unknown → Confirmed |
In bugs.webkit.org/ #119477, Sebastian Dröge (slomo) wrote : | #5 |
It currently is impossible to do that properly, best solution would probably be to expose that queue2 property on uridecodebin and playbin.
gue5t gue5t (gue5t) wrote : | #3 |
I can no longer reproduce this with WebkitGTK+ 2.4.8.
Changed in midori: | |
status: | New → Incomplete |
In bugs.webkit.org/ #119477, Cgarcia-f (cgarcia-f) wrote : | #6 |
Is that cache permanent? I mean, can it be reused among sessions? Otherwise I don't think it should be stored in the home dir at all, but in /tmp
In bugs.webkit.org/ #119477, Claudio Saavedra (csaavedra) wrote : | #7 |
Carlos nailed it. If it cannot be reused between sessions then it doesn't belong in .cache.
In bugs.webkit.org/ #119477, Sebastian Dröge (slomo) wrote : | #8 |
It can be used between sessions if webkit gives an appropriate name to the files IIRC. But yes, it should probably go into g_get_tmp_dir(). Main problem with that is that some people put /tmp on a tmpfs... so if you want to watch a long enough movie, your memory runs full.
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #9 |
(In reply to comment #4)
> It can be used between sessions if webkit gives an appropriate name to the
> files IIRC. But yes, it should probably go into g_get_tmp_dir(). Main
> problem with that is that some people put /tmp on a tmpfs... so if you want
> to watch a long enough movie, your memory runs full.
/tmp on tmpfs has been default in Fedora for several years now... I was amazed quite recently to learn that other distros are still not doing this. Anyway, the videos would have to go in /var/tmp since they are big. But /var/tmp is not cleaned automatically, so there needs to be some measure to clean up leaked videos in the event of a web process crash.
In bugs.webkit.org/ #119477, Pnormand (pnormand) wrote : | #10 |
The UIProcess is notified when the WebProcess crashes, so perhaps we could do the clean-up at that moment.
In bugs.webkit.org/ #119477, Sebastian Dröge (slomo) wrote : | #11 |
Or you could make the videos actually cacheable so they can be reused in future sessions until cleared from the cache ;)
Cleaning up from the webprocess crashes would mean that you need to have a way to identify which files belong to the pid of the crashed process
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #12 |
Note that we've gotten multiple reports of ~/.cache rising to excessive size; apparently there is no way to clean up cached video files if there is a web process crash.
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #13 |
CCing some media folks... how do we want to go about solving this?
Anything cached should go under WebKitWebsiteDa
Note that we have to be robust to UI process crashes as well. That happens. We are already careful to never leak in the normal disk cache.
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #14 |
Probably bug #156369 needs to be fixed at the same time as this.
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #15 |
(Changing component just so that we can find this bug again.)
In bugs.webkit.org/ #119477, carloslp (carloslp) wrote : | #16 |
(In reply to comment #5)
> (In reply to comment #4)
> > It can be used between sessions if webkit gives an appropriate name to the
> > files IIRC. But yes, it should probably go into g_get_tmp_dir(). Main
> > problem with that is that some people put /tmp on a tmpfs... so if you want
> > to watch a long enough movie, your memory runs full.
>
> /tmp on tmpfs has been default in Fedora for several years now... I was
> amazed quite recently to learn that other distros are still not doing this.
> Anyway, the videos would have to go in /var/tmp since they are big. But
> /var/tmp is not cleaned automatically, so there needs to be some measure to
> clean up leaked videos in the event of a web process crash.
I suggest removing the file just after opening it for write.
That way you can continue to use the file for reading or writing to it, by passing the file descriptor id.
The kernel will automatically remove the file once the descriptor id is closed or the process holding the file descriptor id dies (crashes or exits)
So you not longer have to take care of cleaning the files. The file will be automatically cleaned when you not longer use it.
In bugs.webkit.org/ #119477, carloslp (carloslp) wrote : | #17 |
(In reply to comment #5)
> (In reply to comment #4)
> > It can be used between sessions if webkit gives an appropriate name to the
> > files IIRC. But yes, it should probably go into g_get_tmp_dir(). Main
> > problem with that is that some people put /tmp on a tmpfs... so if you want
> > to watch a long enough movie, your memory runs full.
>
> /tmp on tmpfs has been default in Fedora for several years now...
Personally, I don't think /tmp on tmpfs is a good idea.
In the worst case (you have configured your system without swap) you end wasting precious memory space for tmp files. Which is nuts.
In the best case, you end wasting swap space and risking incurring in more swappiness related freezes than otherwise you would have.
/tmp on tmpfs supporters main argument was they were worried about incrementing their SSD wearing level more than needed. This has been exaggerated a lot. I still have to find anyone that has nuked their SSD because of not having /tmp on tmpfs.
Related:
https:/
https:/
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #18 |
(In reply to comment #5)
> (In reply to comment #4)
> > It can be used between sessions if webkit gives an appropriate name to the
> > files IIRC. But yes, it should probably go into g_get_tmp_dir(). Main
> > problem with that is that some people put /tmp on a tmpfs... so if you want
> > to watch a long enough movie, your memory runs full.
>
> /tmp on tmpfs has been default in Fedora for several years now... I was
> amazed quite recently to learn that other distros are still not doing this.
> Anyway, the videos would have to go in /var/tmp since they are big. But
> /var/tmp is not cleaned automatically, so there needs to be some measure to
> clean up leaked videos in the event of a web process crash.
A naive suggestion would be to treat /var/tmp as system storing /tmp on disk treat it. Those systems clean /tmp on boot. My suggestion is to use /var/tmp/
More efficient approaches can be implemented on top of that, but I think this one could be fine as a baseline.
In bugs.webkit.org/ #119477, Adrian Perez (aperezdc) wrote : | #19 |
(In reply to comment #12)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > It can be used between sessions if webkit gives an appropriate name to the
> > > files IIRC. But yes, it should probably go into g_get_tmp_dir(). Main
> > > problem with that is that some people put /tmp on a tmpfs... so if you want
> > > to watch a long enough movie, your memory runs full.
> >
> > /tmp on tmpfs has been default in Fedora for several years now... I was
> > amazed quite recently to learn that other distros are still not doing this.
> > Anyway, the videos would have to go in /var/tmp since they are big. But
> > /var/tmp is not cleaned automatically, so there needs to be some measure to
> > clean up leaked videos in the event of a web process crash.
This is not necessarily true, many (most?) GNU/Linux distributions clean
“/var/tmp”:
% grep '/var/tmp ' /usr/lib/
q /var/tmp 1777 root root 30d
%
Still, using “/var/tmp” is not a good option because many systems are known
*not to* clean it by default ({Free,
expected to clean up after themselves when creating files under ”/var/tmp”.
> I suggest removing the file just after opening it for write.
+1
If we can make GStreamer happy without having named files, passing the FD
around is the absolute best option.
> That way you can continue to use the file for reading or writing to it, by
> passing the file descriptor id.
>
> The kernel will automatically remove the file once the descriptor id is
> closed or the process holding the file descriptor id dies (crashes or exits)
>
> So you not longer have to take care of cleaning the files. The file will be
> automatically cleaned when you not longer use it.
As an additional small side bonus unlinking the file after opening causes less name space pollution in the directory used for temporary files. Which reduces
contention for creating new temporary files — anyway this is most likely
irrelevant for web browsing, but still nice :)
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #20 |
(In reply to comment #15)
> This is not necessarily true, many (most?) GNU/Linux distributions clean
> “/var/tmp”:
You're right, systemd does this, even when the GNOME option to clean temporary files is disabled....
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #21 |
Today I tried to solve this by setting the temp-remove[1] property of GstDownloadBuffer to true, only to find that it's already true by default and that the "delete on READY" statement in the documentation doesnt refer to the NULL -> READY -> PAUSED -> PLAYING transition (ie: delete after creation), but to the PLAYING -> PAUSED -> READY -> NULL one (ie: delete on destruction, the current behaviour).
I guess I'll have to try a different approach and delete the file by myself.
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #22 |
Created attachment 300331
Patch
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #23 |
LGTM. Would be good for a GStreamer reviewer to review it. Please add it to https:/
In bugs.webkit.org/ #119477, Cgarcia-f (cgarcia-f) wrote : | #24 |
Comment on attachment 300331
Patch
View in context: https:/
> Source/
> + Files cached on disk by MediaPlayerPriv
> + WebProcess crashed, they're just left there in the cache directory. This patch changes the location
> + of those temporary files to a proper temporary directory (/var/tmp, as those files aren't actually
> + reusable, so they don't belong to a cache directory, and /tmp is a bad place because it's RAM-based on
> + some distros), unlinks (deletes) them right after creation and also deletes any other stalled temporary
> + file on the old legacy cache directory.
Wouldn't it be a problem if /var is in a different partition? I'm not sure if the solution to leaked files is placing them in /tmp to be honest. If we can decide the folder, then we can use a specific one in the user cache dir, and clean it up at startup, for example.
> Source/
> + if (!g_strcmp0(
Early return here instead.
> Source/
> + g_signal_
Use C++ style casts
> Source/
> + processName = "GStreamer";
shouldn't it be WebKitWebProcess by default?
> Source/
> + GUniquePtr<gchar> newDownloadTemp
Use g_build_filename
> Source/
> + player-
So, if we purge the old files, then we don't really need to use /var/tmp, no?
> Source/
> + g_signal_
Use C++ style cast
> Source/
> + GUniqueOutPtr<
> + g_object_
> + if (g_unlink(
> + GST_WARNING(
> + else
> + GST_TRACE("Unlinked media temporary file %s after creation", downloadFile.
Do we need a signal for this? Doesn't gst changes it when g_object_
> Source/
> + GDir* directory = g_dir_open(
> +
> + if (!directory)
> + return;
> +
> + for (const gchar* fileName = g_dir_read_
> + if (g_str_
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #25 |
(In reply to comment #20)
> Wouldn't it be a problem if /var is in a different partition?
Why would that be a problem?
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #26 |
Comment on attachment 300331
Patch
View in context: https:/
Thanks for the rest of the comments I'm not replying, they're really useful.
>> Source/
>> + file on the old legacy cache directory.
>
> Wouldn't it be a problem if /var is in a different partition? I'm not sure if the solution to leaked files is placing them in /tmp to be honest. If we can decide the folder, then we can use a specific one in the user cache dir, and clean it up at startup, for example.
I don't think GstDownloadBuffer is ready to reuse the media files between sessions with its current design, so as per https:/
I considered /var/tmp as the consensus solution for storing this kind of files. If it's not the consensus solution, then discuss it first among yourselves before requesting an implementation.
Having /var in a different partition is as problematic as having /home or /tmp in a different partition too. If the former hasn't been a problem until now, using /var shouldn't be a problem too.
>> Source/
>> + processName = "GStreamer";
>
> shouldn't it be WebKitWebProcess by default?
That's what g_get_prgname() should return, yes. In the very unlikely case that it returns NULL, I'm just defaulting to the same value that GstUriDecodeBin would:
https:/
>> Source/
>> + player-
>
> So, if we purge the old files, then we don't really need to use /var/tmp, no?
The "$HOME/.cache" vs. "/var/tmp" discussion was about if the files were considered as "cache" or as "temporary". It's the second, so they belong to a temporary directory.
This purging is here just for legacy files generated by WebKit prior to this patch. Michael told me that leaking those legacy files wasn't unacceptable. That's why I added the purge method.
Ideally, when all the users have migrated to a WebKit version having this patch, the purge shouldn't be needed anymore and might be removed.
>> Source/
>> + GST_TRACE("Unlinked media temporary file %s after creation", downloadFile.
>
> Do we need a signal for this? Doesn't gst changes it when g_object_
I don't understand this comment. GstDownloadBuffer was already removing the file when the element was destroyed (when destroying the player). That's not enough for us. We want to delete the file immediately after it's created.
The only way I found to get notified of the file cre...
In bugs.webkit.org/ #119477, Cgarcia-f (cgarcia-f) wrote : | #27 |
(In reply to comment #21)
> (In reply to comment #20)
> > Wouldn't it be a problem if /var is in a different partition?
>
> Why would that be a problem?
I don't know that's why I'm asking :-)
In bugs.webkit.org/ #119477, Cgarcia-f (cgarcia-f) wrote : | #28 |
(In reply to comment #22)
> Comment on attachment 300331 [details]
> Patch
>
> View in context:
> https:/
>
> Thanks for the rest of the comments I'm not replying, they're really useful.
>
> >> Source/
> >> + file on the old legacy cache directory.
> >
> > Wouldn't it be a problem if /var is in a different partition? I'm not sure if the solution to leaked files is placing them in /tmp to be honest. If we can decide the folder, then we can use a specific one in the user cache dir, and clean it up at startup, for example.
>
> I don't think GstDownloadBuffer is ready to reuse the media files between
> sessions with its current design, so as per
> https:/
> https:/
> considered "cache" but temporary files. They can be huge (eg: 2GB or similar
> movie sizes), so they aren't appropriate for /tmp (because of some distros
> using tmpfs) but they're appropriate for /var/tmp as per
> https:/
>
> I considered /var/tmp as the consensus solution for storing this kind of
> files. If it's not the consensus solution, then discuss it first among
> yourselves before requesting an implementation.
Ok, my fault, I tried to help reviewing this, but I didn't read the discussion first, there's even a comment by me suggesting not to use home cache dir :-P
> Having /var in a different partition is as problematic as having /home or
> /tmp in a different partition too. If the former hasn't been a problem until
> now, using /var shouldn't be a problem too.
Yes, sure, but it's more unlikely. Anyway, I only asked. I know, for example, that we write the partial download files in the same download directory instead of /tmp to avoid copies between partitions.
> >> Source/
> >> + processName = "GStreamer";
> >
> > shouldn't it be WebKitWebProcess by default?
>
> That's what g_get_prgname() should return, yes. In the very unlikely case
> that it returns NULL, I'm just defaulting to the same value that
> GstUriDecodeBin would:
>
> https:/
> gsturidecodebin
Because gst can't know in which process is running, but we know it.
> >> Source/
> >> + player-
> >
> > So, if we purge the old files, then we don't really need to use /var/tmp, no?
>
> The "$HOME/.cache" vs. "/var/tmp" discussion was about if the files were
> considered as "cache" or as "temporary". It's the second, so they belong to
> a temporary directory.
Right, ok.
> This purging is here just for legacy files generated by WebKit prior to this
> patch. Michael told me that leaking those legacy files wasn't unacceptable.
> That's why I added the purge method.
Ah, I see, I wonder if we should purge also leaked files from previous sessions too. That would solve the problem for systems where /var/tm...
In bugs.webkit.org/ #119477, Calvaris (calvaris) wrote : | #29 |
Comment on attachment 300331
Patch
View in context: https:/
Lots of comments and suggestions, let's see this patch again.
>> Source/
>> + const gchar* className = G_OBJECT_
>> + if (!g_strcmp0(
>
> Early return here instead.
Remove the variable because it is only used at the if. Besides, type should have been const char*.
> Source/
> + GUniqueOutPtr<
char
> Source/
> + const gchar* processName = g_get_prgname();
char
>>>> Source/
>>>> + processName = "GStreamer";
>>>
>>> shouldn't it be WebKitWebProcess by default?
>>
>> That's what g_get_prgname() should return, yes. In the very unlikely case that it returns NULL, I'm just defaulting to the same value that GstUriDecodeBin would:
>>
>> https:/
>
> Because gst can't know in which process is running, but we know it.
I am with Carlos here. We don't need the process name actually to name the temp file. I'd go for something like WebKit-
>> Source/
>> + GUniquePtr<gchar> newDownloadTemp
>
> Use g_build_filename
char.
Another thing is that I think we should ensure the files are created in a different directory for each user and ensure that directory has the proper permissions so that it cannot be access by anyone else other than the user. I think media people watch online can vary a lot from cats to other things. I'd write a function to return the template and ensure it is placed in the proper directory.
> Source/
> + GST_TRACE(
The \n is not advisable.
>>>> Source/
>>>> + player-
>>>
>>> So, if we purge the old files, then we don't really need to use /var/tmp, no?
>>
>> The "$HOME/.cache" vs. "/var/tmp" discussion was about if the files were considered as "cache" or as "temporary". It's the second, so they belong to a temporary directory.
>>
>> This purging is here just for legacy files generated by WebKit prior to this patch. Michael told me that leaking those legacy files wasn't unacceptable. That's why I added the purge method.
>>
>> Ideally, when all the users have migrated to a WebKit version having this patch, the purge shoul...
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #30 |
Comment on attachment 300331
Patch
View in context: https:/
>>> Source/
>>> + GUniquePtr<gchar> newDownloadTemp
>>
>> Use g_build_filename
>
> char.
>
> Another thing is that I think we should ensure the files are created in a different directory for each user and ensure that directory has the proper permissions so that it cannot be access by anyone else other than the user. I think media people watch online can vary a lot from cats to other things. I'd write a function to return the template and ensure it is placed in the proper directory.
This is tricky and, IMHO, not needed.
Having and extra directory under /var/tmp means that we would have to maintain (delete) that directory by ourselves. This is problematic because we can't use the elegant trick of deleting the file right after its creation to delete the directory. If several videos are being played at once by different WebProcesses a race condition can happen:
- Process A creates /var/tmp/$USER
- Process A creates WebKit-Media-123456 there
- Process B tries to create /var/tmp/$USER (but it's already created, no problem)
- Process A deletes WebKit-Media-123456 there and /var/tmp/$USER
- Process B creates WebKit-Media-ABCDEF there but... the directory doesn't exist anymore. ERROR!
Anyway, the directory itself isn't needed because the new temporary files are now deleted right after their creation. This means that no other processes can open them anymore, so there shouldn't be any concern regarding privacy. I've checked it by myself with a "while true; do ls /var/tmp; done" script.
>>>>> Source/
>>>>> + player-
>>>>
>>>> So, if we purge the old files, then we don't really need to use /var/tmp, no?
>>>
>>> The "$HOME/.cache" vs. "/var/tmp" discussion was about if the files were considered as "cache" or as "temporary". It's the second, so they belong to a temporary directory.
>>>
>>> This purging is here just for legacy files generated by WebKit prior to this patch. Michael told me that leaking those legacy files wasn't unacceptable. That's why I added the purge method.
>>>
>>> Ideally, when all the users have migrated to a WebKit version having this patch, the purge shouldn't be needed anymore and might be removed.
>>
>> Right, ok.
>
> Yep, this will purge the old files. I have a concern though for the files that fall under the GST_WARNING of line 1377 of not being able to unlink. Should we assume that is is very unlikely and forget (and trust distros to purge this from time to time)? Btw, if it is so unlikely, we can tag the decission as UNLIKELY().
Michael would say that WebKit should try hard to clean its own files. I don't think distros are going to mess with the contents of the user home dir, even for the .cache dir. Thanks for the UNLIKELY() suggestion, btw.
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #31 |
Created attachment 300398
Patch
In bugs.webkit.org/ #119477, Cgarcia-f (cgarcia-f) wrote : | #32 |
Comment on attachment 300398
Patch
View in context: https:/
> Source/
> +#include <WebCore/
Don't use <> since you are in WebCore.
> Source/
> + if (m_source && WEBKIT_
G_TYPE_
> Source/
> + g_signal_
What if it has been disconnected before? I think it would be better to save the handler id and use g_signal_
> Source/
> + if (g_strcmp0(
GST_IS_
> Source/
> + // Transform "-XXXXXX" into "-??????" to get a file wildcard expression from the template.
> + for (char* p = &templateFile.
> + *p = '?';
I'm not sure I understand this, maybe you can simply do g_strdelimit (templateFile.
Can't you pass something like "*-XXXXXX*" as pattern to listDirectory?
> Source/
> + for (auto filePath : listDirectory(
auto&
> Source/
> + if (m_source && WEBKIT_
G_TYPE_
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #33 |
(In reply to comment #25)
> Another thing is that I think we should ensure the files are created in a
> different directory for each user and ensure that directory has the proper
> permissions so that it cannot be access by anyone else other than the user.
> I think media people watch online can vary a lot from cats to other things.
> I'd write a function to return the template and ensure it is placed in the
> proper directory.
It should be sufficient to just create the files with 600 permission, right?
In bugs.webkit.org/ #119477, Calvaris (calvaris) wrote : | #34 |
Comment on attachment 300398
Patch
View in context: https:/
> Source/
> + if (m_source && WEBKIT_
You don't need the m_source && as WEBKIT_IS_WEB_SRC checks for nulls as expected.
> Source/
> + GUniqueOutPtr<char> oldDownloadTemp
> + g_object_
> +
> + GUniquePtr<char> newDownloadTemp
> + g_object_
> + GST_TRACE(
Nit: you can move getting oldDownloadTemplate after setting newDownloadTemplate (it is going to be actually used before the GST_TRACE and specially relevant for the purge).
Another nit: "Reconfigured" is better because the relevant action already happened.
> Source/
> + // Transform "-XXXXXX" into "-??????" to get a file wildcard expression from the template.
> + for (char* p = &templateFile.
> + *p = '?';
Maybe you can use String::replace instead of doing this (it can take position and length.
> Source/
> + if (m_source && WEBKIT_
You don't need the m_source && as WEBKIT_IS_WEB_SRC checks for nulls as expected.
In bugs.webkit.org/ #119477, Calvaris (calvaris) wrote : | #35 |
(In reply to comment #26)
> > Another thing is that I think we should ensure the files are created in a different directory for each user and ensure that directory has the proper permissions so that it cannot be access by anyone else other than the user. I think media people watch online can vary a lot from cats to other things. I'd write a function to return the template and ensure it is placed in the proper directory.
>
> This is tricky and, IMHO, not needed.
>
> Having and extra directory under /var/tmp means that we would have to
> maintain (delete) that directory by ourselves. This is problematic because
> we can't use the elegant trick of deleting the file right after its creation
> to delete the directory. If several videos are being played at once by
> different WebProcesses a race condition can happen:
>
> - Process A creates /var/tmp/$USER
> - Process A creates WebKit-Media-123456 there
> - Process B tries to create /var/tmp/$USER (but it's already created, no
> problem)
> - Process A deletes WebKit-Media-123456 there and /var/tmp/$USER
> - Process B creates WebKit-Media-ABCDEF there but... the directory doesn't
> exist anymore. ERROR!
>
> Anyway, the directory itself isn't needed because the new temporary files
> are now deleted right after their creation. This means that no other
> processes can open them anymore, so there shouldn't be any concern regarding
> privacy. I've checked it by myself with a "while true; do ls /var/tmp; done"
> script.
Well, I don't think deleting the directory is needed, it is just 4k on disk.
> > Yep, this will purge the old files. I have a concern though for the files that fall under the GST_WARNING of line 1377 of not being able to unlink. Should we assume that is is very unlikely and forget (and trust distros to purge this from time to time)? Btw, if it is so unlikely, we can tag the decission as UNLIKELY().
>
> Michael would say that WebKit should try hard to clean its own files. I
> don't think distros are going to mess with the contents of the user home
> dir, even for the .cache dir. Thanks for the UNLIKELY() suggestion, btw.
I think I wasn't clear here. Line 1377, if the regular unlink fails (not the purge one, the regular) we are leaking them (under /var/tmp/).
In bugs.webkit.org/ #119477, Calvaris (calvaris) wrote : | #36 |
Comment on attachment 300398
Patch
View in context: https:/
>> Source/
>> + GST_TRACE(
>
> Nit: you can move getting oldDownloadTemplate after setting newDownloadTemplate (it is going to be actually used before the GST_TRACE and specially relevant for the purge).
>
> Another nit: "Reconfigured" is better because the relevant action already happened.
Forget this, it is wrong.
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #37 |
Comment on attachment 300398
Patch
View in context: https:/
>> Source/
>> + g_signal_
>
> What if it has been disconnected before? I think it would be better to save the handler id and use g_signal_
If the callback has been disconnected before, then g_signal_
>> Source/
>> + if (g_strcmp0(
>
> GST_IS_
Sorry, that's not possible. GstDownloadBuffer is an element, and as such, comes from a dynamically loaded plugin. It seems that the gstdownloadbuffer.h header isn't distributed for usage from third party applications. If I can't find it in WebKit/
>>> Source/
>>> + *p = '?';
>>
>> I'm not sure I understand this, maybe you can simply do g_strdelimit (templateFile.
>>
>> Can't you pass something like "*-XXXXXX*" as pattern to listDirectory?
>
> Maybe you can use String::replace instead of doing this (it can take position and length.
Carlos: It doesn't work like that. "X" isn't an actual letter X, but the character g_mkstemp()[1] uses as wildcard to construct actual random filenames. That character is equivalent to "?" in shell glob syntax.
Now that I think about it, if we're comfident about what the legacy base name was ("WebKitWebProc
[1] https:/
In bugs.webkit.org/ #119477, Calvaris (calvaris) wrote : | #38 |
After discussing in private I think the best solution because of permissions is sticking to ~/.cache/ but ensuring deleting and purge of old files. I guess a new patch would be needed.
In bugs.webkit.org/ #119477, carloslp (carloslp) wrote : | #39 |
(In reply to comment #34)
> After discussing in private I think the best solution because of permissions
> is sticking to ~/.cache/ but ensuring deleting and purge of old files. I
> guess a new patch would be needed.
Why you can't you apply there the same approach of unlinking the file just after its created? Its simpler to implement and more robust.
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #40 |
(In reply to comment #34)
> After discussing in private I think the best solution because of permissions
> is sticking to ~/.cache/ but ensuring deleting and purge of old files. I
> guess a new patch would be needed.
I've checked it (after adding a hack to avoid removing the file, normally external processes can't see it), and the file permissions are "600":
1605111 81156 -rw------- 1 enrique enrique 83103373 Feb 2 19:33 WebKit-Media-VPHGVY
Having this into account, there's no reason why plain /var/tmp is a bad idea, and there are several reasons why it's a good idea (as per the "cache" vs. "temporary" file discussion in previous comments).
In bugs.webkit.org/ #119477, Calvaris (calvaris) wrote : | #41 |
(In reply to comment #35)
> Why you can't you apply there the same approach of unlinking the file just
> after its created? Its simpler to implement and more robust.
Probably I wasn't clear enough but my proposal implied this inside WebKit code the problem was a possible permissions race condition between creation and deletion.(In reply to comment #36)
> (In reply to comment #34)
> I've checked it (after adding a hack to avoid removing the file, normally
> external processes can't see it), and the file permissions are "600":
>
> 1605111 81156 -rw------- 1 enrique enrique 83103373 Feb 2 19:33
> WebKit-Media-VPHGVY
>
> Having this into account, there's no reason why plain /var/tmp is a bad
> idea, and there are several reasons why it's a good idea (as per the "cache"
> vs. "temporary" file discussion in previous comments).
Then I think we would be good to go once you fix the less serious comments such as extra null checks, chars replacing, etc.
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #42 |
(In reply to comment #31)
> (In reply to comment #26)
> > > Yep, this will purge the old files. I have a concern though for the files that fall under the GST_WARNING of line 1377 of not being able to unlink. Should we assume that is is very unlikely and forget (and trust distros to purge this from time to time)? Btw, if it is so unlikely, we can tag the decission as UNLIKELY().
> >
> > Michael would say that WebKit should try hard to clean its own files. I
> > don't think distros are going to mess with the contents of the user home
> > dir, even for the .cache dir. Thanks for the UNLIKELY() suggestion, btw.
>
> I think I wasn't clear here. Line 1377, if the regular unlink fails (not the
> purge one, the regular) we are leaking them (under /var/tmp/).
Trying to purge leaked files in the new /var/tmp location doesn't make sense. If the files couldn't be deleted right after creation in the first place (because of a race condition with permissions, where some malicious (root?) process changes the permissions in the milisecond that the file is visible), then ther's no point on trying to delete the file later: the deletion will also fail for the same reasons it failed initially.
Purging files in the old location still makes sense, because with the old implementation more time passed from file creation to file deletion (eg: 2h until the movie finishes being played) and the probability of a crash or kill (the only reason why the file would have been leaked) was higher.
In bugs.webkit.org/ #119477, eocanha (eocanha) wrote : | #43 |
Created attachment 300517
Patch
In bugs.webkit.org/ #119477, Commit-queue (commit-queue) wrote : | #44 |
Comment on attachment 300517
Patch
Clearing flags on attachment: 300517
Committed r211627: <http://
In bugs.webkit.org/ #119477, Commit-queue (commit-queue) wrote : | #45 |
All reviewed patches have been landed. Closing bug.
In bugs.webkit.org/ #119477, Mcatanzaro (mcatanzaro) wrote : | #46 |
\o/
Kinda a shame that this went in with a misleading commit name, since the media is most definitely not being stored in WebKit's cache, but oh well.
In bugs.webkit.org/ #119477, carloslp (carloslp) wrote : | #47 |
Storing this big media files on the homedir is a potentially performance problem on systems where the home-dir is mounted over a shared network file-system (like happens on many shared computers at places like universities)
I think /var/tmp is the right place for this. This directory will be served from local storage, and never from a network file-system.
Also, the possibility of an attacker opening the file in the millisecond that happens between the file is created and the file is unlinked are pretty low.
Adding that to the fact that videos you watch on your browser is not something that I would consider critical information (like a password).
If you are that kind of person, is better you ensure that you are not sharing your computer with anyone when you watch the videos, rating than expecting WebKitGTK+ to do magic tricks to protect your privacy from the other users of your own computer.
So... I'm happy that in the end the simplest approach of storing the file on /var/tmp and unlink it was committed, and we didn't end creating an over-engineered solution to something I don't think is a real problem
Just my 2 cents.
Changed in webkit-open-source: | |
status: | Confirmed → Fix Released |
For me these files are stored in $XDG_CACHE_HOME - though I remember seeing them in /tmp in the past.
To my knowledge we're neither handling the playback nor setting a path. This should be resolved in WebKitGTK+.