Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp758364pxb; Tue, 5 Apr 2022 22:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJdRK4Kfs4FIfXW7y2OXaDlWseuqOW3CHC8gEIs4CK0z3MONEpv3bGZNgVpC64M5aQSFP6 X-Received: by 2002:a17:902:da91:b0:153:cc84:f13f with SMTP id j17-20020a170902da9100b00153cc84f13fmr6867937plx.38.1649221398061; Tue, 05 Apr 2022 22:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649221398; cv=none; d=google.com; s=arc-20160816; b=fBJ1er1bTy4wbml7BRc31xkbKp7UbmnljgquR6xQP3VZ42WRNJUHmiZCc0UNTeOrti WY9Lk1+Noa6Iqbi9Y1o0yNX4EJH3lN5X5ZAh6Q1eo38eKYClpbs8qta9LAtwohuNyZLu lOK7/Tuq0sCtaTuVlK4sPLZQJW8BlKvphqvY8EVeHwq9Vcp85U21Z1urfvpN8bNxZgt/ LYu6UvUkYCl/h56c9H0xTlXx5CKG6zKdyEs/gB7nL9n/pDwJQgFEIS08cX19Ncb3i+7h +hvtAcjkP11MtImOaP1bLKKmO1kjKRJ6tut0osSa+lzq496dFQtn1mOxmC/okjWW08ZA Lx5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Q8MFv/3mYmHMTU/ARqPnFLLpqbnmutqAkdIuqLFWEMA=; b=rvZ0s275LwZXp+8tg6Qy9HmhGjGneDJ7VKUa2plYyE6cs+ZxnyIg80DxggEcptYxGI aGY8ZHdkIvVb2fcE5Dshh2Z/h4X76Xj2hoshAEJEvYMPf/upn4AJWIQ2Yw7rLM46j49O MT/nFmP+zlQhUJ9qk5vig+ngwW8cCfda7kyDoPRMwvKd3xRig+Tnzkb6TwuYnQzgnIyL JpeozLxaWgcBCB3OBmZQP4XkhYGwUOKCBkJ9MclyXN04oHFrYuUca6T/CLDjq2o9sYmP Xav7TWbDwrRbuowoT0G3UGRkTzToBroFW2w/9kCraNb0CfNvxN2qmIHf+e+aj0VKn/7p iRqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jZL7M+cV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x13-20020a056a00188d00b004fa3a8e0096si16904653pfh.333.2022.04.05.22.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 22:03:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jZL7M+cV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F1A4103BB4; Tue, 5 Apr 2022 20:22:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384720AbiDEOSV (ORCPT + 99 others); Tue, 5 Apr 2022 10:18:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239706AbiDEJeA (ORCPT ); Tue, 5 Apr 2022 05:34:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99BCC7C17A; Tue, 5 Apr 2022 02:23:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 39CAC61654; Tue, 5 Apr 2022 09:23:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 132B5C385A2; Tue, 5 Apr 2022 09:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150585; bh=Ucxf3WQ4gL7VbEZenMpfiHmJYn7xo1lpnxFgStCQBcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZL7M+cVaVni1XwsEOZsdnvlvtZq0pfeI198lyx9mLEhAJLvjTp0r8ghXyqz6bz7x aoiWHRji0pRxFcl69PYt2yCFjpjqa/wKPGKtuKnmDOQFaiL303mtud7ysiXTMl+3c0 G37gTZMC+i0S1hr64XNhkFRixBY1jrqWO0FdFuaM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charan Teja Kalla , David Rientjes , Michal Hocko , Minchan Kim , Nadav Amit , Stephen Rothwell , Suren Baghdasaryan , Vlastimil Babka , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 107/913] mm: madvise: skip unmapped vma holes passed to process_madvise Date: Tue, 5 Apr 2022 09:19:29 +0200 Message-Id: <20220405070343.034015380@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Charan Teja Kalla commit 08095d6310a7ce43256b4251577bc66a25c6e1a6 upstream. The process_madvise() system call is expected to skip holes in vma passed through 'struct iovec' vector list. But do_madvise, which process_madvise() calls for each vma, returns ENOMEM in case of unmapped holes, despite the VMA is processed. Thus process_madvise() should treat ENOMEM as expected and consider the VMA passed to as processed and continue processing other vma's in the vector list. Returning -ENOMEM to user, despite the VMA is processed, will be unable to figure out where to start the next madvise. Link: https://lkml.kernel.org/r/4f091776142f2ebf7b94018146de72318474e686.1647008754.git.quic_charante@quicinc.com Fixes: ecb8ac8b1f14("mm/madvise: introduce process_madvise() syscall: an external memory hinting API") Signed-off-by: Charan Teja Kalla Cc: David Rientjes Cc: Michal Hocko Cc: Minchan Kim Cc: Nadav Amit Cc: Stephen Rothwell Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/madvise.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1287,9 +1287,16 @@ SYSCALL_DEFINE5(process_madvise, int, pi while (iov_iter_count(&iter)) { iovec = iov_iter_iovec(&iter); + /* + * do_madvise returns ENOMEM if unmapped holes are present + * in the passed VMA. process_madvise() is expected to skip + * unmapped holes passed to it in the 'struct iovec' list + * and not fail because of them. Thus treat -ENOMEM return + * from do_madvise as valid and continue processing. + */ ret = do_madvise(mm, (unsigned long)iovec.iov_base, iovec.iov_len, behavior); - if (ret < 0) + if (ret < 0 && ret != -ENOMEM) break; iov_iter_advance(&iter, iovec.iov_len); }