Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp266426pxb; Wed, 23 Mar 2022 17:57:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcoWW9pvzkQnkgEJtbJolDhItNcJxjb3CRFMmYRLuax/2mjgCiWq6qePyrDbo8WQlGQjeL X-Received: by 2002:a17:902:ce90:b0:154:3029:97e3 with SMTP id f16-20020a170902ce9000b00154302997e3mr3015899plg.47.1648083433336; Wed, 23 Mar 2022 17:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648083433; cv=none; d=google.com; s=arc-20160816; b=WP5v8TtkOiYbgzWP/ES+C/bOHy4Iz2xMTlJR/c+05TYoaFZwNq0WgCrzSMxJkrbvWB cxknjM2lix4L7Siy1gCMgN+hPxQJ/g1T2vWE8dEHl1Y6AtV77ioOW2VR9nsrW3w99TVt n9mVrQ31jOGxQRaXo7cNAL5O8RpDJyjiyd8sL1RIOrL5X/puMouNIPeAOZusHcp1G29x nfXZcao2rdUH4XzY8E+KslyxhJJQPOFCE6jqACwsQ4/65qQGcTaUNhl6S3Wk7IZ0it8g +eDwicRn5a1b0z8t/BUp8gtN3IL5RtF7NBeCP5I5BPUl/EC7/3kYL3XcxknJ1P1YgB1Y v3Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PDhBafgZj3+zXDMLpR9U5QffixWseTxyOTJmwjftEEw=; b=NCFqGDNmLczanVEynWgrHrDoikvyYqcVKo7cppdSTOMajv5Lkakn3XRNk57Uudh4vH j8J+/fKViU4Ih/c8wiyBqC+cvbXug9lmzMacEvIWPtaBhrOlrsEZWvaDi5BIXUpuW9Vm 86v/UdiHb6DBeoT7lL8uCkAlaiOPt2H43eIAAD6+gH2pAuZ/CV7PXt/rpeobnPZo1AQT YnaI1npjeH/8lFKoRFAswimP4rxJ2HPH5rf3sd8GgpqMAD4Y3H09XBA02iuFEguFTBXQ X5zSskabFmVgvQqG+Ik0oJg97BBWO36VX4OAIgcKOUymfRykI4Y2Y117J5Uhu7PTN7mh 0S4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=K9acs0uG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020a056a0015cc00b004fa771ab36asi9744513pfu.265.2022.03.23.17.56.51; Wed, 23 Mar 2022 17:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=K9acs0uG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245152AbiCWP0V (ORCPT + 99 others); Wed, 23 Mar 2022 11:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245146AbiCWP0S (ORCPT ); Wed, 23 Mar 2022 11:26:18 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15E643C706 for ; Wed, 23 Mar 2022 08:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1648049089; x=1679585089; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=PDhBafgZj3+zXDMLpR9U5QffixWseTxyOTJmwjftEEw=; b=K9acs0uGIIl/Wyd8currlai2EplH71NwNQNfFlBVIIVfHq5F1a9WoZob wq20y4owFU7J3QmvfXH4bkKPrft4Hk73w2DqMCr5dsILsMeF+ntHZmMLm R9/r9CMHRgHXjSppUk0ssXCgVMA+IA4RoBsOppqctiCexgaM8sxY5hHur c=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 23 Mar 2022 08:24:49 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 08:24:48 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 23 Mar 2022 08:24:48 -0700 Received: from hu-charante-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 23 Mar 2022 08:24:44 -0700 From: Charan Teja Kalla To: , , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH 1/2] Revert "mm: madvise: skip unmapped vma holes passed to process_madvise" Date: Wed, 23 Mar 2022 20:54:09 +0530 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 This reverts commit 08095d6310a7 ("mm: madvise: skip unmapped vma holes passed to process_madvise") as process_madvise() fails to return exact processed bytes at other cases too. As an example: if the process_madvise() hits mlocked pages after processing some initial bytes passed in [start, end), it just returns EINVAL though 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, if there any, for all the error types in the following patch. Signed-off-by: Charan Teja Kalla --- mm/madvise.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 39b712f..0d8fd17 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1433,16 +1433,9 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, 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); } -- 2.7.4