Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp639463pxb; Tue, 5 Apr 2022 16:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5ZDV72BnzStwYvNdzqsEkOzzb5c20+CRhGPahSJOcIpilUDqXonLGb6ptrmP4Th7O8fiu X-Received: by 2002:a17:902:d884:b0:153:ce8e:66fe with SMTP id b4-20020a170902d88400b00153ce8e66femr5976123plz.157.1649202989758; Tue, 05 Apr 2022 16:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202989; cv=none; d=google.com; s=arc-20160816; b=y0BkrqK4MttUvJN0IwcLoZ9/W4fJ4TvzZvze2Q2OkfqpLED7a2c0Co+NlneRnd+qsM yy2ww9m8lsVwa9BFk53S9M1kyS/q9cKylQFHd+Vu+jfoYDqUf8LPO/9W3GQpnDY8vnLG bnqWWBkF0ZvBOFtvxqXU92ZzwdbxUxIRk42YNLvD71RZXxr4N/SynS4C2k89ti8m8QuT 72Kiv0JLERt+FdlaTceU46mNVTP4LQv+PwE8dx1Z4i8eG6ibsVi/SVlh/jtD9Z8rEPZG /y42ynLnM3vM3YZSYieoX39jozCzvA2YRYvQm0dxU3Q9vXRn/X2y4/WPkNhSE2sKyRHd dwfA== 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=JMgmY2I2EpqH3N9k3QCAE3vBbuywm8j46osXMythXc4=; b=JcB4tctRDxbDpMEKK5o0uCTqYn8m0ZPxUN51sVGciBJ2ECxKS+aJen4zvJMHSEishj GtTOqGN3xS8fYpmSp6uMv+khoy10nJjCqVGXknCk5TQqoXF3OTVdeVzDMleJy0vL3B3Z CJPYhoqx63DYDAhk+BrslkAuEQmwKuJoHGNXaxmBfTvddxf/bO+BoAry+6/Zflz5eIY5 vnPyGglHSN8pYHkGIrhrqP84qUMbK5oBaSFLeoNcVcgrSKwHvMu3UwfgZohI3+uo6oxN VsfHGDHRtuPs+tsh1PQbXV9INoZSZnlmM39LKmf56sOqBYmRkSM1CEbcOLr/JZ3kSQ/9 w/Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1tZC9tiM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id x5-20020a656aa5000000b00398d65f3654si14553172pgu.403.2022.04.05.16.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:56:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1tZC9tiM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 649DF27855C; Tue, 5 Apr 2022 16:42:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235713AbiDEOTv (ORCPT + 99 others); Tue, 5 Apr 2022 10:19:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240011AbiDEJeA (ORCPT ); Tue, 5 Apr 2022 05:34:00 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A2B7DE3B; Tue, 5 Apr 2022 02:23:14 -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 sin.source.kernel.org (Postfix) with ESMTPS id D4153CE1C77; Tue, 5 Apr 2022 09:23:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3A82C385A0; Tue, 5 Apr 2022 09:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150591; bh=odjEBd93PReyGhAg8bd0F+x9rMuWnwtR8XTzfDHioAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1tZC9tiMHsC+jWyDqiShOMOQh466NuVXEjJGMgSK3nTWX9BGQOANEn4DPSShiyNwP ++GvryP/hore94ozqvgE5LYCPnjYFlMF8jWmwZSbjmv5mcevAhOhVvoRnp553ORJzV I3j1hrE8/1ylSP3UdZF+/sTb/hmQNdz1fsC/EmkU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charan Teja Kalla , Michal Hocko , Suren Baghdasaryan , Vlastimil Babka , David Rientjes , Nadav Amit , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 109/913] Revert "mm: madvise: skip unmapped vma holes passed to process_madvise" Date: Tue, 5 Apr 2022 09:19:31 +0200 Message-Id: <20220405070343.094253192@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 e6b0a7b357659c332231621e4315658d062c23ee upstream. This reverts commit 08095d6310a7 ("mm: madvise: skip unmapped vma holes passed to process_madvise") as process_madvise() fails to return the exact processed bytes in other cases too. As an example: if process_madvise() hits mlocked pages after processing some initial bytes passed in [start, end), it just returns EINVAL although some bytes are processed. Thus making an exception only for ENOMEM is partially fixing the problem of returning the proper advised bytes. Thus revert this patch and return proper bytes advised. Link: https://lkml.kernel.org/r/e73da1304a88b6a8a11907045117cccf4c2b8374.1648046642.git.quic_charante@quicinc.com Fixes: 08095d6310a7ce ("mm: madvise: skip unmapped vma holes passed to process_madvise") Signed-off-by: Charan Teja Kalla Acked-by: Michal Hocko Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: David Rientjes Cc: Nadav Amit Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/madvise.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1287,16 +1287,9 @@ 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 && ret != -ENOMEM) + if (ret < 0) break; iov_iter_advance(&iter, iovec.iov_len); }