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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52115C00140 for ; Tue, 2 Aug 2022 12:33:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFE988E0001; Tue, 2 Aug 2022 08:33:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BABB66B0072; Tue, 2 Aug 2022 08:33:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4CB18E0001; Tue, 2 Aug 2022 08:33:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 92A346B0071 for ; Tue, 2 Aug 2022 08:33:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5D6CE80F56 for ; Tue, 2 Aug 2022 12:33:49 +0000 (UTC) X-FDA: 79754594178.30.7B2F5F4 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) by imf28.hostedemail.com (Postfix) with ESMTP id 7B4E0C004A for ; Tue, 2 Aug 2022 12:33:48 +0000 (UTC) Received: from pps.filterd (m0167072.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 272CXl28012834 for ; Tue, 2 Aug 2022 08:33:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type; s=pps01; bh=ku5KvA6VkinwaOqwI9wQRf1ZytlqCPPzclpUbpwzSpw=; b=qop7OVeRiTS66qBAvmvhHU3/YaVI30dRhIWrTIZI8Jv+5qL39IceKB8hGVkdj1/Xd++Y Cis7oizpdwviTGKDdtc8crfYeIubZ2gL3tOA4yvfn9soKDeXhELr9myXMa8KTSVTUEZq WrxJhbBKQqqgrwyyo/dvGvARMFzyZKIBbNpu4ypPyB1/iCnw/CiGYXv5UYWvfRCyMplF KoSf0ay0nuQFh7dxLTlbnnfmyRRug9qKHvGkWyGQbTsbrYkSbIAQ89F8A7TLP8mh/+An OOMCUutIwwjZ0x1mx7L8TP6hLTc/Wg/z3FCMXaOmAmF2nzpTriCJxndec9nA7ranSMW3 gw== Received: from sendprdmail21.cc.columbia.edu (sendprdmail21.cc.columbia.edu [128.59.72.23]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 3hn0tw2npv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 02 Aug 2022 08:33:46 -0400 Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by sendprdmail21.cc.columbia.edu (8.14.7/8.14.4) with ESMTP id 272CXjFp036957 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 2 Aug 2022 08:33:45 -0400 Received: by mail-vs1-f70.google.com with SMTP id h4-20020a056102104400b003853ac8eb11so513732vsq.17 for ; Tue, 02 Aug 2022 05:33:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=ku5KvA6VkinwaOqwI9wQRf1ZytlqCPPzclpUbpwzSpw=; b=L/bu+sLuCEKoeRLwAqGJgOJDKBHIICQWgkSvm0GnOEXOJhrvDJm8WV863qEmfBrQgY YvHbZnTPa3LifwvSIdOAkNnUffdNvBlZZuwIpyMvhZNe3HSDxazw47z7+C+uXLJgLtnB 8lLLdsbqR17V0V0FGu7BY3J3MOFhzXByR46ZyYtNFR4dNV4ffauQB2VcQN8D2PpAeRCe Gbfz5kehGvFsI6iHVk5iNh2zi6Z7gfsP+2e9hRoNDFaPANNmRYSe3bkYILn1p1Af/tG0 Sj7syJfReCmTMBryfLTWwIGW5wuHjkVam1ZqQmEXhHIC8OWJVmH4WlfipAzpEchqmft1 nZ0g== X-Gm-Message-State: ACgBeo3bYBx3RkdsASZj+JPhwCu99MQ70RdwY3NoyxD5X7LUUEMYuIVo DBIif/KDiOCOpxCNGlNr1nX64x7EkeztVbkEEkrEPcOXUStSjCRPHGM1SPRblV9VhDWXGEmeN8R K1aDvOek8nWeBdOc3KIi4udkA2rHjHO4VZPw= X-Received: by 2002:a05:6102:5490:b0:380:3982:2f97 with SMTP id bk16-20020a056102549000b0038039822f97mr3959528vsb.84.1659443624853; Tue, 02 Aug 2022 05:33:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR6fb70xO9KVOS/juIZ++hdIYQ5s9kjFe69xl6RDBUtR5S4s4RlfFOAYfy/wnUgq/5agAGdZJSr2fbb0qJDzNuQ= X-Received: by 2002:a05:6102:5490:b0:380:3982:2f97 with SMTP id bk16-20020a056102549000b0038039822f97mr3959509vsb.84.1659443624403; Tue, 02 Aug 2022 05:33:44 -0700 (PDT) MIME-Version: 1.0 References: <869d0338-a895-c2c4-17a6-08ba307911a0@huawei.com> In-Reply-To: <869d0338-a895-c2c4-17a6-08ba307911a0@huawei.com> From: Gabriel Ryan Date: Tue, 2 Aug 2022 08:33:33 -0400 Message-ID: Subject: Re: Race in mm/ksm.c To: Kefeng Wang Cc: abhishek.shah@columbia.edu, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: multipart/alternative; boundary="000000000000c1f77005e5415319" X-Proofpoint-ORIG-GUID: EKAdZBt5-RUa7Qvk9miv4VcGul2EZRjA X-Proofpoint-GUID: EKAdZBt5-RUa7Qvk9miv4VcGul2EZRjA X-CU-OB: Yes X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-02_07,2022-08-02_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 clxscore=1015 impostorscore=10 phishscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 suspectscore=0 lowpriorityscore=10 mlxscore=0 bulkscore=10 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208020057 ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=columbia.edu header.s=pps01 header.b=qop7OVeR; spf=pass (imf28.hostedemail.com: domain of gr2547@columbia.edu designates 148.163.135.74 as permitted sender) smtp.mailfrom=gr2547@columbia.edu; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659443628; a=rsa-sha256; cv=none; b=a92w60mh2C+AQUP1O1R1AQ6gV+es2dYDdUZp1Uy7ZudsBWCyGv0plnR19vAE3Z/TB5xdJo pPyn+BTP6zKhSe1e1jjso568UmyBpiKuTkWnsmvSFTZpnwToLLdkOp4CDuftYrujofK+pP ln4uqKQJv8K703ln/cOwtLEk9tThwSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659443628; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ku5KvA6VkinwaOqwI9wQRf1ZytlqCPPzclpUbpwzSpw=; b=Kdjr7Y7crKYY9vm97uk+Hpj3nDGHKUUVEMBg/BbqbBKYrHy8C/QKguCme7ahSMkovTYQ8W M8dBI2prDAwcNngMS3cTANes4g3ScEpv2RBb5bl1ebsRAKm5909krGJu4TBJ+glrwfwWUT HcKkUWyWefbqx08uapau1sEHyYw/E+s= X-Stat-Signature: 6771isk6mt3qw17h3zp498ejqaqzzdy7 X-Rspamd-Queue-Id: 7B4E0C004A Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=columbia.edu header.s=pps01 header.b=qop7OVeR; spf=pass (imf28.hostedemail.com: domain of gr2547@columbia.edu designates 148.163.135.74 as permitted sender) smtp.mailfrom=gr2547@columbia.edu; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1659443628-222492 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: --000000000000c1f77005e5415319 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yes, we are unable to trigger the reported race after applying your patch, and by inspection the patch appears to have fixed the issue by extending ksm_thread_mutex to cover the ksm_run flag check in __ksm_enter. We have also contacted the kernel security team since the race may have security implications. Thanks, Gabe On Tue, Aug 2, 2022 at 8:18 AM Kefeng Wang wrote: > > On 2022/8/2 19:44, Gabriel Ryan wrote: > > Confirmed. > > It means that the following changes could fix the issue, right? > > If so, I will send a formal patch with your report and test, thanks. > > > Thanks for the quick response and apologies for the delay! > > Best, > > Gabe > > On Thu, Jul 21, 2022 at 9:57 PM Kefeng Wang > wrote: > >> >> On 2022/7/21 23:58, Abhishek Shah wrote: >> >> Dear Kernel Maintainers, >> >> We found a race in mm/ksm.c. During the execution of the function >> *__ksm_run* which uses variable *ksm_run* to decide the list insertion >> point, the variable *ksm_run* can be concurrently modified in the >> function *run_store*, which we thought could be undesirable since =E2=80= =9CKSM >> pages in newly forked mms can be missed=E2=80=9D (See comment here: >> https://elixir.bootlin.com/linux/v5.18-rc5/source/mm/ksm.c#L2498). We >> would also like your thoughts on the security impact given it is a TOCTO= U >> bug. >> >> We provide more details below including the trace and reproducing >> test cases. >> >> >> Hello=EF=BC=8C could the following changes to avoid the data-race issue= =EF=BC=9F >> >> diff --git a/mm/ksm.c b/mm/ksm.c >> index 54f78c9eecae..f072753cbb3a 100644 >> --- a/mm/ksm.c >> +++ b/mm/ksm.c >> @@ -2497,6 +2497,7 @@ int __ksm_enter(struct mm_struct *mm) >> { >> struct mm_slot *mm_slot; >> int needs_wakeup; >> + bool ksm_run_merge; >> >> mm_slot =3D alloc_mm_slot(); >> if (!mm_slot) >> @@ -2505,6 +2506,10 @@ int __ksm_enter(struct mm_struct *mm) >> /* Check ksm_run too? Would need tighter locking */ >> needs_wakeup =3D list_empty(&ksm_mm_head.mm_list); >> >> + mutex_lock(&ksm_thread_mutex); >> + ksm_run_unmerge =3D !!(ksm_run & KSM_RUN_UNMERGE); >> + mutex_unlock(&ksm_thread_mutex); >> + >> spin_lock(&ksm_mmlist_lock); >> insert_to_mm_slots_hash(mm, mm_slot); >> /* >> @@ -2517,7 +2522,7 @@ int __ksm_enter(struct mm_struct *mm) >> * scanning cursor, otherwise KSM pages in newly forked mms will >> be >> * missed: then we might as well insert at the end of the list. >> */ >> - if (ksm_run & KSM_RUN_UNMERGE) >> + if (ksm_run_unmerge) >> list_add_tail(&mm_slot->mm_list, &ksm_mm_head.mm_list); >> else >> list_add_tail(&mm_slot->mm_list, >> &ksm_scan.mm_slot->mm_list); >> >> >> >> >> *Trace* >> BUG: KCSAN: data-race in __ksm_enter / run_store >> write to 0xffffffff881edae0 of 8 bytes by task 6542 on cpu 0: >> run_store+0x19a/0x2d0 mm/ksm.c:2897 >> kobj_attr_store+0x44/0x60 lib/kobject.c:824 >> sysfs_kf_write+0x16f/0x1a0 fs/sysfs/file.c:136 >> kernfs_fop_write_iter+0x2ae/0x370 fs/kernfs/file.c:291 >> call_write_iter include/linux/fs.h:2050 [inline] >> new_sync_write fs/read_write.c:504 [inline] >> vfs_write+0x779/0x900 fs/read_write.c:591 >> ksys_write+0xde/0x190 fs/read_write.c:644 >> __do_sys_write fs/read_write.c:656 [inline] >> __se_sys_write fs/read_write.c:653 [inline] >> __x64_sys_write+0x43/0x50 fs/read_write.c:653 >> do_syscall_x64 arch/x86/entry/common.c:50 [inline] >> do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80 >> entry_SYSCALL_64_after_hwframe+0x44/0xae >> >> read to 0xffffffff881edae0 of 8 bytes by task 6541 on cpu 1: >> __ksm_enter+0x114/0x260 mm/ksm.c:2501 >> ksm_madvise+0x291/0x350 mm/ksm.c:2451 >> madvise_vma_behavior mm/madvise.c:1039 [inline] >> madvise_walk_vmas mm/madvise.c:1221 [inline] >> do_madvise+0x656/0xeb0 mm/madvise.c:1399 >> __do_sys_madvise mm/madvise.c:1412 [inline] >> __se_sys_madvise mm/madvise.c:1410 [inline] >> __x64_sys_madvise+0x64/0x70 mm/madvise.c:1410 >> do_syscall_x64 arch/x86/entry/common.c:50 [inline] >> do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80 >> entry_SYSCALL_64_after_hwframe+0x44/0xae >> >> Reported by Kernel Concurrency Sanitizer on: >> CPU: 1 PID: 6541 Comm: syz-executor2-n Not tainted 5.18.0-rc5+ #107 >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 >> 04/01/2014 >> --------------------- >> *Inputs * >> Input CPU 0: >> r0 =3D openat$sysctl(0xffffff9c, >> &(0x7f0000000100)=3D'/sys/kernel/mm/ksm/run\x00', 0x1, 0x0) >> write$sysctl(r0, &(0x7f0000000000)=3D'2\x00', 0x2) >> >> Input CPU 1: >> madvise(&(0x7f0000ffc000/0x4000)=3Dnil, 0x4000, 0xc) >> mlock2(&(0x7f0000ffe000/0x2000)=3Dnil, 0x2000, 0x0) >> madvise(&(0x7f0000ffd000/0x3000)=3Dnil, 0x3000, 0x12) >> clone(0x0, 0x0, 0x0, 0x0, 0x0) >> >> --000000000000c1f77005e5415319 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yes, we are unable to trigger the reported race after= applying your patch, and by inspection the patch appears to have fixed the= issue by extending=20 ksm_thread_mutex to cover the ksm_run flag check in __ksm_enter.
<= div>
We have also contacted the kernel security team since th= e race may have security implications.

Thanks,=

Gabe

On Tue, Aug 2, 2022 at 8:18 AM Kefe= ng Wang <wangkefeng.wang@h= uawei.com> wrote:
=20 =20 =20


On 2022/8/2 19:44, Gabriel Ryan wrote:
=20
Confirmed.

It means that the following changes could fix the issue, right?

If so, I will send a formal patch with your report and test, thanks.


Thanks for the quick response and apologies for the delay!

Best,

Gabe

On Thu, Jul 21, 2022 at 9:57 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:


On 2022/7/21 23:58, Abhishek Shah wrote:
Dear=C2=A0Kernel Maintainers,

We found a race in=C2=A0mm/ksm.c.=C2=A0During th= e execution of the function=C2=A0__ksm_run=C2=A0wh= ich uses variable=C2=A0ksm_run=C2=A0to decide the li= st insertion point, the variable=C2=A0ksm_run=C2=A0= can be concurrently modified in the function=C2=A0run_store= , which we thought could be undesirable since =E2=80=9CKS= M pages in newly forked mms can be missed=E2=80=9D (See comment here:=C2=A0https://elixir.bootlin.com/linux/v5.18-rc5/sou= rce/mm/ksm.c#L2498). We would also like your=C2=A0thoughts on the security impact given it is a TOCTOU bug.=C2=A0=C2=A0

We provide more=C2=A0details=C2=A0below includin= g the trace and reproducing test=C2=A0cases.


Hello=EF=BC=8C could the following changes to avoid the data= -race issue=EF=BC=9F

diff --git a/mm/ksm.c b/mm/ksm.c
index 54f78c9eecae..f072753cbb3a 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2497,6 +2497,7 @@ int __ksm_enter(struct mm_struct *mm)
=C2=A0{
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct mm_slot *mm= _slot;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int needs_wakeup;<= br> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool ksm_run_merge;
=C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mm_slot =3D alloc_= mm_slot();
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!mm_slot)
@@ -2505,6 +2506,10 @@ int __ksm_enter(struct mm_struct *mm)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Check ksm_run t= oo?=C2=A0 Would need tighter locking */
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 needs_wakeup =3D list_empty(&ksm_mm_head.mm_list);
=C2=A0
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mutex_lock(&ksm_thr= ead_mutex);
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ksm_run_unmerge =3D !!(= ksm_run & KSM_RUN_UNMERGE);
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mutex_unlock(&ksm_t= hread_mutex);
+
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_lock(&ksm= _mmlist_lock);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 insert_to_mm_slots= _hash(mm, mm_slot);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*
@@ -2517,7 +2522,7 @@ int __ksm_enter(struct mm_struct *mm)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * scanning c= ursor, otherwise KSM pages in newly forked mms will be
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * missed: th= en we might as well insert at the end of the list.
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */
-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ksm_run & KSM_R= UN_UNMERGE)
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ksm_run_unmerge) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 list_add_tail(&mm_slot->mm_list, &ksm_mm_head.mm_list);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 list_add_tail(&mm_slot->mm_list, &ksm_scan.mm_slot->mm_list);




Trace
BUG: KCSAN: data-race in __ksm_enter / run_store
write to 0xffffffff881edae0 of 8 bytes by task 6542 on cpu 0:
=C2=A0run_store+0x19a/0x2d0 mm/ksm.c:2897
=C2=A0kobj_attr_store+0x44/0x60 lib/kobject.c:824
=C2=A0sysfs_kf_write+0x16f/0x1a0 fs/sysfs/file.c:136
=C2=A0kernfs_fop_write_iter+0x2ae/0x370 fs/kernfs/file.c:291
=C2=A0call_write_iter include/linux/fs.h:2050 [inline] =C2=A0new_sync_write fs/read_write.c:504 [inline]
=C2=A0vfs_write+0x779/0x900 fs/read_write.c:591
=C2=A0ksys_write+0xde/0x190 fs/read_write.c:644
=C2=A0__do_sys_write fs/read_write.c:656 [inline]
=C2=A0__se_sys_write fs/read_write.c:653 [inline]
=C2=A0__x64_sys_write+0x43/0x50 fs/read_write.c:653
=C2=A0do_syscall_x64 arch/x86/entry/common.c:50 [inline]<= br> =C2=A0do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80<= br> =C2=A0entry_SYSCALL_64_after_hwframe+0x44/0xae

read to 0xffffffff881edae0 of 8 bytes by task 6541 on cpu 1:
=C2=A0__ksm_enter+0x114/0x260 mm/ksm.c:2501
=C2=A0ksm_madvise+0x291/0x350 mm/ksm.c:2451
=C2=A0madvise_vma_behavior mm/madvise.c:1039 [inline]
=C2=A0madvise_walk_vmas mm/madvise.c:1221 [inline]
=C2=A0do_madvise+0x656/0xeb0 mm/madvise.c:1399
=C2=A0__do_sys_madvise mm/madvise.c:1412 [inline]
=C2=A0__se_sys_madvise mm/madvise.c:1410 [inline]
=C2=A0__x64_sys_madvise+0x64/0x70 mm/madvise.c:1410
=C2=A0do_syscall_x64 arch/x86/entry/common.c:50 [inline]<= br> =C2=A0do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80<= br> =C2=A0entry_SYSCALL_64_after_hwframe+0x44/0xae

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 6541 Comm: syz-executor2-n Not tainted 5.18.0-rc5+ #107
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
---------------------
Inputs=C2=A0
Input CPU 0:
r0 =3D openat$sysctl(0xffffff9c, &(0x7f0000000100)=3D'/sys/kernel/mm/ksm/run\x00&#= 39;, 0x1, 0x0)
write$sysctl(r0, &(0x7f0000000000)=3D'2\x00',= 0x2)

Input CPU 1:
madvise(&(0x7f0000ffc000/0x4000)=3Dnil, 0x4000, 0xc)<= br> mlock2(&(0x7f0000ffe000/0x2000)=3Dnil, 0x2000, 0x0) madvise(&(0x7f0000ffd000/0x3000)=3Dnil, 0x3000, 0x12)
clone(0x0, 0x0, 0x0, 0x0, 0x0)
--000000000000c1f77005e5415319--