From patchwork Fri Nov 8 15:49:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11235191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA3361709 for ; Fri, 8 Nov 2019 15:50:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ADBB7215EA for ; Fri, 8 Nov 2019 15:50:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uMwnPQpF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADBB7215EA 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 D936C6B0007; Fri, 8 Nov 2019 10:50:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D43CD6B0008; Fri, 8 Nov 2019 10:50:09 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0AC56B000A; Fri, 8 Nov 2019 10:50:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id A8C936B0007 for ; Fri, 8 Nov 2019 10:50:09 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 580C3180AD81A for ; Fri, 8 Nov 2019 15:50:09 +0000 (UTC) X-FDA: 76133546538.01.sun15_1e67cdaa4972e X-Spam-Summary: 2,0,0,ddee6f333c6572f6,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::akpm@linux-foundation.org:mhocko@suse.com:vbabka@suse.cz:hughd@google.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1431:1437:1534:1541:1711:1714:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3350:3865:3868:3870:3871:3874:4250:4321:5007:6261:6653:7514:7875:7903:9413:10004:11026:11232:11473:11658:11914:12297:12517:12519:12555:12895:12986:13069:13161:13229:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21795:21796:30036:30051:30054:30080,0,RBL:209.85.221.66:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: sun15_1e67cdaa4972e X-Filterd-Recvd-Size: 3946 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 Nov 2019 15:50:08 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id f2so7532128wrs.11 for ; Fri, 08 Nov 2019 07:50:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cn9dLUspMkLLnhFheLaXTMcU0/YskVq2OYeM65qAZNA=; b=uMwnPQpFGtoalsPRPut/CDKxTHRi78/v2SCGHtaULuWotoktZmi1NfBlgmbBCuZtyg oZpyKXJf6FMkrf6S8V9Beo/8fBtyIng8YB0mD8iifrmYd7YT4SEGiushKB6P668I6JWi /Cx8XM58xrVgNsEFnn6jzLPMhpFx4XW6Upp7Xwhr9ol3JOOeIsPNXHUxjssMEb/OVJTk EVpGgwQKZsOmD45AKGnqKv9hvtTQD8nYA03GHogSqCH9SbluFv22L2/2HfmHVs7I7k0T hSozg5uizdC0ILovIuDMJo9Ifh3XMd4M2+MHzfPYx9s5vy8X5SnMud/yi/OJDLHW9nMV 1HKQ== 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=cn9dLUspMkLLnhFheLaXTMcU0/YskVq2OYeM65qAZNA=; b=p9hMsPuj+d7Rj4v78QXs6m1NWFARHHiUZbUu7NlT5X3NKsAUVzqRFYyZkMUpgtCEf3 DBki+xC8YhO1avapKB4OVZ/IWFvjlFNZrl3qFBsk7S3548n+HllG86RzVotykLkPiuDV 1ugiMCm5oz13Me2DKndh+G6Cxv0sUx08Fo+VLcDd2huYWdF5LSsdDasuethTlLi+OwG0 ldIeKcI/bAnPL/vH6AaaxjV+guDpJ7NxzsG3dho2uAetKsNgPfZqwlfyZrVVKLqrZ2Iq qOWqKhu8A0IA0WZRus6eBmuUxqYZ88nMbRCEmTifWwjjfen3n6fArMCaKYOcbrHUBf7V U+FA== X-Gm-Message-State: APjAAAXL7anIDrJBcGY+8EhZ3sWY0t0Ee/RYx6iq56dkDx1mQm9oG4Vv ymma+drvaCO7KExA0/4im/9Drds7 X-Google-Smtp-Source: APXvYqzQqGmyez7qMJzJfKEKLCa4JPUwiamWLyQ3GMH/mLbUm79K4QgSlc3GKkvLk/MX1UpElFpXBA== X-Received: by 2002:adf:f744:: with SMTP id z4mr533200wrp.205.1573228207410; Fri, 08 Nov 2019 07:50:07 -0800 (PST) Received: from binjiang-hz-dhcp091254.china.nsn-net.net ([131.228.2.20]) by smtp.gmail.com with ESMTPSA id x16sm6149969wrp.91.2019.11.08.07.50.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Nov 2019 07:50:06 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , Hugh Dickins Subject: [PATCH] mm: mempolicy: Fix wrong use of maxnode in mempolicy API Date: Fri, 8 Nov 2019 23:49:29 +0800 Message-Id: <1573228169-30986-1-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The maxnode used by mbind(), set_mempolicy() and migrate_pages() is not correctly handled in get_nodes(), where --maxnode cause the calculation endmask = (1UL << (maxnode % BITS_PER_LONG)) - 1; ignores the highest node ID bit. Then, at nodes_addr(*nodes)[nlongs-1] &= endmask; the highest node ID bit is cleared. Finally, cause mpol_new() think user does not pass in any node ID, and return EINVAL. The results are: - Application receives EINVAL when only the highest node ID bit is set. - Application recevies no error when other bits set together with the highest node ID bit, but that highest ID is ignored. Cc: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Hugh Dickins Signed-off-by: Li Xinhai --- mm/mempolicy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 4ae967b..2bdc365 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1328,7 +1328,6 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask, unsigned long nlongs; unsigned long endmask; - --maxnode; nodes_clear(*nodes); if (maxnode == 0 || !nmask) return 0;