From nobody Sun May 24 19:33:17 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8D9819343E for ; Sat, 23 May 2026 13:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779541498; cv=none; b=uWbDbpGrKwPkT9bU5enDNLfK8GJslAlRE09jCpDOiWxHVMtXFp5legRKagW2pKF5G4Bqqn74DzJaDGZ2XTGRHeRYmowoiIkx1URqG7lAZhJ/ztm3DWhBaXtZKwmDhWnCTzOACzk7Ab5nYQHsYQoxGkDbayd501O5ByeGkWiTs8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779541498; c=relaxed/simple; bh=DRJjE9vsCXjdjxIStUsGvKLhsln60Vuu8YQDjDuAKmY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o4dGmRqDCATkVI6Dn7RC7c06MvCKrb3UG33KWWBnHyuTyhPinVkLH8T8Fq8QG2uCMA1M160xhyTLuQoCpsDRkHILb3TbMV58TOV5itADM1b91sl5jHhCSifGJ429TEo4uk56euWmb41oMUY2Srte/qpGWAQ0UD+Wj6WZR73Z9p4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=QIK115db; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="QIK115db" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2b458ca2296so60108945ad.0 for ; Sat, 23 May 2026 06:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1779541496; x=1780146296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qqdwlNXYZJEyRP9+E0HpJHlS8fNjZ4FkiE4ZdDF/FA8=; b=QIK115dbER1GhO5sPsXSDTmTQi7DyJAmn8pNoM1CKPa+EMgEFVaG3WenqluB4xbBd6 Mpqvpejk4fOsR/gYVikw/Dr/uu8V75gjO/DIkw049AOx/lCOITdkmJLYah5iveqm3hfu Viq4CwtIcNPRSOEGh/lTBNJpP9O492Shh2dxw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779541496; x=1780146296; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qqdwlNXYZJEyRP9+E0HpJHlS8fNjZ4FkiE4ZdDF/FA8=; b=SDgSPVqCynFHxzYMPa8tHxT3gRpEYZOPfzdmfvaV2TJCnoDeenljC86oGAb8FnxQwg AyBJcUkPJDgptBoVANIMmr7b2+IJ6s+RRavwJ8FY9mqkv1baUy+mC9iPvFJ927xXMDVb 9ZaKpTHsq4TSFcJI7OOM+hkQGudabpUFZ2vrqMAEr9ETPgcxXA2PFMpLOY7FmBGNMpw7 jMtv8JVUjhhJGBSzq4YuAWy3K2n+eX2ToTjlD6C0xWNseFMdf/wvkray2Z1KPwBlFC3+ 6APy80RPj98t0JObu36wp5ESBJkXeiypAjelnLJLwOBZqHCFuUccXgy3sPoKFuQKjtyo HUlg== X-Forwarded-Encrypted: i=1; AFNElJ9eeDtc77tFgGsF3L00ZsKyqvtkJs4s7c9VMQtqTo+cDwnb6cft+fIROVjQxp9C+9l4UqR5oj5N1q0gjHQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzkO7D0iUsREFG+DlJOzyHln5zbNIdIAxIupFGtTrI2bjo8aB9o SPy8k3/3BXfu8aPJT//G3Kc61JSi6saDx2B6CiKq2yLLZRq6I0Ni2amlJtqrwgq2gusIfgfHlkg slpNo X-Gm-Gg: Acq92OGmg9FCBB4QF/PrYxWx2RPorr12YLkeYfSqD9Vf8Y8QPQHt3ou9vMnZUUB3ieO f50DkxDUArTtkIFcf5tnPInl8gOgSiyExWQxI7AueXyzlArZZWQsmNbIOcRqeVutktdLGCHBuWd Wg6M0L/ITyw63tDYXeC0RKxs8aJBEF5OD2lpc/xh3horlLnkVt9GQA09/3r6KEufhxQYb6nC3Mc ygV67X3gbpMJQgW9DHsNzWV2kp5LTIEZJ8MopKBtElb/prxY6S3Lztyu9wzOwEFcHu6Tnig/eDU s5/8kjrOMU4ctblHwCYiqp/Sod77zEtSVUC6aho47EXX/7ix1PwSbxFlP1qKQ2DTL/n5+myri9/ 1Ly0FdWzXJmw/Ir9ijVSojy9WF1hYR1BO0BXAuWpbRFyyUD0spZ6tde7eqJVooKDYgOQUPvW/QR kXLgPFytyKTjBxIjNQC/dS/8Bm6brOk/yU9/czgkkUB2ntcexAVc115BheztYjowh2BaHQ+h+Pb BSHTBJ8V6/NCg== X-Received: by 2002:a17:903:19e8:b0:2b0:6e4a:32d0 with SMTP id d9443c01a7336-2beb06a6053mr85007925ad.35.1779541495768; Sat, 23 May 2026 06:04:55 -0700 (PDT) Received: from kinako.work.home.arpa (p1620034-ipxg00d01sizuokaden.shizuoka.ocn.ne.jp. [122.29.136.34]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2beb58c3016sm63173795ad.56.2026.05.23.06.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2026 06:04:53 -0700 (PDT) From: Daniel Palmer To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Daniel Palmer Subject: [PATCH] tmpfs/ramfs: Let memfd_create() work on nommu Date: Sat, 23 May 2026 22:04:45 +0900 Message-ID: <20260523130445.1101818-1-daniel@thingy.jp> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently trying to use memfd_create() on nommu returns an error with errno set to EFBIG. The manpage memfd_create() doesn't have EFBIG as a possible error value. Doing some digging this is coming from 0 getting passed as newsize to ramfs_nommu_expand_for_mapping() and that getting into get_order() and there "The result is undefined if the size is 0". Whatever comes out of get_order() is then used in the following logic and that results in the EFBIG that causes the syscall to fail and the errno in userspace. If newsize is 0 there is nothing to do so just return. Roughly tested on m68k nommu by creating a process, creating an memfd, forking another process, mmap()ing the memfd in the child, writing into the mapping, then mmap()ing in the parent and checking that the right data is there. Signed-off-by: Daniel Palmer --- Really not sure if this is correct. It works for me but on nommu a lot of things just work because there is no MMU to shout about badness. Maybe shashiko will say this is a dumb patch and explain the proper fix. :) Also I had almost no idea who to send this to from the output of get_maintainer.pl. fs/ramfs/file-nommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 2f79bcb89d2e..fb471bf88ab7 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c @@ -69,6 +69,9 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, s= ize_t newsize) gfp_t gfp =3D mapping_gfp_mask(inode->i_mapping); =20 /* make various checks */ + if (!newsize) + return 0; + order =3D get_order(newsize); if (unlikely(order > MAX_PAGE_ORDER)) return -EFBIG; --=20 2.53.0