From patchwork Mon May 16 19:37:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 573256 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08C10C433FE for ; Mon, 16 May 2022 20:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240892AbiEPUKr (ORCPT ); Mon, 16 May 2022 16:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351063AbiEPUB5 (ORCPT ); Mon, 16 May 2022 16:01:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D5F473B4; Mon, 16 May 2022 12:57:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C3D4DB81615; Mon, 16 May 2022 19:57:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25369C34100; Mon, 16 May 2022 19:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652731075; bh=FM2KypQaSM0lg4NGsv+JVQ8dLweljGPy3xbFEFrdZyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pRwdl+Dii0GTLCNdShtR9NjKSbcU2bgAZksxJKOC6dgK8PG5WnFM1hDxM6d04aW3u XS9svh2MhpDy9lpBREMr6ZehVy19O9xtYw/HvMswVfjpsva+wWmS/ciuix35tu/JyT tGbUITJ3P2X4a3qBLjNnVFFsggLz2yi72VwxZdzk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Mina Almasry , Mike Kravetz , Andrew Morton Subject: [PATCH 5.17 095/114] mm: mremap: fix sign for EFAULT error return value Date: Mon, 16 May 2022 21:37:09 +0200 Message-Id: <20220516193628.201513069@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193625.489108457@linuxfoundation.org> References: <20220516193625.489108457@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Niels Dossche commit 7d1e6496616275f3830e2f2f91fa69a66953e95b upstream. The mremap syscall is supposed to return a pointer to the new virtual memory area on success, and a negative value of the error code in case of failure. Currently, EFAULT is returned when the VMA is not found, instead of -EFAULT. The users of this syscall will therefore believe the syscall succeeded in case the VMA didn't exist, as it returns a pointer to address 0xe (0xe being the value of EFAULT). Fix the sign of the error value. Link: https://lkml.kernel.org/r/20220427224439.23828-2-dossche.niels@gmail.com Fixes: 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") Signed-off-by: Niels Dossche Cc: Mina Almasry Cc: Mike Kravetz Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/mremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/mremap.c +++ b/mm/mremap.c @@ -947,7 +947,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, a return -EINTR; vma = find_vma(mm, addr); if (!vma || vma->vm_start > addr) { - ret = EFAULT; + ret = -EFAULT; goto out; }