Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp765969ybc; Sat, 16 Nov 2019 08:18:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyQXUMgcAvIgO50bIz0a4p/4rkUpKbT9DCBZdr9lmXTJpW9BaPy3z4M7CO40zFr7DasHxYC X-Received: by 2002:adf:f084:: with SMTP id n4mr14278728wro.369.1573921121975; Sat, 16 Nov 2019 08:18:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921121; cv=none; d=google.com; s=arc-20160816; b=WDdvC2XZXvIsuRw2G1Wh1Y8x1NVlDgcUWo5T16LiDtt1RwbGVuYfd5NKbQEW2IEOAW ceO5Vo/eNo/Sgv6bJ7MPrtP6Cu/+92OlKnRSXHqVD/EJJc6FFxhgmSs7f6Azb0fti/12 Crti4ypgnNLxYWBzPsgw9pEj9XU64FRkf6clUsotyylSPpmSzBAw3c711UhIuncQtP01 NXb99Lsb2ftQmth91fbkmSopA0/bf0MZ/CjephFCxKr4Z6wpfuBddbA0fttySSUBqIzc IXqf5dpLE7KcWOc/zikoLe7oJr+ntE5JV0TwnuLLwXdItuDeRBINpaFFHhmv4ToAGkcM 04Fg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5+NHNv3kGc5vBNE9yT2d/XAZFcJXKyINsMCQoh/j+f4=; b=pDWz6wxoXurV+9l9fj64xWr0BPNkazGK0kk39H9WzPM8tWOQ17aRlvUqhgIZqySKAt Kky2vb0v6zTaBN0w16qdjZ8fiIpNQnzsn/hIy4FC/aGRa8eCZzW/PV7KjMq11iUbl/aE ss9n3ac4/8fNESQNGgjeBdib/8ADHuitIBmxI1uTn/U45wPjf6DXMpFOc+urg8+IeaCh 4bSv2xOh0uArUhKWd5d6WJvA3j1b2CXcbJUb0gH/F9nvcA7N+cwG+0kL7faiVutU9t01 QOXM6BW8qGvNRvtvmZiUQa8pLazDThQ8/3fxgpjbl9CuAHS7DokGmzhXMlDCG14k1TjQ 2u1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DWIyHEqu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l18si8281595edv.348.2019.11.16.08.18.17; Sat, 16 Nov 2019 08:18:41 -0800 (PST) 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=DWIyHEqu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729748AbfKPPrj (ORCPT + 99 others); Sat, 16 Nov 2019 10:47:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:53618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728955AbfKPPq5 (ORCPT ); Sat, 16 Nov 2019 10:46:57 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 038872089D; Sat, 16 Nov 2019 15:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919217; bh=Z8WLsowTzZsW31wmmoVRggCv92659igdD967f0ESUVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DWIyHEquPUXFgYDcoVSyE28wOmC8nNbTrqYA0TwYMzYjBylw9Fyh/Ncu+d/Z5gOdC bCHENy52frZTcZzWAL/ccvmcN6+Df33dzZi7GNczsHAwewi3MN6wV+e134q7Oz+PAc ygsXKfzUf4XB2Zb2p56D7pISpJB9DGLpx0z3tjwA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Barmann , Eric Dumazet , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 222/237] sock: Reset dst when changing sk_mark via setsockopt Date: Sat, 16 Nov 2019 10:40:57 -0500 Message-Id: <20191116154113.7417-222-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Barmann [ Upstream commit 50254256f382c56bde87d970f3d0d02fdb76ec70 ] When setting the SO_MARK socket option, if the mark changes, the dst needs to be reset so that a new route lookup is performed. This fixes the case where an application wants to change routing by setting a new sk_mark. If this is done after some packets have already been sent, the dst is cached and has no effect. Signed-off-by: David Barmann Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index ba4f843cdd1d1..948fd687292a6 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -951,10 +951,12 @@ int sock_setsockopt(struct socket *sock, int level, int optname, clear_bit(SOCK_PASSSEC, &sock->flags); break; case SO_MARK: - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) + if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { ret = -EPERM; - else + } else if (val != sk->sk_mark) { sk->sk_mark = val; + sk_dst_reset(sk); + } break; case SO_RXQ_OVFL: -- 2.20.1