[PATCH v2 1/1] netlink: fix neigh lladdr decoder

Dmitry V. Levin ldv at altlinux.org
Sat Sep 8 23:25:13 UTC 2018


On Sat, Sep 01, 2018 at 02:11:08PM -0400, Jamal Hadi Salim wrote:
> From: Jamal Hadi Salim <jhs at mojatatu.com>
> 
> Fixes: 19abd528fbba ("rtnl_neigh: decode ndmsg netlink attributes")
> signed-off-by: Jamal Hadi Salim <jhs at mojatatu.com>

It would be great if you added a sentence describing what was wrong in the
decoder (I suppose that mac address was printed as inet address) and what
is a fix (I suppose it's a new decoder for mac addresses).

> ---
>  rtnl_neigh.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/rtnl_neigh.c b/rtnl_neigh.c
> index 31087748..c1dd3d1c 100644
> --- a/rtnl_neigh.c
> +++ b/rtnl_neigh.c
> @@ -56,6 +56,22 @@ decode_neigh_addr(struct tcb *const tcp,
>  }
>  
>  static bool
> +decode_neigh_lladdr(struct tcb *const tcp,
> +		    const kernel_ulong_t addr,
> +		    const unsigned int len,
> +		    const void *const opaque_data)
> +{
> +	uint8_t maddr[6];
> +
> +	if (len < sizeof(maddr))
> +		return false;
> +	else if (!umove_or_printaddr(tcp, addr, &maddr))
> +		print_mac_addr("",  maddr, sizeof(maddr));
> +
> +	return true;
> +}
> +
> +static bool
>  decode_nda_cacheinfo(struct tcb *const tcp,
>  		     const kernel_ulong_t addr,
>  		     const unsigned int len,
> @@ -78,7 +94,7 @@ decode_nda_cacheinfo(struct tcb *const tcp,
>  
>  static const nla_decoder_t ndmsg_nla_decoders[] = {
>  	[NDA_DST]		= decode_neigh_addr,
> -	[NDA_LLADDR]		= decode_neigh_addr,
> +	[NDA_LLADDR]		= decode_neigh_lladdr,
>  	[NDA_CACHEINFO]		= decode_nda_cacheinfo,
>  	[NDA_PROBES]		= decode_nla_u32,
>  	[NDA_VLAN]		= decode_nla_u16,

This looks OK.

Could you add a corresponding check to tests/nlattr_ndmsg.c, please?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180909/04e452d3/attachment.bin>


More information about the Strace-devel mailing list