# Re: \[PATCH v7 02/10\] fs: add O\_ALLOW\_ENCODED open flag

- From: Josef Bacik \<josef@toxicpanda.com\>
- Date: 2021-01-25 20:59:13 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2021/01/198318
- Thread: https://ratatoskr.run/linux-fsdevel/2021/01/198194/t.md

```text
On 1/22/21 3:46 PM, Omar Sandoval wrote:
> From: Omar Sandoval <redacted>
>
> The upcoming RWF_ENCODED operation introduces some security concerns:
>
> 1. Compressed writes will pass arbitrary data to decompression
>     algorithms in the kernel.
> 2. Compressed reads can leak truncated/hole punched data.
>
> Therefore, we need to require privilege for RWF_ENCODED. It's not
> possible to do the permissions checks at the time of the read or write
> because, e.g., io_uring submits IO from a worker thread. So, add an open
> flag which requires CAP_SYS_ADMIN. It can also be set and cleared with
> fcntl(). The flag is not cleared in any way on fork or exec.
>
> Note that the usual issue that unknown open flags are ignored doesn't
> really matter for O_ALLOW_ENCODED; if the kernel doesn't support
> O_ALLOW_ENCODED, then it doesn't support RWF_ENCODED, either.
>
> Signed-off-by: Omar Sandoval <redacted>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
```
