Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5998357ybc; Wed, 27 Nov 2019 13:08:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxk07LWwa4YJjZZDSMPRHsCtfPuKG4jCPiaIZwyu0ZzZ3uM5vjfFIAR9+7ee2OyeZbBeYGQ X-Received: by 2002:a17:906:7708:: with SMTP id q8mr50911293ejm.33.1574888934514; Wed, 27 Nov 2019 13:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888934; cv=none; d=google.com; s=arc-20160816; b=MLyZdSmhuVpOrPpddId1D02pYur/1gyz1b8Ay1iytsrKkm9vUoOCb4ejykv/OCv7OY EUxfWeg3jt8D4CZsi6PfSpqijlp1rILvzr103Nhvgd9vcSdnWGVdc19UnUmebaxFHYeX gxGgsQrfwA4aCCCdVWeows/fKog3WA/jwMNUb5doO/UwPn81LvsLVzA40laLCe5LMx/Y st/4F5zLEdYe7SnE0XaH8z9v99KgVLVNTWBumHp4OFdZOY4OQH8U0XX3T/GMsOwXzLmZ 7mdhgmPmBmoyvFU7W1tfgiInAIph9YdfiA1bS9erpWd8NYa5Us4PlSO0RkO6iVKAz3HP oPLQ== 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=5+NHNv3kGc5vBNE9yT2d/XAZFcJXKyINsMCQoh/j+f4=; b=pz0VnE+hYKM8/sZYMds2hwDaKYYux+PY40soXtR/Fdz9gE36ouJTHFNI6sdf1Xvwqg CQsUA2ZzpkDgS4NZHyXv48EyuMFHD5gaDo9MytrfpfWN+FgOadOnXsfJVJM0s6T7Pvlw 2Z7be1As+OdhOfC+AG6mQMAaklG5eB5pHlMxpJ0vKSP0xxGg4LsvxW0bn0wrUJeuVezu TtrliGq5SiSMa+j8W68YZpTCa1LvsPf2oe6LGl5188YNp0Uh7OK8uwPFZbyw67tu9F+H fite2TKeAGgURTvsb7Q56Hmiss6dUXEebVoe/T627du0RtmOJ8w+qqKqTbsIeXIrT9fD 5aZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xRVc7AVY; 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 m33si11319734edc.126.2019.11.27.13.08.28; Wed, 27 Nov 2019 13:08:54 -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=xRVc7AVY; 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 S1731923AbfK0VG7 (ORCPT + 99 others); Wed, 27 Nov 2019 16:06:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:32984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732522AbfK0VG5 (ORCPT ); Wed, 27 Nov 2019 16:06:57 -0500 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 8F4BC217AB; Wed, 27 Nov 2019 21:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888817; bh=Z8WLsowTzZsW31wmmoVRggCv92659igdD967f0ESUVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xRVc7AVYcxZzwTO6LTjnxPhsabEmNyTBfZb+J0kFNhxWdwNpOQtWrK/QyhGA2uBSL bWDxEM2oI8hng6MeGuarbiRgNW4XlaWOCSuR5eN3yVMsocvayFmMc7GHK86+wen2nO LPCbdu3tbLNeZyYY3AOcv4UzYEGShsV+1CCex78A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Barmann , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 239/306] sock: Reset dst when changing sk_mark via setsockopt Date: Wed, 27 Nov 2019 21:31:29 +0100 Message-Id: <20191127203132.445420037@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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: 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