Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp692716ybh; Wed, 15 Jul 2020 12:39:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOMlzsFiKMFXRZSfn2aSiEcUCWrlrMrmjfIzhs5qn2X3sapalQm2/KAEciQsKNFfQ6F2su X-Received: by 2002:a17:906:3650:: with SMTP id r16mr458660ejb.465.1594841984876; Wed, 15 Jul 2020 12:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594841984; cv=none; d=google.com; s=arc-20160816; b=uaxhYwXGOXg2tO2hMDLeZenJcgayO3r7CgYnJThNzyHMqDk+Ik3OiKluWp5qSy4VuK tJUdtTGNOQhPhrbjCSfNZDB5xBmFVjkQnYEjcJOfQVHgtBcekvUO22f+9dhnYLZJor0M LJJOl89YBrTnzPMqjkr66cdmhP51wOTrm4PxXXx7QuZSQt7w3QUJEDwTfnK/eSOGFvx1 jxvKRbxogJhRG1dQmH2sUFWiS+blcmtZcWGhYlNNBxViz2z97qqhkN7HHs2Sb7+x5uzL ZEzbdBbLLwAC+YH98pFMcut7l+e77ZRGumUEEdNnw9aeCoKq5/VOpCmTZYk5J4dYopB5 MqjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RKh/vY0BHfd36chDiUTxPLIe+Y+K5A1kkjp71EXwdcE=; b=SA4GyMySALVEXhcWnrLlVPe/R7QRrimdrVXrOfQgqlMxpzltXC7Fc4GTskYzphXCch buNWXEU26eIE4cpojaWD/U2H1d7zKRz4MevuaHzslz3irmPLsCxc86e776U5DS5G2RkI t7PdCcaDaXhNLPMYaI4RgbADy1t+PgVr71wuqTiDRKQ+2dg6lOFvzQ8mlv/iGez3RY7G AoqhEcqq3M8auPC6r6Cy4HmUKM/VGg1T8uXP7HD6hpApeHhZawUaj53G27YS6RHMZYE9 0Ij7JKiE0uG15XqzzL5ktmellF984sDqz6rTrpi7mCikFQsGDhKpGJnEPQwHuRB/FJax DUFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NFYcAm9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si1754907edy.598.2020.07.15.12.39.21; Wed, 15 Jul 2020 12:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NFYcAm9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgGOTiX (ORCPT + 99 others); Wed, 15 Jul 2020 15:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgGOTiW (ORCPT ); Wed, 15 Jul 2020 15:38:22 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F13BC061755 for ; Wed, 15 Jul 2020 12:38:22 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id gc9so3574477pjb.2 for ; Wed, 15 Jul 2020 12:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RKh/vY0BHfd36chDiUTxPLIe+Y+K5A1kkjp71EXwdcE=; b=NFYcAm9wvunsDT3O6rABAEXZUTIq2xx4gdZaR6QtXqGqFitWX01bZktZ25OsD3VwlD 3/RQ9NAAf/BOwnZdQd94jtfO4wkkgYuv4pcx1BtleMgckxJL01rUX371k90SIoMIb9ib X+OmPNF1QYkG3wvnjg47HV51rzX9ADmRkZVR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RKh/vY0BHfd36chDiUTxPLIe+Y+K5A1kkjp71EXwdcE=; b=qrWAhoGQpbpzst7NddyAXrnfZshct1nGSGJdxrHOadFp8L1U0d4rfAUz4XrJ2nBdrb A5vZWlFLQy/G53mRBvpLdbaZV3c/tOrX+RmpNt9Pm1bHP5wyNiBsjgBEIy4A6sqGX3cV D9bFOKfHuTsVslhWXy3/MjzCiIW9Fthpl28/x6Z1ZHoQRxYTMtC31tMZ/y9KnB5B/ztW DSJo68Q0Ek7RtrTMAnZPOY5YaYaoYS2keP/lOM/RLHkNmAZDNMBOhE3DbLV36iTgQYHl ZpW2EhCN68pIG8Dly4KbvEW/MtHwM+FJVHcSxIhxlzuu0NUTyK8+XWqaQ38MntwPhqf5 65WA== X-Gm-Message-State: AOAM533i+5pmOAP5p9IaoH8kT4I777UagU1I/b8b6Ub3WsWOnRpmd0CB rT2YELCcVX6VWqD8nsvu/7Hnjg== X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr857212plk.192.1594841901705; Wed, 15 Jul 2020 12:38:21 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y10sm2800537pfn.121.2020.07.15.12.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 12:38:20 -0700 (PDT) Date: Wed, 15 Jul 2020 12:38:19 -0700 From: Kees Cook To: Masami Hiramatsu Cc: Jarkko Sakkinen , linux-kernel@vger.kernel.org, x86@vger.kernel.org, Andi Kleen , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jessica Yu , Andrew Morton , "Aneesh Kumar K.V" , Will Deacon , Sami Tolvanen , Alexandre Ghiti , Masahiro Yamada , Peter Collingbourne , Frederic Weisbecker , Krzysztof Kozlowski , Arnd Bergmann , Stephen Boyd , Andy Lutomirski , Josh Poimboeuf , Miroslav Benes , Babu Moger , Omar Sandoval , Nayna Jain , Marco Elver , Brian Gerst , Jiri Kosina , Joe Lawrence , Mike Rapoport Subject: Re: [PATCH v3 1/3] kprobes: Add text_alloc() and text_free() Message-ID: <202007151236.FE6CA96261@keescook> References: <20200714223239.1543716-1-jarkko.sakkinen@linux.intel.com> <20200714223239.1543716-2-jarkko.sakkinen@linux.intel.com> <20200715172732.35110a4e53e84fcec9aeac83@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200715172732.35110a4e53e84fcec9aeac83@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 05:27:32PM +0900, Masami Hiramatsu wrote: > > On Wed, 15 Jul 2020 01:32:27 +0300 > Jarkko Sakkinen wrote: > > [...] > > -void *module_alloc(unsigned long size) > > -{ > > - void *p; > > - > > - if (PAGE_ALIGN(size) > MODULES_LEN) > > - return NULL; > > - > > - p = __vmalloc_node_range(size, MODULE_ALIGN, > > - MODULES_VADDR + get_module_load_offset(), > > - MODULES_END, GFP_KERNEL, > > - PAGE_KERNEL, 0, NUMA_NO_NODE, > > - __builtin_return_address(0)); > > - if (p && (kasan_module_alloc(p, size) < 0)) { > > - vfree(p); > > - return NULL; > > - } > > - > > - return p; > > -} > > Please don't touch this module_alloc() at all. Then we can > just call __vmalloc_node_range() in the text_alloc(). Hm? I thought the requirement was that trampolines needed to stay within a certain distance of kernel text and that the module_alloc() enforced that? -- Kees Cook