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 X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 184DCC433DB for ; Mon, 15 Mar 2021 16:25:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B20EE64F23 for ; Mon, 15 Mar 2021 16:25:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B20EE64F23 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BEF336B0036; Mon, 15 Mar 2021 12:25:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B98D76B006C; Mon, 15 Mar 2021 12:25:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DE776B0070; Mon, 15 Mar 2021 12:25:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 3F9E26B0036 for ; Mon, 15 Mar 2021 12:25:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D8723181AF5FD for ; Mon, 15 Mar 2021 16:25:14 +0000 (UTC) X-FDA: 77922633348.24.D36939B Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by imf03.hostedemail.com (Postfix) with ESMTP id 4F2ACC0909CE for ; Mon, 15 Mar 2021 15:35:14 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id n16so57572657lfb.4 for ; Mon, 15 Mar 2021 08:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bMBCcUXuOU3Fm4nhvLl0kRKLKut+Z1kVT4eqPxPAYgU=; b=MQyhYUan/Eyh3CRmjhoq2OOQD8nqcjsBArmfbP7AGxf1OAtkHWRkiLfgrUHZ41z0dg TMHsQsL+/EDOdZIhSG7eEmjZtvTOfyc6CI9WfDje7Nfs+1BFspkkHrWUSPOb88V7tLig j2ams2noeaa//hf44XgFn/yjRsRmbjVakD8wGfMsjNGNa9gwsOzBxthV48Ou9OBoizP3 cGzyhhBlIG5YAaOW+NXAkj5xPiqkYTfnBIOXynw+v5A4gwrYMPYSrhjB50fTwbBFw1B7 mGogX0pM/iu2bxI3tpI3IzSOvlvr8ICzKHe85L3ABBJjII/Niv7K3hVzMAvmYusJZHjI WH6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bMBCcUXuOU3Fm4nhvLl0kRKLKut+Z1kVT4eqPxPAYgU=; b=er7CIE6e/DafIp4F34yz7sPi2kn5UBitv/byYj1pGGODsCi8euES2DH1s9tTRXzTp9 t8NKrfieQNeUFa1KWyyjmsP/tQQohBlai7+Oezpk6F2c5NHRniSqCUfHdwGU53+3cpWf n+Sn+odSqALgWaB1A+k2FFd38jjX+4QtH0WnBzKxjf9P/9eKOAv+kYmUlW3ksUrQb5ZO qAJt4NCdGrsFlGPw6kcrcUDk/kGtPABE+tkFBCx0k4YUJHbQX0q5i2BevwGNDd2DQI3W d3io7oqzf/2wBsS2PS3uAn6K575YaMCyIeMZ1jIlZRr0ZP114hPOg16CCswj4317bIU1 c4/Q== X-Gm-Message-State: AOAM531hfy0YXZ69CYpPZ9OhVr29pxNzcYbIdkhpEHbrp7/FEUDlaehB fnCS2+jeOiiiFZMPw8McMtI= X-Google-Smtp-Source: ABdhPJz+kveInYJo1Hmjwkxo1UdBuaiZdNgw19jnqZRBR4s0izEoKzjq35SSMVeolcYVFTZC6iJ+dA== X-Received: by 2002:a05:6512:3184:: with SMTP id i4mr8625095lfe.314.1615822512436; Mon, 15 Mar 2021 08:35:12 -0700 (PDT) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id y3sm2717239lfg.6.2021.03.15.08.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 08:35:12 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 15 Mar 2021 16:35:10 +0100 To: Topi Miettinen Cc: Uladzislau Rezki , linux-hardening@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andy Lutomirski , Jann Horn , Kees Cook , Linux API , Matthew Wilcox , Mike Rapoport Subject: Re: [PATCH v4] mm/vmalloc: randomize vmalloc() allocations Message-ID: <20210315153510.GA1865@pc638.lan> References: <20210309135757.5406-1-toiwoton@gmail.com> <20210314172312.GA2085@pc638.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Stat-Signature: jcaj5o7sk3xy95nsgsjfnjqa5y316ocm X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4F2ACC0909CE Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=mail-lf1-f52.google.com; client-ip=209.85.167.52 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615822514-896889 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > On 14.3.2021 19.23, Uladzislau Rezki wrote: > > Also, using vmaloc test driver i can trigger a kernel BUG: > > > > > > [ 24.627577] kernel BUG at mm/vmalloc.c:1272! > > It seems that most tests indeed fail. Perhaps the vmalloc subsystem isn't > very robust in face of fragmented virtual memory. What could be done to fix > that? > Your patch is broken in context of checking "vend" when you try to allocate next time after first attempt. Passed "vend" is different there comparing what is checked later to figure out if an allocation failed or not: if (unlikely(addr == vend)) goto overflow; > > In this patch, I could retry __alloc_vmap_area() with the whole region after > failure of both [random, vend] and [vstart, random] but I'm not sure that > would help much. Worth a try of course. > There is no need in your second [vstart, random]. If a first bigger range has not been successful, the smaller one will never be success anyway. The best way to go here is to repeat with real [vsart:vend], if it still fails on a real range, then it will not be possible to accomplish an allocation request with given parameters. > > By the way, some of the tests in test_vmalloc.c don't check for vmalloc() > failure, for example in full_fit_alloc_test(). > Where? -- Vlad Rezki