public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Alessandro Suardi <alessandro.suardi@oracle.com>
Cc: linux-kernel@vger.kernel.org, "David S. Miller" <davem@redhat.com>
Subject: Re: gnome-terminal acts funny in recent 2.5 series
Date: Tue, 19 Feb 2002 20:44:39 +0900	[thread overview]
Message-ID: <87d6z11ys8.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <3C719641.3040604@oracle.com>
In-Reply-To: <3C719641.3040604@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]

Alessandro Suardi <alessandro.suardi@oracle.com> writes:

> Running Ximian-latest for rh72/i386, latest 2.5 kernels (including
>   2.5.4-pre2, 2.5.4, 2.5.5-pre1).
> 
> Symptom:
>    - clicking on the panel icon for gnome-terminal shows a flicker
>       of the terminal window coming up then the window disappears.
>      No leftover processes.
> 
> What works 100%:
>    - regular xterm in 2.5.x
>    - gnome-terminal in 2.4.x (x in .17, .18-pre9, .18-rc2)
> 
> More info:
>    - doesn't happen 100% of the time, but close
>    - trying to start gnome-terminal either vanilla or with the
>       parameters in the icon from an xterm causes
>        * gnome-terminal window comes up, but no shell prompt; the
>           window *does not* disappear and program is in a CPU loop
>        * program detaches from calling xterm even when '&' is
>           not used
>        * calling xterm's tty is left in a funny state (sometimes
>           stty sane^J is required, sometimes tput reset)
> 
> Any ideas would be quite welcome - I can go back and try and narrow
>   down what kernel breaks gnome-terminal if nothing comes up.

Probably, this problem had occurred in libzvt which gnome-terminal is
using.

libzvt was using file descriptor passing via UNIX domain socket for
pseudo terminal. Then because ->passcred was not initialized in
sock_alloc(), unexpected credential data was passing to libzvt.

The following patch fixed this problem, but I'm not sure.
Could you review the patch? (attached file are test program)

--- socket.c.orig	Mon Feb 11 18:21:59 2002
+++ socket.c	Tue Feb 19 16:20:18 2002
@@ -501,6 +501,8 @@ struct socket *sock_alloc(void)
 	sock->ops = NULL;
 	sock->sk = NULL;
 	sock->file = NULL;
+//	init_waitqueue_head(&sock->wait);	this is needed?
+	sock->passcred = 0;
 
 	sockets_in_use[smp_processor_id()].counter++;
 	return sock;

Regards
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 2487 bytes --]

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

static void client(int fd)
{
	int send_fd;
	struct msghdr msg;
	struct iovec iov[1];
	char buf[1];
	union {
		struct cmsghdr cm;
		char cntl[CMSG_SPACE(sizeof(int))];
	} cntl_u;
	struct cmsghdr *cmsgptr;

	send_fd = open("/dev/null", O_RDWR);
	
	iov[0].iov_base = buf;
	iov[0].iov_len = 1;
	msg.msg_iov = iov;
	msg.msg_iovlen = 1;
	msg.msg_name = NULL;
	msg.msg_namelen = 0;

	msg.msg_control = cntl_u.cntl;
	msg.msg_controllen = sizeof(cntl_u.cntl);

	cmsgptr = CMSG_FIRSTHDR(&msg);
	cmsgptr->cmsg_len = CMSG_LEN(sizeof(int));
	cmsgptr->cmsg_level = SOL_SOCKET;
	cmsgptr->cmsg_type = SCM_RIGHTS;
	*((int *)CMSG_DATA(cmsgptr)) = send_fd;

	if (sendmsg(fd, &msg, 0) <= 0)
		perror("sendmsg");
}

static void server(int fd)
{
	int recv_fd;
	struct stat statbuf;
	struct msghdr msg;
	struct iovec iov[1];
	char buf[1];
	union {
		struct cmsghdr cm;
		char cntl[CMSG_SPACE(sizeof(int))];
	} cntl_u;
	struct cmsghdr *cmsgptr;

	iov[0].iov_base = buf;
	iov[0].iov_len = 1;
	msg.msg_iov = iov;
	msg.msg_iovlen = 1;
	msg.msg_name = NULL;
	msg.msg_namelen = 0;

	msg.msg_control = cntl_u.cntl;
	msg.msg_controllen = sizeof(cntl_u.cntl);
	
	if (recvmsg(fd, &msg, 0) <= 0) {
		perror("recvmsg");
		exit(1);
	}
	cmsgptr = CMSG_FIRSTHDR(&msg);
	if (cmsgptr == NULL) {
		fprintf(stderr, "no control message\n");
		exit(1);
	}
	if (cmsgptr->cmsg_len != CMSG_LEN(sizeof(int)))
		fprintf(stderr, "bad length: %d\n", cmsgptr->cmsg_len);
	if (cmsgptr->cmsg_level != SOL_SOCKET)
		fprintf(stderr, "not SOL_SOCKET: %d\n", cmsgptr->cmsg_level);
	if (cmsgptr->cmsg_type != SCM_RIGHTS)
		fprintf(stderr, "not SCM_RIGHTS: %d\n", cmsgptr->cmsg_type);
	recv_fd = *((int *)CMSG_DATA(cmsgptr));
	if (fstat(recv_fd, &statbuf) == -1) {
		perror("stat");
		exit(1);
	}

	printf("fd: %d, dev: %llx, mode: %o\n",
	       recv_fd, statbuf.st_rdev, statbuf.st_mode);
}

int main()
{
	pid_t pid;
	int status, fd[2];

	if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
		perror("socketpair");
		exit(1);
	}

	pid = fork();
	if (pid == -1) {
		perror("fork");
		exit(1);
	}
	if (pid == 0) {
		close(fd[1]);
		client(fd[0]);
		exit(0);
	}

	close(fd[0]);
	if (waitpid(pid, &status, 0) != pid) {
		perror("waitpid");
		exit(1);
	}
	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
		fprintf(stderr, "client abnormal end\n");
		exit(1);
	}

	server(fd[1]);

	return 0;
}

  parent reply	other threads:[~2002-02-19 11:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-19  0:03 gnome-terminal acts funny in recent 2.5 series Alessandro Suardi
2002-02-19  0:39 ` Gustavo Noronha Silva
2002-02-19  4:00   ` Wayne Whitney
2002-02-19 12:48     ` Sebastian Dröge
2002-02-19  6:13   ` Sebastian Dröge
2002-02-19 11:44 ` OGAWA Hirofumi [this message]
2002-02-19 15:09   ` Dave Jones
  -- strict thread matches above, loose matches on Subject: below --
2002-02-19 14:08 ALESSANDRO.SUARDI
2002-02-19 16:40 Petr Vandrovec
2002-02-19 17:47 ` OGAWA Hirofumi

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=87d6z11ys8.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=alessandro.suardi@oracle.com \
    --cc=davem@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox