2018-04-12 16:57:01

by Andrey Konovalov

[permalink] [raw]
Subject: [PATCH] NFC: fix attrs checks in netlink interface

nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX
attribute being present, but doesn't check whether it is actually
provided by the user. Same goes for nfc_genl_fw_download() and
NFC_ATTR_FIRMWARE_NAME.

This patch adds appropriate checks.

Found with syzkaller.

Signed-off-by: Andrey Konovalov <[email protected]>
---
net/nfc/netlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index f018eafc2a0d..58adfb0c90f6 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -936,7 +936,8 @@ static int nfc_genl_deactivate_target(struct sk_buff *skb,
u32 device_idx, target_idx;
int rc;

- if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+ !info->attrs[NFC_ATTR_TARGET_INDEX])
return -EINVAL;

device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
@@ -1245,7 +1246,8 @@ static int nfc_genl_fw_download(struct sk_buff *skb, struct genl_info *info)
u32 idx;
char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];

- if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+ !info->attrs[NFC_ATTR_FIRMWARE_NAME])
return -EINVAL;

idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
--
2.17.0.484.g0c8726318c-goog


2018-06-04 04:29:01

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH] NFC: fix attrs checks in netlink interface

Hi Andrey,

On Thu, Apr 12, 2018 at 06:56:56PM +0200, Andrey Konovalov wrote:
> nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX
> attribute being present, but doesn't check whether it is actually
> provided by the user. Same goes for nfc_genl_fw_download() and
> NFC_ATTR_FIRMWARE_NAME.
>
> This patch adds appropriate checks.
>
> Found with syzkaller.
>
> Signed-off-by: Andrey Konovalov <[email protected]>
> ---
> net/nfc/netlink.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Thanks, applied to nfc-next.

Cheers,
Samuel.

2019-01-02 15:30:39

by Andrey Konovalov

[permalink] [raw]
Subject: Re: [PATCH] NFC: fix attrs checks in netlink interface

On Mon, Jun 4, 2018 at 6:29 AM Samuel Ortiz <[email protected]> wrote:
>
> Hi Andrey,
>
> On Thu, Apr 12, 2018 at 06:56:56PM +0200, Andrey Konovalov wrote:
> > nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX
> > attribute being present, but doesn't check whether it is actually
> > provided by the user. Same goes for nfc_genl_fw_download() and
> > NFC_ATTR_FIRMWARE_NAME.
> >
> > This patch adds appropriate checks.
> >
> > Found with syzkaller.
> >
> > Signed-off-by: Andrey Konovalov <[email protected]>
> > ---
> > net/nfc/netlink.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> Thanks, applied to nfc-next.

Hi Samuel,

It's been 6 months and this fix is still not in mainline. Did it get lost?

Thanks!

>
> Cheers,
> Samuel.