From patchwork Tue Jan 7 18:48:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Isaac J. Manjarres" X-Patchwork-Id: 13929508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36F25E77198 for ; Tue, 7 Jan 2025 18:48:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A97146B009E; Tue, 7 Jan 2025 13:48:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A204E6B00A1; Tue, 7 Jan 2025 13:48:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C1216B00A2; Tue, 7 Jan 2025 13:48:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 694C76B009E for ; Tue, 7 Jan 2025 13:48:13 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F01E0120C4A for ; Tue, 7 Jan 2025 18:48:12 +0000 (UTC) X-FDA: 82981540824.09.5251B66 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf12.hostedemail.com (Postfix) with ESMTP id 386AF4000A for ; Tue, 7 Jan 2025 18:48:10 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=VPMs8rOv; spf=pass (imf12.hostedemail.com: domain of 36XZ9Zw4KCBAy8qqs2q3zq77u8w44w1u.s421y3AD-220Bqs0.47w@flex--isaacmanjarres.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=36XZ9Zw4KCBAy8qqs2q3zq77u8w44w1u.s421y3AD-220Bqs0.47w@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736275691; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=hRL0M0U/vnc7cmkGGFzOAnRVoTu/glJRgcDHjkmue0k=; b=H+MsiKvY04ccrPZiZVk2sw71XkzdlKfPniFp370LPCyLKqAxRhdbZQ6v/PtclXQ7761YXQ xk3v8DRow8iEc6UYPa/LUmE3zL+wZEbZOJJJTU9zLQEEhYG/a1lzSiz5Ywqoy0OLttTOmm /dL8KZaIvL1WAhdHKNTD3HeCmdMveVs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=VPMs8rOv; spf=pass (imf12.hostedemail.com: domain of 36XZ9Zw4KCBAy8qqs2q3zq77u8w44w1u.s421y3AD-220Bqs0.47w@flex--isaacmanjarres.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=36XZ9Zw4KCBAy8qqs2q3zq77u8w44w1u.s421y3AD-220Bqs0.47w@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736275691; a=rsa-sha256; cv=none; b=PToIZUg5z2cUJkK733cgZ6IXUE23wi+lsdcwweFxDukzZIoHf78+0tkLgjI8+FVa2mqShu NP+PsgRd6xfXJGp+QLKjjDEzI2fTMWOjXiCCP9t0yNVbvm663jtFHNLuQYXIF3PVSrqYHH 52j5nKc/50jYuGT9vHJVDFoiv0Y7e9I= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2163dc0f5dbso202539535ad.2 for ; Tue, 07 Jan 2025 10:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736275690; x=1736880490; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=hRL0M0U/vnc7cmkGGFzOAnRVoTu/glJRgcDHjkmue0k=; b=VPMs8rOvLaoURocOXuhRPCZ4cpduHAhRAO+5Xbv+N0/mjieZV9PSqwR9nDo3BwbaNd 4U0j9HWfWr9SrVAWF6vaGP/HxMk2XdahFKLO1BDo98qQIouJJojTyVnX2o2RxpP8Qc0l RfsuEw87C9LTsNA0CDLJ6UsORpJdECFg+TgYu2/HBVUyXpzCzagpYzNfNQA58FtiXZZ0 yzQrR2RlsEuod4l9TTWcdXYeep+xxtCKjJi7/FS/vVUxaSri3atNNr1CgoS4uq2I71p4 FipIRB+EzusLDCa5H6zy/h3eG3mKAtzlxdUVnQUyvhMTU7H7Mo4fRhSOcj8etYNVTnRO 8lRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736275690; x=1736880490; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=hRL0M0U/vnc7cmkGGFzOAnRVoTu/glJRgcDHjkmue0k=; b=t/AagmVvm3MNl3eMmaefW5y+GKf4/QHZ9VMbkMXaFRLWtdLdKwOySLZtg1DF0huIPZ kf5pVQBNMAGsqPR2l2y/J9gfKeYQQmoiZyZ0+p2KojKbJaIuQhKvnqsfcstCbERCimV3 Sru1YtTfEAVuk4s7XUNaEzzaW9Z4MReJYMKFMQaxiYqAndYgmw4YUNcWWs/o3UQJpw9K d44DtLlXCCAIIuraW7O4ZP4g9NQW6zEW0iXiks2n0IDGfygjnhkUstnGQeA1vVBtImv5 NnQnwQwUE4xaAzXA4EoaSJ71Yt3nKUDgsholxp7XqpP8GdTcn1kqnoBvK0MVKf3dJsxg zvvQ== X-Forwarded-Encrypted: i=1; AJvYcCX9tfa1ddp67wf4JMLeNQvXFI5Rmj4D0o2HWl9tqVWd6MHOAMFNt2bLscsDfFlNd28YevELvCMrcA==@kvack.org X-Gm-Message-State: AOJu0Yxott9++Svo9RpTXjfRznhyyOraMyb9P+fdmSKpWj8bRsRPBt2p gCSrOtcPSujYJ3sKUi/tG6RO7MDLRcmxqwG/B1qyrajZSh8t1F6l+/pEhYY120HVRPL0PJyseEj m+BUNnC7mpJGplRpAYEIBITUThebpgphfuA== X-Google-Smtp-Source: AGHT+IEf7i7Fy06FYm3/LqbQyo3vU9yI3b664wokhSmKj7gfT6Js8kRlJWUQBwiWoLXy5lIWvhR6Xkg8EomvjcHXiBXtNA== X-Received: from plbmm3.prod.google.com ([2002:a17:903:a03:b0:216:2234:bf3e]) (user=isaacmanjarres job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d490:b0:215:a7e4:8475 with SMTP id d9443c01a7336-21a83f5c148mr2274205ad.24.1736275689037; Tue, 07 Jan 2025 10:48:09 -0800 (PST) Date: Tue, 7 Jan 2025 10:48:00 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250107184804.4074147-1-isaacmanjarres@google.com> Subject: [PATCH v2 0/2] Cleanup for memfd_create() From: "Isaac J. Manjarres" To: lorenzo.stoakes@oracle.com, Andrew Morton Cc: kaleshsingh@google.com, jstultz@google.com, aliceryhl@google.com, surenb@google.com, "Isaac J. Manjarres" , kernel-team@android.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 386AF4000A X-Rspam-User: X-Stat-Signature: iidfm3yxhnuqsmx7g5epw3rf6nu35roc X-HE-Tag: 1736275690-643044 X-HE-Meta: U2FsdGVkX1+gRnJ8Z1r1wVajympxeY4aSz+vfsZ43lcujG2Wb0UjYO+T7p/XPA/R80fcUwyMh9+OVa1OoDM5WiObIVa/zV442qYr9/0ZnT3BQt+7xFfo2mLpELzocnG2D/hViL3TsiobazEOyVkOy8En6TVV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rtJleR8ZEZXLULLrv0y9l0ANPyEOxppN06S9EJilPhUU+v43KQ7kqRrbZSTrvog/Ee3UepkFyt0vQkrLuB0P0Y6d9Rh/U+gSaGqam6zdDg1O0T0RzZjdoEnyc13Km8N6Z5OAYjcCXXGczZXsU+6Pw1Yu/BG+PFocRD3m/+kWhHw5+43mPEvh11SfzOwqIfwJeE/4O2gs5SxJ/+Ao0xc5km+EMRQask6D4SFduN/6uqYe1EAqQRUFILdLHzo4JWCzVNORjLStNBbk+rSkATCbdQ77vpb4hLkeM+Nw8dGNVTR5fgZVZa54oS21XVYi20bdy8BU/hVOgPbOjmbpHCgOaJfquKfy+HhNbkuEt6IG3pYkYJe5UYl+aUP4HUn3qu7K+X1+JIKVtik7IjhHVwyf+v9IpF2SETWU2vbNPaZUkT6wGSbj2YrnRjcrmBqgqY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.444953, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: memfd_create() handles all of its logic in a single function. Some of the logic in the function is also somewhat contrived (i.e. copying the memfd name from userpace). This series aims to cleanup memfd_create() by splitting out the logic into helper functions, and simplifying the memfd name copying to make the code easier to follow. This has no intended functional changes. Changes from v1 ==> v2: - Rebased on top of the mm-unstable branch instead of Linus' master branch. Base commit on mm-unstable: ca95745c20ad ("mm/memmap: prevent double scanning of memmap by kmemleak"). Links: v1: https://lore.kernel.org/all/20250102230658.1112261-1-isaacmanjarres@google.com/#t Isaac J. Manjarres (2): mm/memfd: Refactor and cleanup the logic in memfd_create() mm/memfd: Use strncpy_from_user() to read memfd name mm/memfd.c | 101 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 42 deletions(-)