From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andrew Morton <akpm@osdl.org>, kuznet@ms2.inr.ac.ru
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] Allow either tid or pid in SCM_CREDENTIALS struct ucred
Date: Thu, 21 Aug 2003 00:39:19 -0700 [thread overview]
Message-ID: <1061451559.4386.13.camel@localhost.localdomain> (raw)
Andrew,
Could you stick this in -mm and see if anyone complains? It fixes an
apparent bug in the validation of the SCM_CREDENTIALS structure in a
unix-domain socket sendmsg().
I found this because with Valgrind, the sendmsg call is being done in a
different thread from the one which did a getpid() to fill out the
SCM_CREDENTIALS structure, which causes the kernel to fail the sendmsg
with EPERM. In the general case, this would cause a multithreaded
program sending messages with SCM_CREDENTIALS to appear schizophrenic to
a recipient, because every message would have a different pid depending
on which thread happened to send it.
If you use SCM_CREDENTIALS with a unix domain socket, and you're
non-root, then the kernel double-checks the values you supply for pid,
uid and gid in struct ucred. In the case of uid or gid, it allows any
of effective, saved or real uid/gid. In the case of pid, it only allows
current->pid, which is actually the tid.
This patch also makes it accept tgid in the SCM_CREDENTIALS pid field.
That is, a threaded program can either supply the ID of the whole
process (tgid) or a particular thread (pid).
Thanks,
J
net/core/scm.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
diff -puN net/core/scm.c~scm_allow_tgid net/core/scm.c
--- local-2.6/net/core/scm.c~scm_allow_tgid 2003-08-20 19:52:40.000000000 -0700
+++ local-2.6-jeremy/net/core/scm.c 2003-08-21 00:28:10.295629745 -0700
@@ -41,7 +41,8 @@
static __inline__ int scm_check_creds(struct ucred *creds)
{
- if ((creds->pid == current->pid || capable(CAP_SYS_ADMIN)) &&
+ if (((creds->pid == current->pid || creds->pid == current->tgid) ||
+ capable(CAP_SYS_ADMIN)) &&
((creds->uid == current->uid || creds->uid == current->euid ||
creds->uid == current->suid) || capable(CAP_SETUID)) &&
((creds->gid == current->gid || creds->gid == current->egid ||
_
next reply other threads:[~2003-08-21 7:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-21 7:39 Jeremy Fitzhardinge [this message]
2003-08-22 17:03 ` [PATCH] Allow either tid or pid in SCM_CREDENTIALS struct ucred Ulrich Drepper
2003-08-22 18:02 ` Trond Myklebust
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=1061451559.4386.13.camel@localhost.localdomain \
--to=jeremy@goop.org \
--cc=akpm@osdl.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.