From patchwork Mon Sep 9 05:02:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2o5pmT?= X-Patchwork-Id: 13795812 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 01995CE7AB0 for ; Mon, 9 Sep 2024 05:02:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3BC46B010C; Mon, 9 Sep 2024 01:02:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC4B36B010D; Mon, 9 Sep 2024 01:02:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B65356B010E; Mon, 9 Sep 2024 01:02:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 962496B010C for ; Mon, 9 Sep 2024 01:02:49 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 383ACC1C57 for ; Mon, 9 Sep 2024 05:02:49 +0000 (UTC) X-FDA: 82544004858.17.9536538 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) by imf25.hostedemail.com (Postfix) with ESMTP id 5DC61A000D for ; Mon, 9 Sep 2024 05:02:44 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=163.com header.s=s110527 header.b="U/jGcGoO"; dmarc=pass (policy=none) header.from=163.com; spf=pass (imf25.hostedemail.com: domain of ice_yangxiao@163.com designates 117.135.210.3 as permitted sender) smtp.mailfrom=ice_yangxiao@163.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725858139; a=rsa-sha256; cv=none; b=q2IhGRroSC9ty53L3n1gkZ3EbnuK+a8Z2swAj6+FjNyIlF2AMw2c86+FSLYLgYR2mWka3T tFkHb44CO7T9AnS7HuSAijyodgbUhJ/UgqD9hkB+hR4+FNaCiTYpKOGrIKNaRyqPjDN5i8 O637WTBLHuYQjyBOzo6Ko/U7IhAK5wU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=163.com header.s=s110527 header.b="U/jGcGoO"; dmarc=pass (policy=none) header.from=163.com; spf=pass (imf25.hostedemail.com: domain of ice_yangxiao@163.com designates 117.135.210.3 as permitted sender) smtp.mailfrom=ice_yangxiao@163.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725858139; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=JBh9gFfx3heYPcoalbCGHCAhXyXUQUzmDtHwdRpGsi4=; b=TT8qvN7CCdYPqniND/GNSVvaUpDJM0jioWIH7h4CedcCSxxh5R8S+0Fh2jJU4W5PUid9br rfbtSYg2QEolgkjdcwG0+QSNJn3Ag7OPFhnR1hthb6v3f7+x90/rChWbrW/oMk+q3uiu/y 8UG5mez2FJwyRosdIH58FIxmKcqV9ss= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=JBh9g Ffx3heYPcoalbCGHCAhXyXUQUzmDtHwdRpGsi4=; b=U/jGcGoOG7tos2kQllbc6 h9/6GvWlPOf7GtDU345cjLcRzZ9eqVVLukbcetnKBx+omyLifVQzjYzi/fkS+ske 0psRZ2uUnx1M5bUR5eqCj+maDb+w8xbu3inI80PWTr3o4Q8/JIQls0pRpzHnugnB pjiyuru8b1Vx1R7+YmzCgw= Received: from fedora40-vm.. (unknown [106.133.130.25]) by gzga-smtp-mta-g2-2 (Coremail) with SMTP id _____wCXzkZkgd5mru5JGQ--.57674S2; Mon, 09 Sep 2024 13:02:30 +0800 (CST) From: Xiao Yang To: Liam.Howlett@Oracle.com, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, ltp@lists.linux.it, oliver.sang@intel.com, Xiao Yang Subject: [PATCH] mm/vma: Return the exact errno for __split_vma() and mas_store_gfp() Date: Mon, 9 Sep 2024 14:02:26 +0900 Message-ID: <20240909050226.2053-1-ice_yangxiao@163.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-CM-TRANSID: _____wCXzkZkgd5mru5JGQ--.57674S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFy8Xw4fXr1fGr1kWrykKrg_yoW8WFy5pr 93Ww1DXFZ5Xr1Sg3WYqF1jvw1Yqas5X3WrCrWUWFn3Z3Z0qws8trW5tryrZr92grZ7uF9I vr4DJF1fW3Z8KaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pinqXkUUUUU= X-Originating-IP: [106.133.130.25] X-CM-SenderInfo: 5lfhs5xdqj5xldr6il2tof0z/1tbiMwpVXmXAnu2fxwAAs8 X-Rspam-User: X-Rspamd-Queue-Id: 5DC61A000D X-Rspamd-Server: rspam01 X-Stat-Signature: 4o65gf7fm5d6bok13j1ity57npj39nho X-HE-Tag: 1725858164-304459 X-HE-Meta: U2FsdGVkX19Plx96HHJBrco6a5qGIGZ3zjemM+UzhvMvhVuvJiwI5kPUOpZpX25D66JncY+ovtV5lhX9V53Z/f3rymSoNBEeVq0nxRbbdY8AByZ00jVQ3iAtV4CVWe1iwosovTjhNfA82k5XkdJ2v0V8hUS10mHgsWsL5y+PB+tJNIKrCfem6Daa/+YnAK0uBIPsRQzWF8FGdsPLSJk5y6puavyeUxTVH5fOP6E9i4l/X+bbRdw+9EQxq5SD5jEO/bdQoZhIzsZScbjmi9H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2R9vvyHikhJvoFGlpHrB5aIbZL0dL3KCRUlgavNb9cwMUi2PwT/aYkjRzaD4lAKj8xMBWkfb1wTP6R2VPumLMKQxZGdTksC/c2qCnNQGScXHHeMtq+y13hmMfwcQjGdOrFN98f3MkTtpQjOZxWVnFndiJXq1IyxDNilvASFxTvc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: __split_vma() and mas_store_gfp() returns several types of errno on failure so don't ignore them in vms_gather_munmap_vmas(). For example, __split_vma() returns -EINVAL when an unaligned huge page is unmapped. This issue is reproduced by ltp memfd_create03 test. Fixes: 6898c9039bc8 ("mm/vma: extract the gathering of vmas from do_vmi_align_munmap()") Signed-off-by: Xiao Yang Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202409081536.d283a0fb-oliver.sang@intel.com --- mm/vma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 8d1686fc8d5a..3feeea9a8c3d 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1200,7 +1200,8 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, goto start_split_failed; } - if (__split_vma(vms->vmi, vms->vma, vms->start, 1)) + error = __split_vma(vms->vmi, vms->vma, vms->start, 1); + if (error) goto start_split_failed; } vms->prev = vma_prev(vms->vmi); @@ -1220,12 +1221,14 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, } /* Does it split the end? */ if (next->vm_end > vms->end) { - if (__split_vma(vms->vmi, next, vms->end, 0)) + error = __split_vma(vms->vmi, next, vms->end, 0); + if (error) goto end_split_failed; } vma_start_write(next); mas_set(mas_detach, vms->vma_count++); - if (mas_store_gfp(mas_detach, next, GFP_KERNEL)) + error = mas_store_gfp(mas_detach, next, GFP_KERNEL); + if (error) goto munmap_gather_failed; vma_mark_detached(next, true);