mirror of https://gitee.com/openkylin/linux.git
netfilter: nfnetlink_queue: use y2038 safe timestamp
The __build_packet_message function fills a nfulnl_msg_packet_timestamp structure that uses 64-bit seconds and is therefore y2038 safe, but it uses an intermediate 'struct timespec' which is not. This trivially changes the code to use 'struct timespec64' instead, to correct the result on 32-bit architectures. This is a copy and paste of Arnd's original patch for nfnetlink_log. Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
2b5b1a01a7
commit
b28b1e826f
|
@ -500,9 +500,10 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
|
||||||
|
|
||||||
if (entskb->tstamp.tv64) {
|
if (entskb->tstamp.tv64) {
|
||||||
struct nfqnl_msg_packet_timestamp ts;
|
struct nfqnl_msg_packet_timestamp ts;
|
||||||
struct timeval tv = ktime_to_timeval(entskb->tstamp);
|
struct timespec64 kts = ktime_to_timespec64(skb->tstamp);
|
||||||
ts.sec = cpu_to_be64(tv.tv_sec);
|
|
||||||
ts.usec = cpu_to_be64(tv.tv_usec);
|
ts.sec = cpu_to_be64(kts.tv_sec);
|
||||||
|
ts.usec = cpu_to_be64(kts.tv_nsec / NSEC_PER_USEC);
|
||||||
|
|
||||||
if (nla_put(skb, NFQA_TIMESTAMP, sizeof(ts), &ts))
|
if (nla_put(skb, NFQA_TIMESTAMP, sizeof(ts), &ts))
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
Loading…
Reference in New Issue