From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37FFDC4708E for ; Mon, 5 Dec 2022 22:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233755AbiLEW0Y (ORCPT ); Mon, 5 Dec 2022 17:26:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233785AbiLEW0T (ORCPT ); Mon, 5 Dec 2022 17:26:19 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62CA110544 for ; Mon, 5 Dec 2022 14:26:18 -0800 (PST) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 E360F1FDB8; Mon, 5 Dec 2022 22:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1670279176; 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=eZ4WsNiVNXdP/78KYzu1+u6hT2Y7e5e51ZAh5KxKHiQ=; b=Mz4LSylqrP8ErHLX6mdTKsIxeP0X3J/KnbGcZy07dbAzqr9lkVLSzNAD59YERGfpuAM4X0 i/pNOJpaizAt9FQw+9Dded+bfrF/16FDjCSHP006daKugmd6ECcgwNutTAHHXoGs4GIFIJ h2FWdnZUqdcwMmsYHrgJQezFQM33nlU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1670279176; 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=eZ4WsNiVNXdP/78KYzu1+u6hT2Y7e5e51ZAh5KxKHiQ=; b=cxru7bdKCWSt4HvsfSK/Y0yCYP5U5zJzeIAsJ82Woitkp+SbNNrGGzTYTQT5YhN68ljSa8 ERtNVzU86oSgrJDA== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id C21DC13326; Mon, 5 Dec 2022 22:26:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id Egi7LghwjmO9dQAAGKfGzw (envelope-from ); Mon, 05 Dec 2022 22:26:16 +0000 Message-ID: <6eb002c8-0e31-7c9f-bb3d-81c4430b296c@suse.cz> Date: Mon, 5 Dec 2022 23:26:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v2] mmap: Fix do_brk_flags() modifying obviously incorrect VMAs Content-Language: en-US From: Vlastimil Babka To: Jann Horn , Andrew Morton Cc: Liam Howlett , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Yu Zhao , Jason Donenfeld , Matthew Wilcox , SeongJae Park References: <20221205192304.1957418-1-Liam.Howlett@oracle.com> <20221205123250.3fc552d96fcca5dc58be8443@linux-foundation.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/5/22 23:13, Vlastimil Babka wrote: > On 12/5/22 22:55, Jann Horn wrote: >> On Mon, Dec 5, 2022 at 9:32 PM Andrew Morton wrote: >>> On Mon, 5 Dec 2022 19:23:17 +0000 Liam Howlett wrote: >>> > Add more sanity checks to the VMA that do_brk_flags() will expand. >>> > Ensure the VMA matches basic merge requirements within the function >>> > before calling can_vma_merge_after(). >>> >>> I't unclear what's actually being fixed here. >>> >>> Why do you feel we need the above changes? >>> >>> > Drop the duplicate checks from vm_brk_flags() since they will be >>> > enforced later. >>> > >>> > Fixes: 2e7ce7d354f2 ("mm/mmap: change do_brk_flags() to expand existing VMA and add do_brk_munmap()") >>> >>> Fixes in what way? Removing the duplicate checks? >> >> The old code would expand file VMAs on brk(), which is functionally >> wrong and also dangerous in terms of locking because the brk() path >> isn't designed for file VMAs and therefore doesn't lock the file >> mapping. Checking can_vma_merge_after() ensures that new anonymous >> VMAs can't be merged into file VMAs. >> >> See https://lore.kernel.org/linux-mm/CAG48ez1tJZTOjS_FjRZhvtDA-STFmdw8PEizPDwMGFd_ui0Nrw@mail.gmail.com/ And yeah, that URL should have been a Link: in the patch. And the scenario it's fixing described in a bit more detail? > I guess the point is that if we fix it still within 6.1, we don't have to > devise how exactly this is exploitable, but due to the insufficient locking > it most likely is, right?