Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2924457rwb; Mon, 15 Aug 2022 14:09:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5zWR/TFVhtxrvxCCYIOF6Ec8+HJqMrp/OPneTXiNJAtaj8+z/9CWaobXu7O6X2Z4nvCGCS X-Received: by 2002:a17:907:1c93:b0:730:c9c3:f6f8 with SMTP id nb19-20020a1709071c9300b00730c9c3f6f8mr11988773ejc.17.1660597765792; Mon, 15 Aug 2022 14:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597765; cv=none; d=google.com; s=arc-20160816; b=V9tTnVaO2XXkgGj3dKTUvPaeKMPQtcg5nDo6F1bVQMeWJNHtVfc8XGnDhp2gFS1hG5 EwWXS0NBIL2tY5z/NUH//+C3P2TizMEbuopOAY6fP88s7+53cdw5fNyzqafGfC4hiGl1 9ard1gYUL1dEMuYOvy5sdj++9O0Iilr9u7xhw88YXGByg0GEH52K2ky2lN6Uxkl5YlSO Wm5l9lKyskEe04/tzMRetWfOAWcJNwTyHp/5+7vKemEadoDE3HPfRSZsy6/9G3s832jm YJ1WnjpCQuIOe+kH09lzs5ahBLkVCEK7MDxjGZ1GHNLRmXvjka5bOyO0SYTNGxvADUvT PLhg== 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=BuTkkoCHloKKvY5GGvfUNsk9jCttWQo5hDgcmbIGpqA=; b=STJPKs+5KynOgmR/0CQHR98Jdo+Rvoss+kgyWeellfEelgiCM7x0RCKy4YaPgSwcp7 lfY+g0hHuGVK0Feug1he7DUWMotlE5hJMWjkl2DvuU472FBHQwPSVj7lo+njkJz20NRF Jy+Tkc9N65cnoiU6b8snzXbQvtSNyJOtJZPOFDkWFe4QCbuEGjLyCQbpjUKOimXBbg0Z h0TqaR3VcVAIIUR781N6aNKaKYf2Ql0mf9UzwVUFZ0xjBg5M9nhM7CQUz8hGQatlSLO1 yPmk3Xw+LCO4kjNRBCdY4eWxDveyALRTN0s61LxiYwSEQcgGa8iDSdVMz9BqJnK/aiAz 9eTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BiAgI2Kf; 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 l23-20020a170906079700b00730951a95bbsi7371973ejc.521.2022.08.15.14.08.59; Mon, 15 Aug 2022 14:09:25 -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=BiAgI2Kf; 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 S244484AbiHOTT4 (ORCPT + 99 others); Mon, 15 Aug 2022 15:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344553AbiHOTQz (ORCPT ); Mon, 15 Aug 2022 15:16:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 665D63C157; Mon, 15 Aug 2022 11:38:18 -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 76C0D61024; Mon, 15 Aug 2022 18:38:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63BE0C433C1; Mon, 15 Aug 2022 18:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588694; bh=Gz8bGqYoi8le6+ilC4kLA6XP+cBNj1tuSsvPN4O29SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BiAgI2KfpapIIdPbA1ZT8cC2w9ho2lontdlsPj+yn8XQjO+LIWOi1RAozEbvHNcyF LyqwOBIHaNLIyrju1nThdfuHmsD7KPIAThS1b6x9V2uFqbJigIWfiQoUzKv3AqKug5 R2dAZNIZsT0OKeLinmB8+SQDZsFuI5cJ0pmZn69o= 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.15 458/779] mm/mempolicy: fix get_nodes out of bound access Date: Mon, 15 Aug 2022 20:01:42 +0200 Message-Id: <20220815180356.852822996@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 9db0158155e1..4472be6f123d 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1389,7 +1389,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