Skip to content

Commit

Permalink
net: mctp i2c: Copy headers if cloned
Browse files Browse the repository at this point in the history
Use skb_cow_head() prior to modifying the TX SKB. This is necessary
when the SKB has been cloned, to avoid modifying other shared clones.

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Fixes: f5b8abf ("mctp i2c: MCTP I2C binding driver")
Link: https://patch.msgid.link/20250306-matt-mctp-i2c-cow-v1-1-293827212681@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Matt Johnston authored and Jakub Kicinski committed Mar 8, 2025
1 parent 26db9c9 commit df8ce77
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/mctp/mctp-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
struct mctp_i2c_hdr *hdr;
struct mctp_hdr *mhdr;
u8 lldst, llsrc;
int rc;

if (len > MCTP_I2C_MAXMTU)
return -EMSGSIZE;
Expand All @@ -593,6 +594,10 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
lldst = *((u8 *)daddr);
llsrc = *((u8 *)saddr);

rc = skb_cow_head(skb, sizeof(struct mctp_i2c_hdr));
if (rc)
return rc;

skb_push(skb, sizeof(struct mctp_i2c_hdr));
skb_reset_mac_header(skb);
hdr = (void *)skb_mac_header(skb);
Expand Down

0 comments on commit df8ce77

Please sign in to comment.