Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1722819rdb; Wed, 31 Jan 2024 07:17:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQa27shRitfwyqukmvE0f+C/4LSUaVDCvW0TQy4n4daiy153arlnvQ98QZeOhTjvZ6puNd X-Received: by 2002:a05:620a:3883:b0:783:8400:5666 with SMTP id qp3-20020a05620a388300b0078384005666mr1522596qkn.1.1706714264353; Wed, 31 Jan 2024 07:17:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706714264; cv=pass; d=google.com; s=arc-20160816; b=U4XT5YktLhB2OjPOR8CWeHXwvopIsgSKtdnvNR8r3Qh2dCgvC/eKpJN0Y6xp83b0mt yucB9knJWf1aBSe6s0dKHWB9+tprQvD+FFUyx3QFGnEAQK3Boe3mVhiNM6wCTRoQ27A0 u5qycvZ0sNzgnN4mi1aBIllDMMQjXGewMNT0o5rLBG6231BAdtk5t3Q1lC5oI38+60vo kC4ealUyoze4AIqHCDVo02QGxEkVwjsDpMDQk8VqoOZfaSIDkca4kNpvsZvHU7YOY3m4 Dn2n4SNWF3AgEdhq5VJjH5yj6JVfNtA4KqCn2jAWiG80ae65PSWueDtuzzwH7GkWnX2Y li7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:content-transfer-encoding:in-reply-to:from:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-filter; bh=vyZV6sJ+C4Ph/Q7b2FdAoMgA3iIBfoctDx1VoKpawe0=; fh=2v1d1JvqEQ0JEdvZ4j166NkOgIoJZz+EeNZtZqapggw=; b=TthSzFoLA4aGuRpdfwHzVIzAVJNAmXnLVORHa7pcVlk6XikjOVdLFzosFQIp8ncCPr olrYAqhnYaGpi0UYiKHwYqQmQWYrI/003UUVLfWE/jmCdT4gM2k9o/OHZY9PjK0AGRt4 hvYtdhzyHPpJVAtc9eRfyOf2z+gq/Bg8vAftFmMT1PBUVAzO+QyhcbaNz5pww0oCUWGG EHRwFg0mS5pSA1gBOw+Dy34v/DbyWB/70OzQLbC3LRP59kehmcSwK8iuNilbk8joQy1P +uyAKuNJcM4R9Pth748l4PYxd/1d4J/feH7mBmi7uSvJIhooVoUrroc13LITm0mLVZg4 y4sA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Xsu0+3xu; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-46698-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46698-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=1; AJvYcCXrOWx6MI1UXtXYJVN1QdIHMzafFPMhojo4XFlJgI8tLpmVtE5UtevZSEc3qN+7t/koTdUZMWuYGXT/VgVsUIGTMV1OgNrg0hmg42uVWQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j11-20020a37c24b000000b00783ad67e5c2si6656227qkm.552.2024.01.31.07.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 07:17:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46698-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Xsu0+3xu; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-46698-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46698-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 14AC91C21517 for ; Wed, 31 Jan 2024 15:17:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF9D484A53; Wed, 31 Jan 2024 15:17:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Xsu0+3xu" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A30F684A26 for ; Wed, 31 Jan 2024 15:17:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706714253; cv=none; b=nt3qpqjEXrKqFTsSJhM5TIEos3pSmnbfx4N9/fYErlozl07ZpF+b6aKvUWIOCEKE1EY0hZnumZu9vusas4J28Fe0uz81gEnNsQtxvG+LGWI0akvHQOckhyXmkWtN4XDZkYE7mVONrVHCsE7tMK3gPN71Hhf6wovZjzEFIfNoDn0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706714253; c=relaxed/simple; bh=go2Tk9dnTNQsudjqHQZUVgsKBrOWMQALIsPbF0JTnB0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=eO4XOuCNi+V/GOK4Ezk/Ck86IM69zkbDamwXXXDlGwrVn0Q9fKn5MLLuPmPqg1xWHnhtrrxHL8U5AmSsw4bVd0kjoY0tPMvvLFJI2SEBsiEDTbqV3mPtu3e0WZ5Ef6T5jc4diVP+zIMmesHqKSK/xbrh0h0mn6UmYiIa9Ehw4pg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Xsu0+3xu; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240131151721euoutp02740f52834288e6b1faf18e3526c1fbe7~vd49xy6cm2833128331euoutp02o for ; Wed, 31 Jan 2024 15:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240131151721euoutp02740f52834288e6b1faf18e3526c1fbe7~vd49xy6cm2833128331euoutp02o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1706714241; bh=vyZV6sJ+C4Ph/Q7b2FdAoMgA3iIBfoctDx1VoKpawe0=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=Xsu0+3xu7JFe65DllV2fQG+FheZxjvglMQila5Xju0CoIZqx0wuI/+f9g+s0QJ0B5 95ddurlMroQunCY3k0QgJ/gHmVr1+Be8c+y7vQoE7cvysUQSNj1t3nTvj/zjmiziJO wWg+4io4Y/TCE1tmUQ5uU3fZ3Qotuc9xdYfgVBy8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240131151721eucas1p244ec5c2fa138b032dd0a4eca093b601c~vd49ekSzQ0568505685eucas1p2d; Wed, 31 Jan 2024 15:17:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 8B.D9.09552.1846AB56; Wed, 31 Jan 2024 15:17:21 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240131151720eucas1p1f168cb17a8e5b5b7792d2b570d13e1ca~vd48-k3mq1073110731eucas1p1f; Wed, 31 Jan 2024 15:17:20 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240131151720eusmtrp125e019057189bda9bfa0d717fa4f2635~vd48_8FXr2218422184eusmtrp1C; Wed, 31 Jan 2024 15:17:20 +0000 (GMT) X-AuditID: cbfec7f5-83dff70000002550-3a-65ba6481bb82 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 8D.7E.09146.0846AB56; Wed, 31 Jan 2024 15:17:20 +0000 (GMT) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240131151720eusmtip1bea35847920a57cbd0e168925f4283eb~vd48SIPHd2088220882eusmtip1d; Wed, 31 Jan 2024 15:17:20 +0000 (GMT) Message-ID: <2febff4d-26ba-4809-a124-7add25ab3d35@samsung.com> Date: Wed, 31 Jan 2024 16:17:20 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] init: Declare rodata_enabled and mark_rodata_ro() at all time Content-Language: en-US To: Christophe Leroy , Chen-Yu Tsai , Luis Chamberlain Cc: Michael Ellerman , Nicholas Piggin , Arnd Bergmann , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-modules@vger.kernel.org" From: Marek Szyprowski In-Reply-To: <46627d92-976a-4126-b261-a4c6575e5a3e@csgroup.eu> Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKKsWRmVeSWpSXmKPExsWy7djP87qNKbtSDV4+E7H4O+kYu8WdSc/Z LS7vmsNm0TD7O6vF7+//WC1uTHjKaLGl4RCbxc8XN1gsZrRdZnXg9Pj9axKjx+yGiyweX2+e Y/JY9LKBxWPnrLvsHptWdbJ5nJ+xkNHj8ya5AI4oLpuU1JzMstQifbsErowF7x6wFPRqVHx/ /ZaxgXGjYhcjJ4eEgInEkhkPmboYuTiEBFYwSlz9PIcNJCEk8IVRYtseGYjEZ0aJeRPOscF0 HH6wmgmiaDmjxMpfdhBFHxklHn5pYgRJ8ArYSfz5d5gZxGYRUJVofPmLCSIuKHFy5hMWEFtU QF7i/q0Z7CC2sECExJpJ18DqmQXEJW49mQ9WLyJQK3Hr0Wyw85gFtjFJ/Dr9ECzBJmAo0fW2 C+wiTqBlB7dsYoFolpdo3jqbGeLSZk6J5klFXYwcQLaLROd7Q4iwsMSr41vYIWwZidOTe1hA 5ksItDNKLPh9nwnCmcAo0fD8FiNElbXEnXO/2EAGMQtoSqzfpQ8RdpRY/RikGWQ+n8SNt4IQ J/BJTNo2nRkizCvR0SYEUa0mMev4Ori1By9cYp7AqDQLKVRmIfl+FpJnZiHsXcDIsopRPLW0 ODc9tdg4L7Vcrzgxt7g0L10vOT93EyMwZZ3+d/zrDsYVrz7qHWJk4mA8xCjBwawkwrtSbmeq EG9KYmVValF+fFFpTmrxIUZpDhYlcV7VFPlUIYH0xJLU7NTUgtQimCwTB6dUA5N9tN6R9TK+ RkHn3x/cfFTKlbuIxT19sdUmjbRXfu/sBRwiz9oabnjy1OHptLAZW59y88278vnQpALPnldd Xl4NXPvN/ofcf+jtlTHjwvpk76NKS4HpbrOYGueeIxmC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Ve3ftN9Psj85eW46t3KE0nXfKt5L2nWa7arn/Xsny+LHa/nQV558ZLdb8+f3rf+3J053r 8fR00fQJll3fP/oUNe17HFzHsMZjxj0LeXuT7AvuoWttDB89lOTZm1fPe05Nt+f/ixqDW8rl ew8Xa6cf+MduuefPhU+M0+yknjJ+d2W6zXrlfFX/nWKmytvrSxTYkhL47Be/K/ErFwqY8+ED U+WHrKBZOSddFmqzxp094++W4rP+qajinfq0X9e4BVeEf9x0x/WDEktxRqKhFnNRcSIAC6yf m1wDAAA= X-CMS-MailID: 20240131151720eucas1p1f168cb17a8e5b5b7792d2b570d13e1ca X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20240130174812eucas1p166f62549457fd188fed6ed72b6b4b9cd X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240130174812eucas1p166f62549457fd188fed6ed72b6b4b9cd References: <7b5df1782e94a755b4a18733af44d17d8dd8b37b.1703149011.git.christophe.leroy@csgroup.eu> <20240130091626.GA3684878@google.com> <9e298fa7-a953-462a-96a4-56a1b4316a17@csgroup.eu> <30ddedc9-0829-4a99-9cb1-39190937981c@samsung.com> <46627d92-976a-4126-b261-a4c6575e5a3e@csgroup.eu> Hi Christophe, On 31.01.2024 12:58, Christophe Leroy wrote: > Le 30/01/2024 à 18:48, Marek Szyprowski a écrit : >> [Vous ne recevez pas souvent de courriers de m.szyprowski@samsung.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] >> >> On 30.01.2024 12:03, Christophe Leroy wrote: >>> Le 30/01/2024 à 10:16, Chen-Yu Tsai a écrit : >>>> [Vous ne recevez pas souvent de courriers de wenst@chromium.org. D?couvrez pourquoi ceci est important ? https://aka.ms/LearnAboutSenderIdentification ] >>>> >>>> On Mon, Jan 29, 2024 at 12:09:50PM -0800, Luis Chamberlain wrote: >>>>> On Thu, Dec 21, 2023 at 10:02:46AM +0100, Christophe Leroy wrote: >>>>>> Declaring rodata_enabled and mark_rodata_ro() at all time >>>>>> helps removing related #ifdefery in C files. >>>>>> >>>>>> Signed-off-by: Christophe Leroy >>>>> Very nice cleanup, thanks!, applied and pushed >>>>> >>>>> Luis >>>> On next-20240130, which has your modules-next branch, and thus this >>>> series and the other "module: Use set_memory_rox()" series applied, >>>> my kernel crashes in some very weird way. Reverting your branch >>>> makes the crash go away. >>>> >>>> I thought I'd report it right away. Maybe you folks would know what's >>>> happening here? This is on arm64. >>> That's strange, it seems to bug in module_bug_finalize() which is >>> _before_ calls to module_enable_ro() and such. >>> >>> Can you try to revert the 6 patches one by one to see which one >>> introduces the problem ? >>> >>> In reality, only patch 677bfb9db8a3 really change things. Other ones are >>> more on less only cleanup. >> I've also run into this issue with today's (20240130) linux-next on my >> test farm. The issue is not fully reproducible, so it was a bit hard to >> bisect it automatically. I've spent some time on manual testing and it >> looks that reverting the following 2 commits on top of linux-next fixes >> the problem: >> >> 65929884f868 ("modules: Remove #ifdef CONFIG_STRICT_MODULE_RWX around >> rodata_enabled") >> 677bfb9db8a3 ("module: Don't ignore errors from set_memory_XX()") >> >> This in fact means that commit 677bfb9db8a3 is responsible for this >> regression, as 65929884f868 has to be reverted only because the latter >> depends on it. Let me know what I can do to help debugging this issue. >> > Thanks for the bisect. I suspect you hit one of the errors and something > goes wrong in the error path. > > To confirm this assumption, could you try with the following change on > top of everything ? Yes, this is the problem. I've added printing a mod->name to the log. Here is a log from kernel build from next-20240130 (sometimes it even boots to shell): # dmesg | grep module_set_memory [    8.061525] module_set_memory(6, 0000000000000000, 0) name ipv6 returned -22 [    8.067543] WARNING: CPU: 3 PID: 1 at kernel/module/strict_rwx.c:22 module_set_memory+0x9c/0xb8 [    8.097821] pc : module_set_memory+0x9c/0xb8 [    8.102068] lr : module_set_memory+0x9c/0xb8 [    8.183101]  module_set_memory+0x9c/0xb8 [    8.472862] module_set_memory(6, 0000000000000000, 0) name x_tables returned -22 [    8.479215] WARNING: CPU: 2 PID: 1 at kernel/module/strict_rwx.c:22 module_set_memory+0x9c/0xb8 [    8.510978] pc : module_set_memory+0x9c/0xb8 [    8.515225] lr : module_set_memory+0x9c/0xb8 [    8.596259]  module_set_memory+0x9c/0xb8 [   10.529879] module_set_memory(6, 0000000000000000, 0) name dm_mod returned -22 [   10.536087] WARNING: CPU: 3 PID: 127 at kernel/module/strict_rwx.c:22 module_set_memory+0x9c/0xb8 [   10.568254] pc : module_set_memory+0x9c/0xb8 [   10.572501] lr : module_set_memory+0x9c/0xb8 [   10.653535]  module_set_memory+0x9c/0xb8 [   10.853177] module_set_memory(6, 0000000000000000, 0) name fuse returned -22 [   10.859196] WARNING: CPU: 5 PID: 130 at kernel/module/strict_rwx.c:22 module_set_memory+0x9c/0xb8 [   10.891382] pc : module_set_memory+0x9c/0xb8 [   10.895629] lr : module_set_memory+0x9c/0xb8 [   10.976663]  module_set_memory+0x9c/0xb8 > diff --git a/kernel/module/strict_rwx.c b/kernel/module/strict_rwx.c > index a14df9655dbe..fdf8484154dd 100644 > --- a/kernel/module/strict_rwx.c > +++ b/kernel/module/strict_rwx.c > @@ -15,9 +15,12 @@ static int module_set_memory(const struct module > *mod, enum mod_mem_type type, > int (*set_memory)(unsigned long start, int num_pages)) > { > const struct module_memory *mod_mem = &mod->mem[type]; > + int err; > > set_vm_flush_reset_perms(mod_mem->base); > - return set_memory((unsigned long)mod_mem->base, mod_mem->size >> > PAGE_SHIFT); > + err = set_memory((unsigned long)mod_mem->base, mod_mem->size >> > PAGE_SHIFT); > + WARN(err, "module_set_memory(%d, %px, %x) returned %d\n", type, > mod_mem->base, mod_mem->size, err); > + return err; > } > > /* > > > Thanks for your help > Christophe Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland