Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp379861rwd; Wed, 7 Jun 2023 00:55:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4j0J17kjsd02FzlVyWdWFrnrpP8XJUMEv1w44hPzN9TKA6NTQGqh51FKm9e3Zb0FEy1WJ1 X-Received: by 2002:a05:622a:24e:b0:3f6:a7c2:63d6 with SMTP id c14-20020a05622a024e00b003f6a7c263d6mr2209963qtx.44.1686124539281; Wed, 07 Jun 2023 00:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686124539; cv=none; d=google.com; s=arc-20160816; b=wK4OIQV+elGcNBB2GcVEx/JSnOrdxcHUpGmxKDKOidfu4g+qUjRYfWvxi9FPYJfjEv g8OkvothqpWawhsh6N0ahZ6BQty6TMAImh73BgPIMwHEEXJbFCqSwZkx+nU/VhdbJW8R RWceJx2SGudHMvnbQNlH0MQycc5W/RaX3C7pm4mnNPbe9sUssnTHe1YPz2DV1Zv3t/J6 Ut2lhMXuiicA5yBeHfslimEZohLLhwc4VZLKAwUCUburQxCRivgvNYcDhzIPu1JUpXuN tO8jwgaFGHYSVMdvwU0/tT+O4iYCcp2FMWIAJJohH8N7vIJnJqL2lpoWRd/XKgEJ92yp F4Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=kuzBLDH+6vBS19qokiGMN61hDvOG3cixMFx4ZnGpwsY=; b=c6XAWke5mze+FpR7mfHrkEmUJYFHfEoyidBTmGnHrwTXoExBjA4Y3hYAqOUtQGkVKJ 7H56BuKxFpI/kC7KLO7/G9hUSqSk2xV/RQp/hr5xF6MdKnAgkbz8Zwur1I880ETREvU8 p+9zXVkvHdb5SbPdFhPLBi2beKJsJK838eByXIm9H7x0QsY7Ny1lhCUgJFIcFwxp6eLN LBboa9R7bxsXvKb8NVe+oh8B0Osa7+UafazqARq4SlpchjTa3DkgQm90fl981vRaOgJW th3dCFA/cpSNuzcuPJYt6MxNf0sZVpD5aqttkAs2J2hJ6ZUX5roraOfuzn8usNOkNAAb KR7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZDkJ+wP8; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a630115000000b0053fb7cd1ac4si8569219pgb.519.2023.06.07.00.55.25; Wed, 07 Jun 2023 00:55:39 -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=@suse.cz header.s=susede2_rsa header.b=ZDkJ+wP8; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238737AbjFGHra (ORCPT + 99 others); Wed, 7 Jun 2023 03:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238863AbjFGHrG (ORCPT ); Wed, 7 Jun 2023 03:47:06 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 256FA10DE; Wed, 7 Jun 2023 00:45:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D90C11FDA7; Wed, 7 Jun 2023 07:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1686123943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kuzBLDH+6vBS19qokiGMN61hDvOG3cixMFx4ZnGpwsY=; b=ZDkJ+wP8Mk1V/Gd6g8XOWPnH7eQTgy7RacOhnKeA+SsDIxenMOIUXFebEOuHd6KqQ427io LoBSLRjHgMr4kPdRG1+i/MFd9BGqm+aR/V7Hx4IG/9u48F2p+Lm6lsBKbjqhhGmlEiINZi R8q+PDmS/Ej5gskkjY+fqjtEXyedPgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1686123943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kuzBLDH+6vBS19qokiGMN61hDvOG3cixMFx4ZnGpwsY=; b=zyDAsG/SWmg9baJajNBw87o4keZirFobvvi8GI83urryWwLZAiL3l/gXexud90fOb/yXui zM0qgtsA2dzdZ3Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A983F13776; Wed, 7 Jun 2023 07:45:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AqTkJ6c1gGRlKQAAMHmgww (envelope-from ); Wed, 07 Jun 2023 07:45:43 +0000 Message-ID: <571c997a-0f26-4076-f5c4-cf2aacd36e90@suse.cz> Date: Wed, 7 Jun 2023 09:46:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() limit check To: "Liam R. Howlett" , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Lorenzo Stoakes , Jeff Xu , stable@vger.kernel.org References: <20230606182912.586576-1-Liam.Howlett@oracle.com> Content-Language: en-US From: Vlastimil Babka In-Reply-To: <20230606182912.586576-1-Liam.Howlett@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 6/6/23 20:29, 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 Acked-by: Vlastimil Babka > --- > 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: