提交 3a01d1b5 编写于 作者: Z Zheng Yejian 提交者: Yang Yingliang

sysfs: Remove address alignment constraint in sysfs_emit{_at}

hulk inclusion
category: bugfix
bugzilla: 51349
CVE: CVE-2021-27365
---------------------------

sysfs_emit and sysfs_emit_at have a constraint that output buffer should
be alignment with PAGE_SIZE, but currently we can not guarantee it since
59bb4798 ("mm, sl[aou]b: guarantee natural alignment for
kmalloc(power-of-two)") is not merged.

This may lead to an unexpected warning when execute like:
'cat /sys/class/iscsi_transport/tcp/handle'.

As for the necessity of the address alignment constraint, Joe Perches
(the code author) wrote that:
    > It's to make sure it's a PAGE_SIZE aligned buffer.
    > It's just so it would not be misused/abused in non-sysfs derived cases.

So we'll not need to introduce 59bb4798 ("mm, sl[aou]b: guarantee natural
alignment for kmalloc(power-of-two)") but just remove the address alignment
constraint.

For more discussions of the issue, see:
    https://www.spinics.net/lists/stable/msg455428.htmlSigned-off-by: NZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 9ba54aa4
...@@ -574,7 +574,7 @@ int sysfs_emit(char *buf, const char *fmt, ...) ...@@ -574,7 +574,7 @@ int sysfs_emit(char *buf, const char *fmt, ...)
va_list args; va_list args;
int len; int len;
if (WARN(!buf || offset_in_page(buf), if (WARN(!buf,
"invalid sysfs_emit: buf:%p\n", buf)) "invalid sysfs_emit: buf:%p\n", buf))
return 0; return 0;
...@@ -602,7 +602,7 @@ int sysfs_emit_at(char *buf, int at, const char *fmt, ...) ...@@ -602,7 +602,7 @@ int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
va_list args; va_list args;
int len; int len;
if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE, if (WARN(!buf || at < 0 || at >= PAGE_SIZE,
"invalid sysfs_emit_at: buf:%p at:%d\n", buf, at)) "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册