Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2272138ybd; Mon, 24 Jun 2019 03:41:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9qsnYLxQfPHR9VhrLCaBdFHpV5u39p1DEdLAcc3GZ+c2O1DSyjwgsQ+2lHV/nCx2jmIuR X-Received: by 2002:a63:6981:: with SMTP id e123mr31722334pgc.136.1561372889802; Mon, 24 Jun 2019 03:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561372889; cv=none; d=google.com; s=arc-20160816; b=0vS8+5DjnQJgteX0Pr10uF5Ys+7Xkpv1OWp+MEt8/YOHXQLJyYLv99UVIgj7JOYtLp aLkji1ll7z3frKRpaoQjbbU322hQ0YvrfZT0cMV/HCv+gu6wLUvoHsGvgQVRx7iya1tO LsE7677w2DKC69NaHNFeQe89mzHJYsnFxLHzCvVwKdUBBGto3+Mo85tpEOsujmMXSuz1 9oouH+Lke/VSD+FIvoon4W1nRGSmYKkeUeS/90COtNI4pMEc+u57PtVdH8+W8BK+rk/H e8psBlgWN1ufgYFp41jmtWF81J6vRXxLzH0WXAbUIQ+9FgE/nmpo+lpYInBfzUXbr+db xr+w== 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=FPyOWU/AWRjh8q8+wraQEm79ciIqJve+QuqtS274Nvc=; b=i83dD6UURGLf44KKuxMXFKoUS3GsiMQpiFqKD8o55cNxUqvHHvJfpIjkgtY6L/tFa5 yn2+6QADrh6yRE3s5XzjbfVA7uNxmd4gRwKcVLJ/jA0MJpEFVndNs4EusITbJs9yrVM2 YhEkM10wJ2Ewh6y6K87UHY8PWgHyTUUvlgghrmD9Zf/FFWv4xcVlhcjw8IUvIpxotnB8 55tdk/gLHhY1iMDgNTUTE3LNg9bvjsFxQtKSv67LAgSQRKqCu7+MjwZjABaCPIwnIgpS iJ3jLR8AO5U+8XrO8D0khhSl191ztHncCZjdTEaeaP9O1vhLsp79ExrM4gqlTc4rZDfN DRjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KeLZOGsV; 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 w188si10661524pfd.283.2019.06.24.03.41.14; Mon, 24 Jun 2019 03:41:29 -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=KeLZOGsV; 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 S1729232AbfFXKk7 (ORCPT + 99 others); Mon, 24 Jun 2019 06:40:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728950AbfFXKk6 (ORCPT ); Mon, 24 Jun 2019 06:40:58 -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 DA341208E4; Mon, 24 Jun 2019 10:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561372858; bh=2dFfTEoWp60ECXsMUMfLHSUmkyf/mCTPGHT9AHfNTTI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KeLZOGsVIf33b6a/jBmrgyAu9CW9olZa/r5DJReovMFfccT8yDgE227sNpYUnbjKt URN09Ki/8OKLOHtgz5J2wV60o6rWc/cFRTv0oTi16aiPf0ac07b170NBBpFxGIL5lx A7oUZ6PpsXVhZg6HYZU3sZ5oio240itAk0RPH7+s= Date: Mon, 24 Jun 2019 12:40:54 +0200 From: Jessica Yu To: Yang Yingliang Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, namit@vmware.com, cj.chengjian@huawei.com Subject: Re: [PATCH v2] modules: fix BUG when load module with rodata=n Message-ID: <20190624104053.GA22519@linux-8ccs> References: <1560997094-19920-1-git-send-email-yangyingliang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1560997094-19920-1-git-send-email-yangyingliang@huawei.com> 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 +++ Yang Yingliang [20/06/19 10:18 +0800]: >When loading a module with rodata=n, it causes an executing >NX-protected page BUG. > >[ 32.379191] kernel tried to execute NX-protected page - exploit attempt? (uid: 0) >[ 32.382917] BUG: unable to handle page fault for address: ffffffffc0005000 >[ 32.385947] #PF: supervisor instruction fetch in kernel mode >[ 32.387662] #PF: error_code(0x0011) - permissions violation >[ 32.389352] PGD 240c067 P4D 240c067 PUD 240e067 PMD 421a52067 PTE 8000000421a53063 >[ 32.391396] Oops: 0011 [#1] SMP PTI >[ 32.392478] CPU: 7 PID: 2697 Comm: insmod Tainted: G O 5.2.0-rc5+ #202 >[ 32.394588] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 >[ 32.398157] RIP: 0010:ko_test_init+0x0/0x1000 [ko_test] >[ 32.399662] Code: Bad RIP value. >[ 32.400621] RSP: 0018:ffffc900029f3ca8 EFLAGS: 00010246 >[ 32.402171] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 >[ 32.404332] RDX: 00000000000004c7 RSI: 0000000000000cc0 RDI: ffffffffc0005000 >[ 32.406347] RBP: ffffffffc0005000 R08: ffff88842fbebc40 R09: ffffffff810ede4a >[ 32.408392] R10: ffffea00108e3480 R11: 0000000000000000 R12: ffff88842bee21a0 >[ 32.410472] R13: 0000000000000001 R14: 0000000000000001 R15: ffffc900029f3e78 >[ 32.412609] FS: 00007fb4f0c0a700(0000) GS:ffff88842fbc0000(0000) knlGS:0000000000000000 >[ 32.414722] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >[ 32.416290] CR2: ffffffffc0004fd6 CR3: 0000000421a90004 CR4: 0000000000020ee0 >[ 32.418471] Call Trace: >[ 32.419136] do_one_initcall+0x41/0x1df >[ 32.420199] ? _cond_resched+0x10/0x40 >[ 32.421433] ? kmem_cache_alloc_trace+0x36/0x160 >[ 32.422827] do_init_module+0x56/0x1f7 >[ 32.423946] load_module+0x1e67/0x2580 >[ 32.424947] ? __alloc_pages_nodemask+0x150/0x2c0 >[ 32.426413] ? map_vm_area+0x2d/0x40 >[ 32.427530] ? __vmalloc_node_range+0x1ef/0x260 >[ 32.428850] ? __do_sys_init_module+0x135/0x170 >[ 32.430060] ? _cond_resched+0x10/0x40 >[ 32.431249] __do_sys_init_module+0x135/0x170 >[ 32.432547] do_syscall_64+0x43/0x120 >[ 32.433853] entry_SYSCALL_64_after_hwframe+0x44/0xa9 > >Because if rodata=n, set_memory_x() cann't be called, fix this by >calling set_memory_x in complete_formation(); > >v1 -> v2: > Remove empty lines between the frob_* calls. > >Fixes: f2c65fb3221a ("x86/modules: Avoid breaking W^X while loading modules") >Suggested-by: Jian Cheng >Reviewed-by: Nadav Amit >Signed-off-by: Yang Yingliang Applied, thanks for the fix! Jessica