From owner-svn-src-user@FreeBSD.ORG  Mon May  5 20:13:26 2014
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id F3EDFEAB;
 Mon,  5 May 2014 20:13:25 +0000 (UTC)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id E1D76257;
 Mon,  5 May 2014 20:13:25 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s45KDPIh055955;
 Mon, 5 May 2014 20:13:25 GMT (envelope-from dchagin@svn.freebsd.org)
Received: (from dchagin@localhost)
 by svn.freebsd.org (8.14.8/8.14.8/Submit) id s45KDPg0055954;
 Mon, 5 May 2014 20:13:25 GMT (envelope-from dchagin@svn.freebsd.org)
Message-Id: <201405052013.s45KDPg0055954@svn.freebsd.org>
From: Dmitry Chagin <dchagin@FreeBSD.org>
Date: Mon, 5 May 2014 20:13:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
Subject: svn commit: r265387 - user/dchagin/lemul/sys/compat/linux
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: "SVN commit messages for the experimental &quot; user&quot;
 src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-user>,
 <mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user/>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
 <mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 05 May 2014 20:13:26 -0000

Author: dchagin
Date: Mon May  5 20:13:25 2014
New Revision: 265387
URL: http://svnweb.freebsd.org/changeset/base/265387

Log:
  hecking epoll fd against fd is useless as different fds could
  resolve to the same file.
  Instead of checking of file descriptors compare file pointers.
  
  Suggested by: mjg

Modified:
  user/dchagin/lemul/sys/compat/linux/linux_event.c

Modified: user/dchagin/lemul/sys/compat/linux/linux_event.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linux/linux_event.c	Mon May  5 19:53:03 2014	(r265386)
+++ user/dchagin/lemul/sys/compat/linux/linux_event.c	Mon May  5 20:13:25 2014	(r265387)
@@ -339,9 +339,6 @@ linux_epoll_ctl(struct thread *td, struc
 	int nchanges = 0;
 	int error;
 
-	if (args->epfd == args->fd)
-		return (EINVAL);
-
 	if (args->op != LINUX_EPOLL_CTL_DEL) {
 		error = copyin(args->event, &le, sizeof(le));
 		if (error != 0)
@@ -359,6 +356,12 @@ linux_epoll_ctl(struct thread *td, struc
 	if (error != 0)
 		goto leave1;
 
+	/* Linux disallows spying on himself */
+	if (epfp == fp) {
+		error = EINVAL;
+		goto leave0;
+	}
+
 	ciargs.changelist = kev;
 
 	switch (args->op) {