Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7528584rwd; Tue, 6 Jun 2023 12:05:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WHzZ7dWnz71wGcBpdiB/mXonH1EqOQaci8iK4yYpFJ36IymITKli0sH9ArQgoOUgL8qfF X-Received: by 2002:a05:6a20:7345:b0:f2:57da:7f45 with SMTP id v5-20020a056a20734500b000f257da7f45mr614930pzc.8.1686078314363; Tue, 06 Jun 2023 12:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686078314; cv=none; d=google.com; s=arc-20160816; b=dpJcZREnZ2fmznlugho8TCa45LBPtyCtXuiG3dtQqn+FE6ngF/mdMJUlHbc46ElO88 f/40KFdYu+ol48Iz6tGxMgct/1Pgj6RbTJIz9yd7vZCAHfg3O69FRGZdgU4ZBhH6afKu xrjzKdT2Czs+HXSgHZRGwzskAZC3YG09ctRUYxwzR3fEBh81Fp0aGTemv2HjmuhIbutL K/UgbPNEgAGtgCwflVRxQJ8g7DFA/pqThDg/AwVHacMli703O5+8N22jIF6zV7bWg4dI 7zt139Y9tzHojYjBiStTUAihIsV25WSZWA9XKI9u6K16UwZHf4L5EzZ+NhZv3hxmThIF hquQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8svzrQGUEtETEf2Gc4kOvl6Kj1C686jV3zJl9I41Yfg=; b=jKbsCXO5M5Nq3dm+31npWDG9MGSUy0IaxONjOFGXFfLl6GCmdmQRQ4exM0bPbQuefr 9H//OI9PosxZHck0hSMBE0XmxYWmvmbFTKPsqxYMB/jYzw1D/xR0PWzAAYUV7ZFK4kJE YqwJZYvi11olAOBdfyJmI2ngKCPWbUBAMQI1YJLhl/pj2eARSHNWjqlYMjUUsv0x87EJ i79OvdIpwUezb5dIeO8FaiG+7xnQqY+e0GE+cA8i81qdCTRs09S22ionbMFvXjV8hL8e UYfjn7bTu0RrSnvHkJyk6K2mpfqb2u05qeZv2MFN2xzwZWKLGD1/UOKHaUwNcgb3xEb0 JLtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=psq7lUwS; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d66-20020a633645000000b005349316e59bsi7624441pga.751.2023.06.06.12.05.01; Tue, 06 Jun 2023 12:05:14 -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=@gmail.com header.s=20221208 header.b=psq7lUwS; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238161AbjFFSeC (ORCPT + 99 others); Tue, 6 Jun 2023 14:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233574AbjFFSd5 (ORCPT ); Tue, 6 Jun 2023 14:33:57 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A28C01BCC; Tue, 6 Jun 2023 11:33:26 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3063433fa66so5616780f8f.3; Tue, 06 Jun 2023 11:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686076404; x=1688668404; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8svzrQGUEtETEf2Gc4kOvl6Kj1C686jV3zJl9I41Yfg=; b=psq7lUwSkBsj+yf4R0xiNE9E7Hj9VK328d/Zic7hPh315XwjsbK9b3Oc1d5rAGSde0 ppVJzOXmbVEi2HtzCooQfBWismtvmFIrwATUkh8fUagKL9pqQ5z28HI7b8JFY6/nQOZY RPtjpQUpv12BQfzc3YWu5q4/L/Ifs4jIk4VX0/GO/tIjfqY0rIRe5ZAe0JtaAsOHEF7X 2x0Nine0BWYKULFo/+CrxUHliyCduz1kjYBLoVcoV4ny2Y3PRW1sDYs7UfMZQyIupz0q YxC0vfealeD+BahHSnJLuIewyXcfZpOuzZEogfwq7MDvI2EERS1D7m+uqJXoDGMk2P3Y f8zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686076404; x=1688668404; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8svzrQGUEtETEf2Gc4kOvl6Kj1C686jV3zJl9I41Yfg=; b=fCBuvubPmOxKGMtNNUcbnmKM7qTchsffjPiL3eozc+Q8VyAF4wm025TMJqnYkbJC6q jWT5TMd9l/k0yXK6hoyCYYHl5lxHM0aP8CZ+c3RbImD05a/eRNjtRWz2goADYzIWv6Pc Wm5U+eXExS7DsKqLIRSJmuaTi3dL81Or+dDMpoJxJNNhpLwh67Hzrj120ZT2kGfhg36e aRbMWqEmsuGgQwzRAruClHBFNa2DCszDOGJnpR7PbvwIkPJ9AKa12YP1k2VRHog6MdL3 4nQVsIjnMS8Dc7qzvn9l7dJg73RETsvx8gU+NfnEceAK5F/lkmf6zeiAA5KwqlmEEwkr I+cA== X-Gm-Message-State: AC+VfDz8Mqr4nVALbUgmRFkTYC68kf1HOugfKPZnfRckrJI7dDHycZcH 62AVI6YdEfRKnR/Iu8dJxTE= X-Received: by 2002:adf:f212:0:b0:30d:5cce:3bb5 with SMTP id p18-20020adff212000000b0030d5cce3bb5mr2461590wro.60.1686076403503; Tue, 06 Jun 2023 11:33:23 -0700 (PDT) Received: from localhost ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.gmail.com with ESMTPSA id 4-20020a05600c248400b003f604793989sm18503641wms.18.2023.06.06.11.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 11:33:22 -0700 (PDT) Date: Tue, 6 Jun 2023 19:33:22 +0100 From: Lorenzo Stoakes To: "Liam R. Howlett" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Jeff Xu , stable@vger.kernel.org Subject: Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check Message-ID: References: <20230606182912.586576-1-Liam.Howlett@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230606182912.586576-1-Liam.Howlett@oracle.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Tue, Jun 06, 2023 at 02:29:12PM -0400, Liam R. Howlett wrote: > The return of do_mprotect_pkey() can still be incorrectly returned as > success if there is a gap that spans to or beyond the end address passed > in. Update the check to ensure that the end address has indeed been > seen. > > Link: https://lore.kernel.org/all/CABi2SkXjN+5iFoBhxk71t3cmunTk-s=rB4T7qo0UQRh17s49PQ@mail.gmail.com/ > Fixes: 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error") > Reported-by: Jeff Xu > Cc: > Signed-off-by: Liam R. Howlett > --- > mm/mprotect.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/mprotect.c b/mm/mprotect.c > index 92d3d3ca390a..c59e7561698c 100644 > --- a/mm/mprotect.c > +++ b/mm/mprotect.c > @@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, > } > tlb_finish_mmu(&tlb); > > - if (!error && vma_iter_end(&vmi) < end) > + if (!error && tmp < end) > error = -ENOMEM; > > out: > -- > 2.39.2 > As discussed via irc, was able to confirm locally this fixes the reported issue, so have a quick:- Reviewed-by: Lorenzo Stoakes