netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Dharanitharan R <dharanitharan725@gmail.com>
Cc: syzbot+5dd615f890ddada54057@syzkaller.appspotmail.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Edward Adam Davis <eadavis@qq.com>
Subject: Re: [PATCH v3] net: atm: lec: add pre_send validation to avoid uninitialized
Date: Wed, 10 Dec 2025 10:28:53 +0000	[thread overview]
Message-ID: <aTlLZUDphWwZGaGS@horms.kernel.org> (raw)
In-Reply-To: <20251210035354.17492-2-dharanitharan725@gmail.com>

+ Edward

On Wed, Dec 10, 2025 at 03:53:55AM +0000, Dharanitharan R wrote:
> syzbot reported a KMSAN uninitialized-value crash caused by reading
> fields from struct atmlec_msg before validating that the skb contains
> enough linear data. A malformed short skb can cause lec_arp_update()
> and other handlers to access uninitialized memory.
> 
> Add a pre_send() validator that ensures the message header and optional
> TLVs are fully present. This prevents all lec message types from reading
> beyond initialized skb data.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: syzbot+5dd615f890ddada54057@syzkaller.appspotmail.com
> Tested-by: syzbot+5dd615f890ddada54057@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=5dd615f890ddada54057
> Signed-off-by: Dharanitharan R <dharanitharan725@gmail.com>

As pointed out elsewhere, this patch largely duplicates the following by
Edward (CCed).

- [PATCH] net: atm: targetless need more input msg
  https://lore.kernel.org/netdev/tencent_B31D1B432549BA28BB5633CB9E2C1B124B08%40qq.com/

Ideally there would be some collaboration between you and him on this.

Also, as a fix for Networking code, please explicitly target the patch
at net-next.

Subject: [PATCH net] ...

> ---
>  net/atm/lec.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/net/atm/lec.c b/net/atm/lec.c
> index afb8d3eb2185..c893781a490a 100644
> --- a/net/atm/lec.c
> +++ b/net/atm/lec.c
> @@ -489,8 +489,33 @@ static void lec_atm_close(struct atm_vcc *vcc)
>  	module_put(THIS_MODULE);
>  }
>  
> +static int lec_atm_pre_send(struct atm_vcc *vcc, struct sk_buff *skb)
> +{
> +	struct atmlec_msg *mesg;
> +	u32 sizeoftlvs;
> +	unsigned int msg_size = sizeof(struct atmlec_msg);

Please use reverse xmas tree order - longest line to shortest -
for Networking code.

> +
> +	/* Must contain the base message */
> +	if (skb->len < msg_size)
> +		return -EINVAL;
> +
> +   	/* Must have at least msg_size bytes in linear data */
> +   	if (!pskb_may_pull(skb, msg_size))
> +   		return -EINVAL;

As you pointed out off-list, this check seems to be the main difference
between your patch and Edward's. I agree it seems relevant. But if so I
believe it duplicates the skb->len check above which can be dropped.

Also The indentation of the three above is not correct.
It should only use tabs.  checkpatch.pl points this out.

> +
> +	mesg = (struct atmlec_msg *)skb->data;
> +	sizeoftlvs = mesg->sizeoftlvs;
> +
> +	/* Validate TLVs if present */
> +	if (sizeoftlvs && !pskb_may_pull(skb, msg_size + sizeoftlvs))
> +       	return -EINVAL;

Tabs only for indentation on the like above too.

> +
> +	return 0;
> +}
> +
>  static const struct atmdev_ops lecdev_ops = {
>  	.close = lec_atm_close,
> +	.pre_send = lec_atm_pre_send,
>  	.send = lec_atm_send
>  };

-- 
pw-bot: changes requested

      reply	other threads:[~2025-12-10 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10  3:53 [PATCH v3] net: atm: lec: add pre_send validation to avoid uninitialized Dharanitharan R
2025-12-10 10:28 ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aTlLZUDphWwZGaGS@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=dharanitharan725@gmail.com \
    --cc=eadavis@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+5dd615f890ddada54057@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).