Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4280509yba; Wed, 17 Apr 2019 08:17:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzubsG3nShIwJJkLgh+LgrM06FQxl8m+gNTU+3rMZHAx85TBysxTESEHZMVsdKfopcQPXSg X-Received: by 2002:a17:902:bb90:: with SMTP id m16mr318518pls.340.1555514255005; Wed, 17 Apr 2019 08:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555514254; cv=none; d=google.com; s=arc-20160816; b=hvEOqUiGHHjuYvrDXoGulOk3/xKdblKtb99vlIXOXzMD4yYLTYI2wRDskVd0LQgpa5 k0kpc5NCTFOgtxkHdL5yKhqBVJ2LQbknAffjxFmiLXiwjMSNTpsJbh37MNhiQXBaDNcD BEVhbFymbVhvUrsnxh3QOA6nDJ9PN05x6gcEARw3JzvsaFS8deth+hZm0yRPnAckIXgw 7v6eKq4VVdOtqhENP7EEoTJA+59cFVFsVk3JWiFrGj4MhMKuQhMe6nHd9WQ93FsfQanb 0evVISEJVRTTBLajOXIblNAwvk+gXw09hJcTawvAYpFOKYIrBN5OxSuNUZKE3gM8DfEV wBRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fC/WyYkis0ZRDKmYc+AdM+Jv7WMhXgE7SZgwqSYIyzo=; b=gwZjNjtdVqEqI2ZIFNbHpWay+74I4QSQqlXrBGUuTR4EUjIqOKd2g2B0rCMyKVqv4r tJvcRu5PO5WxAyo/Yw0AIlb42rMiv7z8s9xAfNuj8/U2QWG2Qc9D2QG4+2FVWXsjhdse cms8V06u8tyhRtPfs/dSilURxZFFbjgGlBlkxx+K7LY5WDc9SWTxkg7LkbLolMLfOgrD MZ0kl1TbBAEOqyfSuFQ38ASidahHPN5a8hRUxuUEdFFEDk0cy4/jp9R+wjgWXdCH+79Q LHDVTVWH7SUy5DRptZ9DsX0g/4CGp09ZV5BLr8A+kJRfne8tp3lmTmd+baOF82/1DOK0 aEQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fcC9YlYI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si51766526plj.345.2019.04.17.08.17.19; Wed, 17 Apr 2019 08:17:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fcC9YlYI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732268AbfDQPQY (ORCPT + 99 others); Wed, 17 Apr 2019 11:16:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729940AbfDQPQY (ORCPT ); Wed, 17 Apr 2019 11:16:24 -0400 Received: from linux-8ccs (nat.nue.novell.com [195.135.221.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9414E20645; Wed, 17 Apr 2019 15:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555514183; bh=JH2HUpdWLGb4SijG4uMgSFaNehYepgtc1BtSkXiffjo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fcC9YlYIw23SgDLWb2KU5r2Ygg7zxasDA+c/d0JSMMCi7SZP9fu7/x+3Me0OUgYJq tpBCwF9K4W3E+OidkKYDJH3AsOOq9jwOmW5xXhgaycQciwHJRA9gst0Jf+GMWxp86z lb6wEOpJ5WiSW+Q+vWKZc+6Fbv9johAfdC/ppPR0= Date: Wed, 17 Apr 2019 17:16:18 +0200 From: Jessica Yu To: Steven Rostedt Cc: Joel Fernandes , linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, keescook@chromium.org, mathieu.desnoyers@efficios.com, kernel-hardening@lists.openwall.com, kernel-team@android.com, rcu@vger.kernel.org Subject: Re: [PATCH v3 3/3] module: Make __tracepoints_ptrs as read-only Message-ID: <20190417151618.GD17099@linux-8ccs> References: <20190410195708.162185-1-joel@joelfernandes.org> <20190410195708.162185-3-joel@joelfernandes.org> <20190410161112.540017d9@gandalf.local.home> <20190410202902.GA167446@google.com> <20190410204401.62f928ca@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190410204401.62f928ca@gandalf.local.home> X-OS: Linux linux-8ccs 5.1.0-rc1-lp150.12.28-default+ x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Steven Rostedt [10/04/19 20:44 -0400]: >On Wed, 10 Apr 2019 16:29:02 -0400 >Joel Fernandes wrote: > >> The srcu structure pointer array is modified at module load time because the >> array is fixed up by the module loader at load-time with the final locations >> of the tracepoints right? Basically relocation fixups. At compile time, I >> believe it is not know what the values in the ptr array are. I believe same >> is true for the tracepoint ptrs array. >> >> Also it needs to be in a separate __tracepoint_ptrs so that this code works: >> >> >> #ifdef CONFIG_TRACEPOINTS >> mod->tracepoints_ptrs = section_objs(info, "__tracepoints_ptrs", >> sizeof(*mod->tracepoints_ptrs), >> &mod->num_tracepoints); >> #endif >> >> Did I miss some point? Thanks, > >But there's a lot of others too. Hmm, does this mean that the RO data >sections that are in modules are not set to RO? > >There's a bunch of separate sections that are RO. Just look in >include/asm-generic/vmlinux.lds.h under the RO_DATA_SECTION() macro. > >A lot of the sections saved in module.c:find_module_sections() are in >that RO_DATA when compiled as a builtin. Are they not RO when loaded via >a module? Unlike the kernel, the module loader does not rely on a linker script to determine which sections get what protections. On module load, all sections in a module are looped through and those sections without the SHF_WRITE flag will be set to RO. For example, when there is a section filled with structs declared as const or if the section was explicitly given only the SHF_ALLOC attribute, those will be read-only. As long as the sections were given the correct section attributes for read-only, it'll have read-only protection. I see this is already the case for __param and __ksymtab*/__kcrctab* sections, but I agree that a full audit would be useful to be consistent with builtin RO protections. Hope that helps, Jessica