Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2383691ybi; Sun, 9 Jun 2019 10:22:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZYD28J+/CT51EDcQSfuWvEfTbUS4UUX4BatPWJpmjjxhqo2nwTq1uSHrDtr3MSMismoYX X-Received: by 2002:a63:84c1:: with SMTP id k184mr10207763pgd.7.1560100933787; Sun, 09 Jun 2019 10:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560100933; cv=none; d=google.com; s=arc-20160816; b=FkIW4nNxZIkreWmHNoJjoB1y955h0gNEgJJ58hVHs+G4uC+aPulJ2XsErDbZ3BJ7Bf JJQ4Gfjbx3YZIEjMZkNzUCwROOtxMX35DwDxMSwjTDbPRUdDv7hRlGb1HFCFrmYSUXD9 9GkGs2UpGzGsx4Jr20GZn/pvIDOzELgbgeeWXyRH1ysrc/Ae483cPpGgloqEFhUxJPLk gEyleLV9cF84hC1cSJJfleQKpQxzs+E0E/n1NUCoJEqRm9fTAt11fiKSmW6TZ7IDQzI/ WmOAjfKHs3HwOOoUDVEg4uPCRF/cgaXPYbMk/UEU2ovS6EZn6MJXlg8O4OVYXVpfx+QW hpgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ua+aMrgrjNxJJPBaHqH+rQq5SQZgtbNZMW/Rvy87R8A=; b=tLCl3wZKf9t6wMtBYCYE2zS/A8/HxVLLHnAYo4szEh05TUR2lW0q5oKYg6otKAmIII x1XRoMNrCmj7eFPrzqpM6VznXGLTGqBIMekRXhy+TNoVIHarNUaf8szJDV8qGc/DP2V7 NaxD+gomRE7+w2oZYugBTgSe9EaVQYl2A1T5s04kOsVjGuPI2MQR1RfzDzJhyBy6uucI 9A8HmLpy23mSr40KxDdzw/Mdfu6MfuDQuAYJGSG3r0Q3OlO6KP0H1NOvatHJIlkEdL61 yv5mOFG7z2uWf3OnL2CKYOzE1szEcIW6Awu5wENl1wCImwKIflHIbq0gFCdFWV+XWrFP YgUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hjzID1LQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cg6si8563446plb.350.2019.06.09.10.21.58; Sun, 09 Jun 2019 10:22:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hjzID1LQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbfFIQrq (ORCPT + 99 others); Sun, 9 Jun 2019 12:47:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:46376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730910AbfFIQrj (ORCPT ); Sun, 9 Jun 2019 12:47:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA409205ED; Sun, 9 Jun 2019 16:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560098859; bh=sdE3P7sOxxmzEGlCIbI3UmAgN/aiH7Yp1z0Sp9FfpiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjzID1LQGlGyzSbq4tDV68WEtk/uNsg5KycjVLMUY4cciyoxyZc6cLbjggYis7OeH iVnIZH+m9rNMaqTFbWuod7Khr09OcRMnEVM4oC+REIodpWNfGVCOCfnX9jqFNLyu0P xz7Y2iV1gwg3OGV1MTxSneXM8JnzOxTjEoBTCHMc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olivier Matz , "David S. Miller" Subject: [PATCH 4.19 15/51] ipv6: use READ_ONCE() for inet->hdrincl as in ipv4 Date: Sun, 9 Jun 2019 18:41:56 +0200 Message-Id: <20190609164127.967317205@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164127.123076536@linuxfoundation.org> References: <20190609164127.123076536@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Olivier Matz [ Upstream commit 59e3e4b52663a9d97efbce7307f62e4bc5c9ce91 ] As it was done in commit 8f659a03a0ba ("net: ipv4: fix for a race condition in raw_sendmsg") and commit 20b50d79974e ("net: ipv4: emulate READ_ONCE() on ->hdrincl bit-field in raw_sendmsg()") for ipv4, copy the value of inet->hdrincl in a local variable, to avoid introducing a race condition in the next commit. Signed-off-by: Olivier Matz Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/raw.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -782,6 +782,7 @@ static int rawv6_sendmsg(struct sock *sk struct flowi6 fl6; struct ipcm6_cookie ipc6; int addr_len = msg->msg_namelen; + int hdrincl; u16 proto; int err; @@ -795,6 +796,13 @@ static int rawv6_sendmsg(struct sock *sk if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; + /* hdrincl should be READ_ONCE(inet->hdrincl) + * but READ_ONCE() doesn't work with bit fields. + * Doing this indirectly yields the same result. + */ + hdrincl = inet->hdrincl; + hdrincl = READ_ONCE(hdrincl); + /* * Get and verify the address. */ @@ -907,7 +915,7 @@ static int rawv6_sendmsg(struct sock *sk fl6.flowi6_oif = np->ucast_oif; security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); - if (inet->hdrincl) + if (hdrincl) fl6.flowi6_flags |= FLOWI_FLAG_KNOWN_NH; if (ipc6.tclass < 0) @@ -930,7 +938,7 @@ static int rawv6_sendmsg(struct sock *sk goto do_confirm; back_from_confirm: - if (inet->hdrincl) + if (hdrincl) err = rawv6_send_hdrinc(sk, msg, len, &fl6, &dst, msg->msg_flags, &ipc6.sockc); else {