Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3092296rwb; Mon, 15 Aug 2022 17:56:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/r0oYMspM1OGvADHfFR6W4Ois2NUv5UQRiyTpmNA2GRC+qQa5SwEd9x8IjkwY7t7QD6Hp X-Received: by 2002:aa7:c983:0:b0:43d:3879:216b with SMTP id c3-20020aa7c983000000b0043d3879216bmr16561046edt.131.1660611387427; Mon, 15 Aug 2022 17:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611387; cv=none; d=google.com; s=arc-20160816; b=Pb6gOQjpSghnPty9DpVi7XGlwKNPyWVPs8JXcKfoYy0BhYcjmQWYsEKC43+H30OT0c 07Bo1uHQ+A3zG1kkEySP3dSRoT0L57ZMGWE+aPphKcRvmmU60eaVRNH9vTRVGB9NNldo vC2gEToJAr22+748SROHPkTvscQ0InZ1cSU1sEkD+yWCFWiSFHC46RVI9DgRBrBJ1jPf a3BQANTvJQg2pGkvNaFd+7wJG1q3RqpVBVleFqM0Z6iHq23hhydFujD0C2pxUGJCbnw6 YXhrpCmiiRCPYF4r10vV7YUIIYZALq7AxhraRpqpGLYGIGNTpisj3hVs8izuUamcoGbU wuHw== 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=Vi7N1ATZj4Zl83gqhN2meu2R+7/hQfOjgvSIz8+CT+w=; b=TKTM+/Gtsa7bPLPiRJuJCvvpp20IQpWGgv5CMGzkVp0/GHi7XC4QuLWrmqgl5wDeAw tLjk+bPnPt5QgEwuc611mS9/Dciz+YJ5bdN30+tbdQHdW2g9RR4XZ2fcjBWUbVVArbUw cRXiWQmbeCS6DUUh2nBgLfMtaDqEyI7bjDCjhqNzHRhlYgmp1UhwiX/IJJKIfTv7LVgS tKxBZoZx6PqJtau7aMc9RKQT6YpLs504JkgVVZ9mbD5YKL9XPib1oR353xJeD2TNIJer 3bBlY9YHRLljf8YD3KIO0PNS5D7kbSgzTZ27Gp0usjrW11CL0CW9jp5ctKH6xwcktBBG +gEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=waluQLjD; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020aa7c591000000b0043c0288d312si7833207edq.584.2022.08.15.17.55.58; Mon, 15 Aug 2022 17:56:27 -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=@linuxfoundation.org header.s=korg header.b=waluQLjD; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343613AbiHPAXD (ORCPT + 99 others); Mon, 15 Aug 2022 20:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354942AbiHPAQa (ORCPT ); Mon, 15 Aug 2022 20:16:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89B4B15C909; Mon, 15 Aug 2022 13:30:49 -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 9762961089; Mon, 15 Aug 2022 20:30:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BFCFC433D6; Mon, 15 Aug 2022 20:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595448; bh=IWPQb8ie+Po/Tj9QdZjmmgG64zCz88pHqWsrx6zftGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=waluQLjDTyhhF6AdyO+KAJYM7oHz0chJ2zV4VAvDiJJxABEMo7hWBR6kgrzxXlN4h 0z87HnS4EaBvvHoH4/HI+M5M2QopytjVogzF8F+NgTQq+/n/djWzQ8whGZKEa5ZmiU j48VV1njxGG3OTeQlWLUvGG8IQ7Cc9hTl39fyF6s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tianyu Li , Arnd Bergmann , Mark Rutland , Andrew Morton , Sasha Levin Subject: [PATCH 5.19 0768/1157] mm/mempolicy: fix get_nodes out of bound access Date: Mon, 15 Aug 2022 20:02:04 +0200 Message-Id: <20220815180510.211406156@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Tianyu Li [ Upstream commit 000eca5d044d1ee23b4ca311793cf3fc528da6c6 ] When user specified more nodes than supported, get_nodes will access nmask array out of bounds. Link: https://lkml.kernel.org/r/20220601093211.2970565-1-tianyu.li@arm.com Fixes: e130242dc351 ("mm: simplify compat numa syscalls") Signed-off-by: Tianyu Li Cc: Arnd Bergmann Cc: Mark Rutland Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 9689919a2829..f4cd963550c1 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1388,7 +1388,7 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask, unsigned long bits = min_t(unsigned long, maxnode, BITS_PER_LONG); unsigned long t; - if (get_bitmap(&t, &nmask[maxnode / BITS_PER_LONG], bits)) + if (get_bitmap(&t, &nmask[(maxnode - 1) / BITS_PER_LONG], bits)) return -EFAULT; if (maxnode - bits >= MAX_NUMNODES) { -- 2.35.1