Commit 7ee23491 authored by Viresh Kumar's avatar Viresh Kumar Committed by Jason Gunthorpe

RDMA/qib: Validate ->show()/store() callbacks before calling them

The permissions of the read-only or write-only sysfs files can be
changed (as root) and the user can then try to read a write-only file or
write to a read-only file which will lead to kernel crash here.

Protect against that by always validating the show/store callbacks.

Link: https://lore.kernel.org/r/d45cc26361a174ae12dbb86c994ef334d257924b.1573096807.git.viresh.kumar@linaro.orgSigned-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent da046d5f
......@@ -301,6 +301,9 @@ static ssize_t qib_portattr_show(struct kobject *kobj,
struct qib_pportdata *ppd =
container_of(kobj, struct qib_pportdata, pport_kobj);
if (!pattr->show)
return -EIO;
return pattr->show(ppd, buf);
}
......@@ -312,6 +315,9 @@ static ssize_t qib_portattr_store(struct kobject *kobj,
struct qib_pportdata *ppd =
container_of(kobj, struct qib_pportdata, pport_kobj);
if (!pattr->store)
return -EIO;
return pattr->store(ppd, buf, len);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment