From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B37174C81 for ; Thu, 16 Jan 2025 04:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737000099; cv=none; b=bM+DhTKAoZS98eyQXMEppf2zE3nT4uWhRLv/5c1Ad9M//OKl3SzVAiOO0ShPgZDPpm/B7dua8kbsrckdXqoJ+cR6bEa295rMYgtOjofDhPoxKv5S0GXco9PvpqA0EH5+FBtc6LPam9ECO741hUWdjp2BImGddw17ZsNRIK/nnvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737000099; c=relaxed/simple; bh=/A3EHbhjm/JMu8+qy59CDtweJJn9hEoeX0pag1cKcpY=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=W3MstH/wn+ILndAAyD3BeVPxKb2xsoM5Lqrsjhr5q8pxsff4xXzgmnOWIpN9nLdGTxpYyuRP1DUQG3wcLRBBlI19JGgE3Bi17amKiLDQAe8Oe1HrrwSC4qESpjGtHIg7yZgNcrUgX6SO7OyYmA6lbx3nLznk0puF5Q7G5WnLMZI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=2L7Cip36; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="2L7Cip36" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F077DC4CED6; Thu, 16 Jan 2025 04:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1737000099; bh=/A3EHbhjm/JMu8+qy59CDtweJJn9hEoeX0pag1cKcpY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=2L7Cip36NIW/dcUhC5QVzFHb+UTkkkvY3aXesgJJ+9ks6EcuuRmneiLYWYY4P+oHN JRsRuOs/8e/4NEX9kDHQ3e57BlkOQ9ArQ/AFZLbCwpic9OXK/2OCMt0KvtjmEk+OEp FqRQwrARMdinpGoAMRlnYvgyVFk4b/yRZPmOpSG0= Date: Wed, 15 Jan 2025 20:01:38 -0800 From: Andrew Morton To: Liu Ye Cc: Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, jannh@google.com, vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/vma: Add VM_WARN_ON for commit_merge Message-Id: <20250115200138.708adc518dd4f92f4fe7fae5@linux-foundation.org> In-Reply-To: <20250116025005.55846-1-liuye@kylinos.cn> References: <20250116025005.55846-1-liuye@kylinos.cn> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 16 Jan 2025 10:50:05 +0800 Liu Ye wrote: > Add VM_WARN_ON to prevent 'adjust' from accessing NULL pointers > when 'adjust' is NULL and 'expanded' is false or 'adj_start' is > not zero. > > ... > > --- a/mm/vma.c > +++ b/mm/vma.c > @@ -641,6 +641,7 @@ static int commit_merge(struct vma_merge_struct *vmg, > > init_multi_vma_prep(&vp, vmg->vma, adjust, remove, remove2); > > + VM_WARN_ON(!adjust && (!expanded || adj_start)); > VM_WARN_ON(vp.anon_vma && adjust && adjust->anon_vma && > vp.anon_vma != adjust->anon_vma); > This won't prevent a null deref. It will emit a warning which duplicates all the information which we're about to emit from the oops handler. Are there any reports of an oops from a NULL deref of `adjust'?