From patchwork Thu Jan 2 23:06:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Manjarres X-Patchwork-Id: 13924998 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 AC6A5E77188 for ; Thu, 2 Jan 2025 23:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BFFA6B007B; Thu, 2 Jan 2025 18:07:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 970EA6B0082; Thu, 2 Jan 2025 18:07:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 810A96B0083; Thu, 2 Jan 2025 18:07:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 61D556B007B for ; Thu, 2 Jan 2025 18:07:06 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DC2F5C04C1 for ; Thu, 2 Jan 2025 23:07:05 +0000 (UTC) X-FDA: 82964047614.30.340F19A Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf22.hostedemail.com (Postfix) with ESMTP id 7E163C000D for ; Thu, 2 Jan 2025 23:06:11 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=2ovxWQ46; spf=pass (imf22.hostedemail.com: domain of 3Fhx3Zw4KCG0TdLLNXLYULccPdRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--isaacmanjarres.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3Fhx3Zw4KCG0TdLLNXLYULccPdRZZRWP.NZXWTYfi-XXVgLNV.ZcR@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=1735859200; 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=guOa2zF/oXdIvQGSrPjH0WRTPeMomNKFx5Ld2AuofNo=; b=4S8U2Dxz3I9eX4dSubsYZRUCmxI1d+tm2S2rGYN1IkKXUjEL2//QpfOKWAaBf0Ym6f6YIg ht7AhN6Dg3jhk1ddDd9x52jE5hHDereBK/KFm8Dq91vcccxK2OrDnQqRaTR+4yNesNzB4O rjB3xyeiQ3c2gMg+jcEXy7RxM480Hrc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735859200; a=rsa-sha256; cv=none; b=H3Quwnily7CW/Y16c2kJIGxofgnaVuZZ9zbhGZnySSQxCSnMryzekep+huNgDO00DnIdVm FY+ozNJQh9WYVOm4QuCxOz2aPDeMN59LJJYT3LcKsvYJm/0QeBS9ncNN47TeFaO+lLTRxs IErdJvHMu2poDJPYXJD99SgJr37KjV0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=2ovxWQ46; spf=pass (imf22.hostedemail.com: domain of 3Fhx3Zw4KCG0TdLLNXLYULccPdRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--isaacmanjarres.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3Fhx3Zw4KCG0TdLLNXLYULccPdRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-218cf85639eso262565285ad.3 for ; Thu, 02 Jan 2025 15:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1735859223; x=1736464023; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=guOa2zF/oXdIvQGSrPjH0WRTPeMomNKFx5Ld2AuofNo=; b=2ovxWQ46T8MLzc/Tu47+KCoyJVNFxEJD9vXrA+WwCpc7JtJ4G8GYIT3cHrhJgZ1ce+ 1KU1qdIR/cnjDF86JWNFGq873AAQZiCWZ73lHrK38vMGfb/CM+kcHN/HXKuJ9G3oElnu 8+g/RKYbDNQVrxn7e5Y4+ZaS7VKKBXZkdOzQFBWUDwfzue6+uC0DqDWDYg8rDgQUWm51 NzgsagvC9JKYDqiRBib+13Dvp9t/xSOKatIhEPUsjQHtPPs0z37FXZahz7AB4JaW5EwH JX7vTr4Q8WTsbWchABfjL31xSQkex5ktJ1rbtZbq1p+Vnn6yg5UY03dbHFRYuDGa+g/f CQag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735859223; x=1736464023; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=guOa2zF/oXdIvQGSrPjH0WRTPeMomNKFx5Ld2AuofNo=; b=uveQG4mvQfJtZivOPK7aD+5mwBWhHhg8/ZmX/FXvZWLt6/X3DKH4ZjXJ2qas7ZC+nx QxUeSJkWnXsjbNcp+gkxre879l5je8aNSu81aQZKfLo4u4jtF8ljPltFaWydfWW2LZD/ qEbQA6vnf5/YSqzEljojcGU4TNsY09+KwnIEscrISe2z842hIklcBBtpxyD4eL/tQBYg QXehpY16lRdW/nN66OtVFsSpXhBdVAlb/7hJOxIlBVfdV4RbnhuWTG3lR636c4UDVzVV IY+nB2ZMKULCEQhzwlhenpeZ7/brnBeXQaCkSL41WpGNFc4Cj7lSkmXK5aj8O2HhO4iZ D35Q== X-Forwarded-Encrypted: i=1; AJvYcCWqeMr1t1yzLGVvtiEgtTHEsLsNpYbKeGLhIpXlW9xcByqFtwFJBC0mUwNrNHjLMFi9N9aIaMsYog==@kvack.org X-Gm-Message-State: AOJu0Yy+Zaogs14JiNmfA8IT9V1VcN86hLM/Msfsx76DFKYQawlToRm+ aiWDnfKiL2NiCriqVf3CUTjbh5UFeckJ4mZ3/HgYMx4K7DCpsHcLMpKdkou+z0/gSCYGjS6arOZ W5HMzKPNyZBLYyqB6BIT7/K3ch9s4dOHKHA== X-Google-Smtp-Source: AGHT+IHt/rsWTQVzHNosVtiQL5lwhWuJ6/sbpbbChlk5GYTSOWFsE/CTt0Znbbo8n8j5cmTbRLUT0cECIt2qWac7qBPNMg== X-Received: from pgbcr10.prod.google.com ([2002:a05:6a02:410a:b0:801:d783:5f1e]) (user=isaacmanjarres job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:841a:b0:1db:eead:c588 with SMTP id adf61e73a8af0-1e5e080dc85mr76282683637.29.1735859222596; Thu, 02 Jan 2025 15:07:02 -0800 (PST) Date: Thu, 2 Jan 2025 15:06:53 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250102230658.1112261-1-isaacmanjarres@google.com> Subject: [PATCH v1 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: rspam10 X-Rspamd-Queue-Id: 7E163C000D X-Stat-Signature: 5rqwnibpu86rbep79bhrf8fnhbzdc1qa X-Rspam-User: X-HE-Tag: 1735859171-694955 X-HE-Meta: U2FsdGVkX1+IbocFsjqkWhqNZ2s5ox/HrTV+MHIRoOcFvOX//2+9nUW33QOQHUgl2rOy7OqKu4BgtJiu9bj6Ij7XrDPr9zJwxVN2lBIoA4YwtiTYTw7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3LxWvWM3ArEqx7gVQG/cjRnG5C8DTj8SqCIvvj5D73HmuebA39jN5dWqQwUfCXcRuaOFV9AZ+rXfPxpZ5iRywBevrMyLpfCv5DrMGf4TQfHwDWFZ30xgknB2xXSCggZfNwGBZEP3KAUt43k4MXpyVjyA/OVz6Mtm1x5jk2uGYsg2wyta+55vMPIHgFqxQN1/DPrRSYWcJILPOis3n02ua+AtlrtWkd5yRkbBvBRHHJyals5uNLRZWCTxzV06QuNj244RTrcyU/Nbjw+kBCM/PBAHbM9fpIcCXlvJOfFAQ0UplTrgT9tKuc3qNdklnMPNi+Bhk86BtmfUP3OLXoGEuQtrwkje9XhsrmlUOIPVTEGapdF/gIRwP4YzWHZKXKODqP/xWfh51edMT57fOryzfeNIWMkuDL7+1jhqsiNodV/YxO2QfCfkQKNWsjybsLGWPyEG3uvTZu8eM6DDmXhTEGmKec X-Bogosity: Unsure, tests=bogofilter, spamicity=0.498589, 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. 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(-)