Skip to content

Commit 7cd0401

Browse files
keesgregkh
authored andcommitted
w1: Split memcpy() of struct cn_msg flexible array
To work around a misbehavior of the compiler's ability to see into composite flexible array structs (as detailed in the coming memcpy() hardening series[1]), split the memcpy() of the header and the payload so no false positive run-time overflow warning will be generated. [1] https://lore.kernel.org/linux-hardening/[email protected]/ Cc: Evgeniy Polyakov <[email protected]> Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9c573cd commit 7cd0401

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/w1/w1_netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ static void w1_cn_callback(struct cn_msg *cn, struct netlink_skb_parms *nsp)
611611
}
612612
atomic_set(&block->refcnt, 1);
613613
block->portid = nsp->portid;
614-
memcpy(&block->request_cn, cn, sizeof(*cn) + cn->len);
614+
block->request_cn = *cn;
615+
memcpy(block->request_cn.data, cn->data, cn->len);
615616
node = (struct w1_cb_node *)(block->request_cn.data + cn->len);
616617

617618
/* Sneeky, when not bundling, reply_size is the allocated space

0 commit comments

Comments
 (0)