Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Jun 2020 15:50:35 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r362699 - head/sys/compat/linux
Message-ID:  <202006271550.05RFoZY0025659@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sat Jun 27 15:50:35 2020
New Revision: 362699
URL: https://svnweb.freebsd.org/changeset/base/362699

Log:
  Make linux(4) warn about unsupported SA_ flags.
  
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D25453

Modified:
  head/sys/compat/linux/linux_signal.c

Modified: head/sys/compat/linux/linux_signal.c
==============================================================================
--- head/sys/compat/linux/linux_signal.c	Sat Jun 27 15:06:58 2020	(r362698)
+++ head/sys/compat/linux/linux_signal.c	Sat Jun 27 15:50:35 2020	(r362699)
@@ -63,24 +63,56 @@ static void	sicode_to_lsicode(int si_code, int *lsi_co
 static void
 linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa)
 {
+	unsigned long flags;
 
 	linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask);
 	bsa->sa_handler = PTRIN(lsa->lsa_handler);
 	bsa->sa_flags = 0;
-	if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP)
+
+	flags = lsa->lsa_flags;
+	if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) {
+		flags &= ~LINUX_SA_NOCLDSTOP;
 		bsa->sa_flags |= SA_NOCLDSTOP;
-	if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT)
+	}
+	if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) {
+		flags &= ~LINUX_SA_NOCLDWAIT;
 		bsa->sa_flags |= SA_NOCLDWAIT;
-	if (lsa->lsa_flags & LINUX_SA_SIGINFO)
+	}
+	if (lsa->lsa_flags & LINUX_SA_SIGINFO) {
+		flags &= ~LINUX_SA_SIGINFO;
 		bsa->sa_flags |= SA_SIGINFO;
-	if (lsa->lsa_flags & LINUX_SA_ONSTACK)
+#ifdef notyet
+		/*
+		 * XXX: We seem to be missing code to convert
+		 *      some of the fields in ucontext_t.
+		 */
+		linux_msg(curthread,
+		    "partially unsupported sigaction flag SA_SIGINFO");
+#endif
+	}
+	if (lsa->lsa_flags & LINUX_SA_RESTORER) {
+		flags &= ~LINUX_SA_RESTORER;
+		/* XXX: We might want to handle it; see Linux sigreturn(2). */
+	}
+	if (lsa->lsa_flags & LINUX_SA_ONSTACK) {
+		flags &= ~LINUX_SA_ONSTACK;
 		bsa->sa_flags |= SA_ONSTACK;
-	if (lsa->lsa_flags & LINUX_SA_RESTART)
+	}
+	if (lsa->lsa_flags & LINUX_SA_RESTART) {
+		flags &= ~LINUX_SA_RESTART;
 		bsa->sa_flags |= SA_RESTART;
-	if (lsa->lsa_flags & LINUX_SA_ONESHOT)
+	}
+	if (lsa->lsa_flags & LINUX_SA_ONESHOT) {
+		flags &= ~LINUX_SA_ONESHOT;
 		bsa->sa_flags |= SA_RESETHAND;
-	if (lsa->lsa_flags & LINUX_SA_NOMASK)
+	}
+	if (lsa->lsa_flags & LINUX_SA_NOMASK) {
+		flags &= ~LINUX_SA_NOMASK;
 		bsa->sa_flags |= SA_NODEFER;
+	}
+
+	if (flags != 0)
+		linux_msg(curthread, "unsupported sigaction flag %#lx", flags);
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006271550.05RFoZY0025659>