Skip to content

Commit

Permalink
CIPSO: Fix unaligned memory access in cipso_v4_gentag_hdr
Browse files Browse the repository at this point in the history
We need to use put_unaligned when writing 32-bit DOI value
in cipso_v4_gentag_hdr to avoid unaligned memory access.

v2: unneeded type cast removed as Ondrej Mosnacek suggested.

Signed-off-by: Sergey Nazarov <[email protected]>
Acked-by: Paul Moore <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Sergey Nazarov authored and davem330 committed Mar 5, 2021
1 parent 8eb37ab commit e233feb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/ipv4/cipso_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ static void cipso_v4_gentag_hdr(const struct cipso_v4_doi *doi_def,
{
buf[0] = IPOPT_CIPSO;
buf[1] = CIPSO_V4_HDR_LEN + len;
*(__be32 *)&buf[2] = htonl(doi_def->doi);
put_unaligned_be32(doi_def->doi, &buf[2]);
}

/**
Expand Down

0 comments on commit e233feb

Please sign in to comment.