mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Firo Yang <firo.yang@suse.com>
To: vyasevich@gmail.com, nhorman@tuxdriver.com, marcelo.leitner@gmail.com
Cc: mkubecek@suse.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, linux-sctp@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	firogm@gmail.com, Firo Yang <firo.yang@suse.com>
Subject: [PATCH 1/1] sctp: sysctl: referring the correct net namespace
Date: Wed, 23 Nov 2022 17:44:06 +0800	[thread overview]
Message-ID: <20221123094406.32654-1-firo.yang@suse.com> (raw)

Recently, a customer reported that from their container whose
net namespace is different to the host's init_net, they can't set
the container's net.sctp.rto_max to any value smaller than
init_net.sctp.rto_min.

For instance,
Host:
sudo sysctl net.sctp.rto_min
net.sctp.rto_min = 1000

Container:
echo 100 > /mnt/proc-net/sctp/rto_min
echo 400 > /mnt/proc-net/sctp/rto_max
echo: write error: Invalid argument

This is caused by the check made from this'commit 4f3fdf3bc59c
("sctp: add check rto_min and rto_max in sysctl")'
When validating the input value, it's always referring the boundary
value set for the init_net namespace.

Having container's rto_max smaller than host's init_net.sctp.rto_min
does make sense. Considering that the rto between two containers on the
same host is very likely smaller than it for two hosts.

So to fix this problem, just referring the boundary value from the net
namespace where the new input value came from shold be enough.

Signed-off-by: Firo Yang <firo.yang@suse.com>
---
 net/sctp/sysctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index b46a416787ec..e167df4dc60b 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -429,6 +429,9 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
 	else
 		tbl.data = &net->sctp.rto_min;
 
+	if (net != &init_net)
+		max = net->sctp.rto_max;
+
 	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
 	if (write && ret == 0) {
 		if (new_value > max || new_value < min)
@@ -457,6 +460,9 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
 	else
 		tbl.data = &net->sctp.rto_max;
 
+	if (net != &init_net)
+		min = net->sctp.rto_min;
+
 	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
 	if (write && ret == 0) {
 		if (new_value > max || new_value < min)
-- 
2.26.2


             reply	other threads:[~2022-11-23  9:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  9:44 Firo Yang [this message]
2022-11-23 13:00 ` Marcelo Ricardo Leitner
2022-11-24  6:29   ` Firo Yang
2022-11-24 17:57     ` Marcelo Ricardo Leitner
2022-11-25  5:53       ` Firo Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221123094406.32654-1-firo.yang@suse.com \
    --to=firo.yang@suse.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=firogm@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=mkubecek@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=pabeni@redhat.com \
    --cc=vyasevich@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®