[regression, bisected] Bug 216738 - Adding O_APPEND to O_RDWR with fcntl(fd, F_SETFL) does not work on overlayfs

From: Thorsten Leemhuis
Date: Thu Nov 24 2022 - 10:48:05 EST


Hi, this is your Linux kernel regression tracker speaking.

I noticed a regression report in bugzilla.kernel.org. As many (most?)
kernel developer don't keep an eye on it, I decided to forward it by
mail. Quoting from https://bugzilla.kernel.org/show_bug.cgi?id=216738 :

> Pierre Labastie 2022-11-24 14:53:33 UTC
>
> Created attachment 303287 [details]
> C program for reproducing the bug
>
> Not sure this is the right place to report this, but at least the offending commit

[offending commit is 164f4064ca8 ("keep iocb_flags() result cached in
struct file"), as specified in the "Kernel Version:" field in bugzilla]

> is in this component...
>
> Steps to reproduce:
> $ gcc repro.c
> $ rm -f toto
> $ ./a.out
> $ cat toto; echo
>
> On an ext4 fs, the output is (on all versions):
> abcdefghijklmnopqr
>
> Now, make an overlayfs:
> $ mkdir -p up lo wo mnt
> $ sudo mount -t overlay overlay -oupperdir=up,lowerdir=lo,workdir=wo mnt
> $ cd mnt
> $ rm f toto
> $ ../a.out
> $ cat toto; echo
>
> before the said commit, the output is:
> abcdefghijklmnopqr
>
> after the said commit, the output is:
> ghijklmnopqr
>
> That is the file is truncated when opened with O_RDWR, with O_APPEND added later, but not when opened with both.

See the ticket for more details.

BTW, let me use this mail to also add the report to the list of tracked
regressions to ensure it's doesn't fall through the cracks:

#regzbot introduced: 164f4064ca8
https://bugzilla.kernel.org/show_bug.cgi?id=216738
#regzbot ignore-activity

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)

P.S.: As the Linux kernel's regression tracker I deal with a lot of
reports and sometimes miss something important when writing mails like
this. If that's the case here, don't hesitate to tell me in a public
reply, it's in everyone's interest to set the public record straight.