From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8266EC43461 for ; Sun, 13 Sep 2020 14:33:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 095BB2151B for ; Sun, 13 Sep 2020 14:33:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L7/07/Vs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 095BB2151B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 626266B0002; Sun, 13 Sep 2020 10:33:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FA7B6B0037; Sun, 13 Sep 2020 10:33:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 522F46B0055; Sun, 13 Sep 2020 10:33:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 3C9E66B0002 for ; Sun, 13 Sep 2020 10:33:01 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F1178180AD806 for ; Sun, 13 Sep 2020 14:33:00 +0000 (UTC) X-FDA: 77258280120.16.sky89_1809b9127100 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id C3650100E6912 for ; Sun, 13 Sep 2020 14:33:00 +0000 (UTC) X-HE-Tag: sky89_1809b9127100 X-Filterd-Recvd-Size: 3468 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Sun, 13 Sep 2020 14:33:00 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id o68so10546274pfg.2 for ; Sun, 13 Sep 2020 07:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Btcqa7Ss3wf3T8okzeIRJbVGIc22VxkWA4t/qIPR/qo=; b=L7/07/Vsg5gGavDTQRKWXGASQ+FYDur7bs0PoRHt9QtLFrHpdPGXA3TdjfmFF/vKZq fN4dTm1NWx+5Dlu/Av64tCCz6dvCwejsZ915Y/n9+4gozzMjXwk7NqT6Qm/kPUwrjNgq 3Gzp/EXa52oRwgXOm55fIgpzaYn1LAnvokbQH9ySNkYXUSFh3T+7dVqPRrlQYhG+/R5B lNtKZzgVaiHCwzNS3AX7AclHXxu3e4H1MPpXLYdSKZJddySCccBcP1pFpCRlLx73TLTO l2HUEtu/f6voLE1oHEJN+1zJ5mC+Za7QqHGfTrY8a9Oe4Ks9ilqYk1xRk0I1ukbEcX4O j32A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Btcqa7Ss3wf3T8okzeIRJbVGIc22VxkWA4t/qIPR/qo=; b=ppTTkvMR1ft3Mn0KYvpUde5jVV3xJNk+VP5XNDRgOrJBlFtn8KIANs16IYFmtx/RMm G2hDoZFr5HXwgyNQ/AITTUMzyjaCamQebt2ScIXSXIcr+xTRO2P76uXteoePeDs/3IaW V+JYSbbNONSl/3EHIJuqLnMEi4vW15VpGrxxfxMRTdxaMuy6qGvljZa68hBP1P/VNrtz k/OR+gGNWPr/2JvN1kZNi2YdhxaVPzapCQGc+/jaq2U6LRRsONlnH3cEbh2bgbxcDriL Cw1mTL9huN8Rnkmuapb8ANcLT9SANfkAZYcoXoEjLNi8hJ7ZKmYgYi8Q0QQnEJhTeKWl /4FA== X-Gm-Message-State: AOAM530wMNmN7lO/ulHmZw34ZmsiEjNfndINyYAHyrvVgOK+XvcwW2LO JFj39egLFJY5qCLFqVtiVQo= X-Google-Smtp-Source: ABdhPJyfAoM3KarB7tR3PpDmlCTkqwRplEb+zNL5euQnSSlq4Xn8xqqwZLSSyO7V+f84QzsjBhjdMg== X-Received: by 2002:a63:5663:: with SMTP id g35mr8121830pgm.163.1600007579345; Sun, 13 Sep 2020 07:32:59 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.167.45.202]) by smtp.gmail.com with ESMTPSA id kf10sm6618257pjb.2.2020.09.13.07.32.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Sep 2020 07:32:58 -0700 (PDT) From: Souptick Joarder To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Souptick Joarder , John Hubbard Subject: [PATCH] mm/gup.c: Handling ERR within unpin_user_pages() Date: Sun, 13 Sep 2020 20:02:35 +0530 Message-Id: <1600007555-11650-1-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 X-Rspamd-Queue-Id: C3650100E6912 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.020335, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It is possible that a buggy caller of unpin_user_pages() (specially in error handling path) may end up calling it with npages < 0 which is unnecessary. This can be fixed by adding extra check inside unpin_user_pages(). Signed-off-by: Souptick Joarder Cc: John Hubbard --- mm/gup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index 0b5c308b..2e19bd6 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -328,6 +328,9 @@ void unpin_user_pages(struct page **pages, unsigned long npages) { unsigned long index; + if (WARN_ON_ONCE(npages < 0)) + return; + /* * TODO: this can be optimized for huge pages: if a series of pages is * physically contiguous and part of the same compound page, then a -- 1.9.1