Skip to content

Commit 8434f9a

Browse files
John Sperbeckakpm00
authored andcommitted
init: open output files from cpio unpacking with O_LARGEFILE
If a member of a cpio archive for an initrd or initrams is larger than 2Gb, we'll eventually fail to write to that file when we get to that limit, unless O_LARGEFILE is set. The problem can be seen with this recipe, assuming that BLK_DEV_RAM is not configured: cd /tmp dd if=/dev/zero of=BIGFILE bs=1048576 count=2200 echo BIGFILE | cpio -o -H newc -R root:root > initrd.img kexec -l /boot/vmlinuz-$(uname -r) --initrd=initrd.img --reuse-cmdline kexec -e The console will show 'Initramfs unpacking failed: write error'. With the patch, the error is gone. Link: https://lkml.kernel.org/r/20240323152934.3307391-1-jsperbeck@google.com Signed-off-by: John Sperbeck <jsperbeck@google.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 65291dc commit 8434f9a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static int __init do_name(void)
367367
if (S_ISREG(mode)) {
368368
int ml = maybe_link();
369369
if (ml >= 0) {
370-
int openflags = O_WRONLY|O_CREAT;
370+
int openflags = O_WRONLY|O_CREAT|O_LARGEFILE;
371371
if (ml != 1)
372372
openflags |= O_TRUNC;
373373
wfile = filp_open(collected, openflags, mode);

0 commit comments

Comments
 (0)