From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: Linus Torvalds <torvalds@transmeta.com>,
Marcelo Tosatti <marcelo@conectiva.com.br>,
Linux kernel mailing list <linux-kernel@vger.kernel.org>,
linux-irda@pasta.cs.uit.no
Subject: [PATCH] : ir245_af_ias.diff
Date: Fri, 30 Nov 2001 12:56:22 -0800 [thread overview]
Message-ID: <20011130125622.D3938@bougret.hpl.hp.com> (raw)
ir245_af_ias.diff :
-----------------
o [CORRECT] Restrict write access to IAS database to ROOT. Users can
only write IAS object attached to their own socket. This avoid apps
polluting each other.
o [FEATURE] Empty IAS classname will refer to object attached to
present socket.
diff -u -p linux/net/irda/af_irda.d3.c linux/net/irda/af_irda.c
--- linux/net/irda/af_irda.d3.c Wed Nov 28 10:21:31 2001
+++ linux/net/irda/af_irda.c Wed Nov 28 14:13:43 2001
@@ -1845,15 +1845,36 @@ static int irda_setsockopt(struct socket
return -EFAULT;
}
- /* Find the object we target */
- ias_obj = irias_find_object(ias_opt->irda_class_name);
+ /* Find the object we target.
+ * If the user gives us an empty string, we use the object
+ * associated with this socket. This will workaround
+ * duplicated class name - Jean II */
+ if(ias_opt->irda_class_name[0] == '\0') {
+ if(self->ias_obj == NULL) {
+ kfree(ias_opt);
+ return -EINVAL;
+ }
+ ias_obj = self->ias_obj;
+ } else
+ ias_obj = irias_find_object(ias_opt->irda_class_name);
+
+ /* Only ROOT can mess with the global IAS database.
+ * Users can only add attributes to the object associated
+ * with the socket they own - Jean II */
+ if((!capable(CAP_NET_ADMIN)) &&
+ ((ias_obj == NULL) || (ias_obj != self->ias_obj))) {
+ kfree(ias_opt);
+ return -EPERM;
+ }
+
+ /* If the object doesn't exist, create it */
if(ias_obj == (struct ias_object *) NULL) {
/* Create a new object */
ias_obj = irias_new_object(ias_opt->irda_class_name,
jiffies);
}
- /* Do we have it already ? */
+ /* Do we have the attribute already ? */
if(irias_find_attrib(ias_obj, ias_opt->irda_attrib_name)) {
kfree(ias_opt);
return -EINVAL;
@@ -1927,13 +1948,28 @@ static int irda_setsockopt(struct socket
return -EFAULT;
}
- /* Find the object we target */
- ias_obj = irias_find_object(ias_opt->irda_class_name);
+ /* Find the object we target.
+ * If the user gives us an empty string, we use the object
+ * associated with this socket. This will workaround
+ * duplicated class name - Jean II */
+ if(ias_opt->irda_class_name[0] == '\0')
+ ias_obj = self->ias_obj;
+ else
+ ias_obj = irias_find_object(ias_opt->irda_class_name);
if(ias_obj == (struct ias_object *) NULL) {
kfree(ias_opt);
return -EINVAL;
}
+ /* Only ROOT can mess with the global IAS database.
+ * Users can only del attributes from the object associated
+ * with the socket they own - Jean II */
+ if((!capable(CAP_NET_ADMIN)) &&
+ ((ias_obj == NULL) || (ias_obj != self->ias_obj))) {
+ kfree(ias_opt);
+ return -EPERM;
+ }
+
/* Find the attribute (in the object) we target */
ias_attr = irias_find_attrib(ias_obj,
ias_opt->irda_attrib_name);
@@ -2166,8 +2202,14 @@ bed:
return -EFAULT;
}
- /* Find the object we target */
- ias_obj = irias_find_object(ias_opt->irda_class_name);
+ /* Find the object we target.
+ * If the user gives us an empty string, we use the object
+ * associated with this socket. This will workaround
+ * duplicated class name - Jean II */
+ if(ias_opt->irda_class_name[0] == '\0')
+ ias_obj = self->ias_obj;
+ else
+ ias_obj = irias_find_object(ias_opt->irda_class_name);
if(ias_obj == (struct ias_object *) NULL) {
kfree(ias_opt);
return -EINVAL;
reply other threads:[~2001-11-30 20:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20011130125622.D3938@bougret.hpl.hp.com \
--to=jt@bougret.hpl.hp.com \
--cc=jt@hpl.hp.com \
--cc=linux-irda@pasta.cs.uit.no \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=torvalds@transmeta.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®