Skip to contentSkip to conversation

New: info leaks in all kernel versions including android

Bug 210973 [email protected] 2 participants 2 messages Dec 30, 2020 – Dec 31, 2020 InfiniBand

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=210973

Bug ID: 210973
Summary: info leaks in all kernel versions including android
Product: Drivers
Version: 2.5
Kernel Version: latest
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: high
Priority: P1
Component: Infiniband/RDMA
Assignee: [email protected]
Reporter: [email protected]
Regression: No

While I audit android kernel source code , I noticed that there is an Uninitialized data which could lead to info leak in ib_uverbs_create_ah function. I download the source code from here
https://android.googlesource.com/kernel/common. Also it exists in the linux-masters

https://github.com/torvalds/linux/blob/master/drivers/infiniband/core/uverbs_cmd.c#L2408

# BUG
resp.ah_handle = uobj->id;
return uverbs_response(attrs, &resp, sizeof(resp));

# 1
static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs)

{
        struct ib_uverbs_create_ah       cmd;
        struct ib_uverbs_create_ah_resp  resp; <== point to ah_handle and
driver_data
        struct ib_uobject               *uobj;
        struct ib_pd                    *pd;
        struct ib_ah                    *ah;
        struct rdma_ah_attr             attr = {};
        int ret;
        struct ib_device *ib_dev;

        ret = uverbs_request(attrs, &cmd, sizeof(cmd));
        if (ret)
                ret

..etc

        ah->uobject  = uobj;
        uobj->user_handle = cmd.user_handle;
        uobj->object = ah;
        uobj_put_obj_read(pd);
        uobj_finalize_uobj_create(uobj, attrs);

        resp.ah_handle = uobj->id; <==
      //  __u32 driver_data[0];  <== ??? Uninitialized data.
        return uverbs_response(attrs, &resp, sizeof(resp)); <== memoey leaks

//include/uapi/rdma/ib_user_verbs.h

struct ib_uverbs_create_ah_resp {
        __u32 ah_handle;
        __u32 driver_data[0];
};

static int uverbs_response(struct uverbs_attr_bundle *attrs, const void *resp,
size_t resp_len)

{
        int ret;

        if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_CORE_OUT))
                return uverbs_copy_to_struct_or_zero(
                        attrs, UVERBS_ATTR_CORE_OUT, resp, resp_len);

        if (copy_to_user(attrs->ucore.outbuf, resp,
                         min(attrs->ucore.outlen, resp_len))) <== copy data to
userspace
                return -EFAULT;
Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw
Quoted 24 lines · On Wed, Dec 30, 2020 at 10:50:43PM +0000, [email protected]…

https://bugzilla.kernel.org/show_bug.cgi?id=210973

Bug ID: 210973
Summary: info leaks in all kernel versions including android
Product: Drivers
Version: 2.5
Kernel Version: latest
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: high
Priority: P1
Component: Infiniband/RDMA
Assignee: [email protected]
Reporter: [email protected]
Regression: No

While I audit android kernel source code , I noticed that there is an Uninitialized data which could lead to info leak in ib_uverbs_create_ah function. I download the source code from here
https://android.googlesource.com/kernel/common. Also it exists in the linux-masters

Quoted 6 lines

https://github.com/torvalds/linux/blob/master/drivers/infiniband/core/uverbs_cmd.c#L2408

# BUG
resp.ah_handle = uobj->id;
return uverbs_response(attrs, &resp, sizeof(resp));

Thanks for the report.

There is no info leak here because according to the C99 standard if flexible array doesn't have members, it will be treated as non-existent for the struct size calculations.

In our case sizeof(u32) == sizeof(struct ib_uverbs_create_ah_resp) and not sizeof(u32) + sizeof(u32) as you wrote.

See 6.7.2.1 Structureand union specifiers, item 16 for more info.

Thanks