From e51372325864feeed93cabaf483a5ae689382071 Mon Sep 17 00:00:00 2001 From: Srinivasa Rao Kuppala Date: Wed, 30 Nov 2016 14:55:36 -0800 Subject: [PATCH] packet: fix race condition in packet_set_ring commit 5a01eaf19858 ("packet: fix race condition in packet_set_ring") was incorrectly resolved. Add the missing lock_sock(sk) and release_sock(sk) calls. Change-Id: I6565bf3e3c6a15d6f1b93cab0536424dbacb187b Signed-off-by: Srinivasa Rao Kuppala --- net/packet/af_packet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index f165514a4db5..3236d97fb784 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -4154,6 +4154,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, /* Added to avoid minimal code churn */ struct tpacket_req *req = &req_u->req; + lock_sock(sk); /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { WARN(1, "Tx-ring is not supported.\n"); @@ -4289,6 +4290,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, if (pg_vec) free_pg_vec(pg_vec, order, req->tp_block_nr); out: + release_sock(sk); return err; }