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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37D12C433B4 for ; Fri, 2 Apr 2021 07:25:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA79D6101E for ; Fri, 2 Apr 2021 07:25:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA79D6101E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D1A2B6B0071; Fri, 2 Apr 2021 03:25:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCB566B0072; Fri, 2 Apr 2021 03:25:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6BE06B0073; Fri, 2 Apr 2021 03:25:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 9A6A46B0071 for ; Fri, 2 Apr 2021 03:25:05 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 393E0824805A for ; Fri, 2 Apr 2021 07:25:05 +0000 (UTC) X-FDA: 77986590570.35.0D1727B Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf13.hostedemail.com (Postfix) with ESMTP id 11AE6E000100 for ; Fri, 2 Apr 2021 07:25:02 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FBWhp4sB6zNs0x; Fri, 2 Apr 2021 15:22:18 +0800 (CST) Received: from [10.174.177.143] (10.174.177.143) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Fri, 2 Apr 2021 15:24:48 +0800 Subject: Re: [QUESTION] WARNNING after 3d8e2128f26a ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output") To: , , , , , CC: "zhangyi (F)" , Kefeng Wang , , "Zhengyejian (Zetta)" , Yang Yingliang , References: <5837f5d9-2235-3ac2-f3f2-712e6cf4da5c@huawei.com> From: yangerkun Message-ID: <3a321bdb-66d0-978f-cbb2-f40cbe4beb86@huawei.com> Date: Fri, 2 Apr 2021 15:24:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <5837f5d9-2235-3ac2-f3f2-712e6cf4da5c@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed X-Originating-IP: [10.174.177.143] X-CFilter-Loop: Reflected X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 11AE6E000100 X-Stat-Signature: 3b7xwwwnbc4f7qreb3d1bajbjpgayocr Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=szxga05-in.huawei.com; client-ip=45.249.212.191 X-HE-DKIM-Result: none/none X-HE-Tag: 1617348302-458834 Content-Transfer-Encoding: quoted-printable 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: Emm... Actually, the problem exist for stable branch like 4.19 after fix for=20 CVE-2021-27365 which include the follow two patch: 2efc459d06f1 ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs=20 output") ec98ea7070e9 ("scsi: iscsi: Ensure sysfs attributes are limited to=20 PAGE_SIZE") =E5=9C=A8 2021/4/2 15:16, yangerkun =E5=86=99=E9=81=93: > sysfs_emit(3d8e2128f26a ("sysfs: Add sysfs_emit and sysfs_emit_at to > format sysfs output")) has a hidden constraint that the buf should be > alignment with PAGE_SIZE. It's OK since 59bb47985c1d ("mm, sl[aou]b: > guarantee natural alignment for kmalloc(power-of-two)") help us to solv= e > scenes like CONFIG_SLUB_DEBUG or CONFIG_SLOB which will break this. >=20 >=20 > But since lots of stable branch(we reproduce it with 4.19 stable) merge > 3d8e2128f26a ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs > output") without 59bb47985c1d ("mm, sl[aou]b: guarantee natural > alignment for kmalloc(power-of-two)"), we will get the follow warning > with command 'cat /sys/class/iscsi_transport/tcp/handle' once we enable > CONFIG_SLUB_DEBUG and start kernel with slub_debug=3DUFPZ! >=20 >=20 > Obviously, we can backport 59bb47985c1d ("mm, sl[aou]b: guarantee > natural alignment for kmalloc(power-of-two)") to fix it. But this will > waste some memory to ensure natural alignment which seems unbearable fo= r > embedded device. So for stable branch like 4.19, can we just remove the > warning in sysfs_emit since the only user for it is iscsi, and seq_read > + sysfs_kf_seq_show can ensure that the buf in sysfs_emit must be aware > of PAGE_SIZE. Or does there some other advise for this problem? >=20 >=20 > # without 59bb47985c1d + 1G ram > [root@localhost ~]# free > =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 total=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 used=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 free=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 shared=C2=A0= buff/cache > available > Mem:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 947336=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 169960=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 389732=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 896=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 38= 7644 > 624216 > Swap:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0 >=20 > # merge with 59bb47985c1d + 1G ram > [root@localhost ~]# free > =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 total=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 used=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 free=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 shared=C2=A0= buff/cache > available > Mem:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 947340=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 175176=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 374396=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 896=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 39= 7768 > 618964 > Swap:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0 > [root@localhost ~]# >=20 >=20 > [=C2=A0=C2=A0 37.683332] ------------[ cut here ]------------ > [=C2=A0=C2=A0 37.692747] invalid sysfs_emit: buf:00000000f75441ab > [=C2=A0=C2=A0 37.693914] WARNING: CPU: 1 PID: 576 at fs/sysfs/file.c:57= 7=20 > sysfs_emit+0xb9/0xe0 > [=C2=A0=C2=A0 37.694861] Modules linked in: > [=C2=A0=C2=A0 37.695264] CPU: 1 PID: 576 Comm: cat Not tainted=20 > 4.19.183-00023-gdf225d326e8c #7 > [=C2=A0=C2=A0 37.696210] Hardware name: QEMU Standard PC (i440FX + PIIX= , 1996),=20 > BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31=20 > 04/01/2014 > [=C2=A0=C2=A0 37.697866] RIP: 0010:sysfs_emit+0xb9/0xe0 > [=C2=A0=C2=A0 37.698387] Code: 47 c9 c3 48 83 05 76 33 b3 04 01 48 89 f= e 48 c7 c7=20 > 64 08 bb 8a 48 83 05 7c 33 b3 04 01 e8 13 7f be 00 48 83 05 77 33 b3 04= =20 > 01 <0f> 0b 48 83 05 75 33 b3 04 01 48 83 05 73 > [=C2=A0=C2=A0 37.700713] RSP: 0018:ffffc90000af7cf8 EFLAGS: 00010202 > [=C2=A0=C2=A0 37.701370] RAX: 0000000000000000 RBX: ffff88803e0e4c00 RC= X:=20 > 0000000000000006 > [=C2=A0=C2=A0 37.702261] RDX: 0000000000000007 RSI: 0000000000000006 RD= I:=20 > ffff888039455bf0 > [=C2=A0=C2=A0 37.703171] RBP: ffffc90000af7d48 R08: 00000000000002f8 R0= 9:=20 > 0000000000000005 > [=C2=A0=C2=A0 37.704079] R10: 00000000000002f7 R11: ffffffff8bd9534d R1= 2:=20 > ffff88801a013740 > [=C2=A0=C2=A0 37.705001] R13: ffff88803db37a08 R14: ffff88803db37a30 R1= 5:=20 > ffff88803db37a48 > [=C2=A0=C2=A0 37.705918] FS:=C2=A0 00007fcb96411580(0000) GS:ffff888039= 440000(0000)=20 > knlGS:0000000000000000 > [=C2=A0=C2=A0 37.706956] CS:=C2=A0 0010 DS: 0000 ES: 0000 CR0: 00000000= 80050033 > [=C2=A0=C2=A0 37.707692] CR2: 00007fcb88cf0000 CR3: 000000001a501000 CR= 4:=20 > 00000000000006e0 > [=C2=A0=C2=A0 37.708607] DR0: 0000000000000000 DR1: 0000000000000000 DR= 2:=20 > 0000000000000000 > [=C2=A0=C2=A0 37.709520] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR= 7:=20 > 0000000000000400 > [=C2=A0=C2=A0 37.710427] Call Trace: > [=C2=A0=C2=A0 37.710784]=C2=A0 show_transport_handle+0x3e/0x60 > [=C2=A0=C2=A0 37.711338]=C2=A0 dev_attr_show+0x22/0x60 > [=C2=A0=C2=A0 37.711808]=C2=A0 sysfs_kf_seq_show+0xc6/0x190 > [=C2=A0=C2=A0 37.712332]=C2=A0 kernfs_seq_show+0x25/0x30 > [=C2=A0=C2=A0 37.712862]=C2=A0 seq_read+0xe1/0x540 > [=C2=A0=C2=A0 37.713292]=C2=A0 ? __handle_mm_fault+0xba3/0x1c70 > [=C2=A0=C2=A0 37.713866]=C2=A0 kernfs_fop_read+0x36/0x230 > [=C2=A0=C2=A0 37.714371]=C2=A0 __vfs_read+0x3c/0x230 > [=C2=A0=C2=A0 37.714819]=C2=A0 ? handle_mm_fault+0x1d1/0x340 > [=C2=A0=C2=A0 37.715345]=C2=A0 vfs_read+0xb5/0x1b0 > [=C2=A0=C2=A0 37.715774]=C2=A0 ksys_read+0x67/0x130 > [=C2=A0=C2=A0 37.716218]=C2=A0 __x64_sys_read+0x1e/0x30 > [=C2=A0=C2=A0 37.716701]=C2=A0 do_syscall_64+0x95/0x3d0 > [=C2=A0=C2=A0 37.717175]=C2=A0 ? do_async_page_fault+0x2e/0x190 > [=C2=A0=C2=A0 37.717747]=C2=A0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 > [=C2=A0=C2=A0 37.718406] RIP: 0033:0x7fcb963363f2 > [=C2=A0=C2=A0 37.718881] Code: c0 e9 b2 fe ff ff 50 48 8d 3d 8a 41 0a 0= 0 e8 75 f0=20 > 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f= =20 > 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 04 > [=C2=A0=C2=A0 37.721290] RSP: 002b:00007ffea78dff18 EFLAGS: 00000246 OR= IG_RAX:=20 > 0000000000000000 > [=C2=A0=C2=A0 37.722264] RAX: ffffffffffffffda RBX: 0000000000020000 RC= X:=20 > 00007fcb963363f2 > [=C2=A0=C2=A0 37.723169] RDX: 0000000000020000 RSI: 00007fcb88cf1000 RD= I:=20 > 0000000000000003 > [=C2=A0=C2=A0 37.724100] RBP: 00007fcb88cf1000 R08: 00007fcb88cf0010 R0= 9:=20 > 0000000000000000 > [=C2=A0=C2=A0 37.725039] R10: 0000000000000022 R11: 0000000000000246 R1= 2:=20 > 0000000000020f00 > [=C2=A0=C2=A0 37.725945] R13: 0000000000000003 R14: 0000000000020000 R1= 5:=20 > 0000000000020000 > [=C2=A0=C2=A0 37.726857] ---[ end trace fbd5b85cd7d85530 ]--- >=20 > .