mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: jonas@southpole.se
To: linux-kernel@vger.kernel.org
Cc: linux@openrisc.net, joern.rennecke@embecosm.com,
	Jonas Bonn <jonas@southpole.se>
Subject: [PATCH 1/1] Apply transparent_union attribute to union semun
Date: Fri, 27 May 2011 00:27:45 +0200	[thread overview]
Message-ID: <1306448865-3142-1-git-send-email-jonas@southpole.se> (raw)


From: Jonas Bonn <jonas@southpole.se>

The syscall handler for semctl is written under the assumption that the
toolchain will pass "small" unions as function parameters directly instead
of by reference.  The union semun is "small" and thus fits this description.

Since it is assumed that the union will be passed directly and not by
reference, it is safe to access the union members without going via
get_user.

The OpenRISC architecture, however, passes all unions by reference, thus
breaking the above assumption.

The technically correct fix here is to mark the union as being transparent
so that the ABI of the union's first element determines the parameter
passing method and thus make explicit what's already implied in the function
definition.

Signed-off-by: Jonas Bonn <jonas@southpole.se>
---
 include/linux/sem.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/sem.h b/include/linux/sem.h
index f2961af..6985c7d 100644
--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -48,7 +48,7 @@ union semun {
 	unsigned short __user *array;	/* array for GETALL & SETALL */
 	struct seminfo __user *__buf;	/* buffer for IPC_INFO */
 	void __user *__pad;
-};
+} __attribute__ ((transparent_union));
 
 struct  seminfo {
 	int semmap;
-- 
1.7.4.1


             reply	other threads:[~2011-05-26 22:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 22:27 jonas [this message]
2011-05-27  8:13 ` [ORLinux] " Jeremy Bennett
2011-06-17 17:31 ` Jonas Bonn

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=1306448865-3142-1-git-send-email-jonas@southpole.se \
    --to=jonas@southpole.se \
    --cc=joern.rennecke@embecosm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@openrisc.net \
    /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®