LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH]: MTRR: fix 32-bit ioctls on x64_32
@ 2007-01-16  8:14 Giuliano Procida
  0 siblings, 0 replies; 5+ messages in thread
From: Giuliano Procida @ 2007-01-16  8:14 UTC (permalink / raw)
  To: rgooch; +Cc: linux-kernel, giuliano.procida

[MTRR] fix 32-bit ioctls on x64_32

Signed-off-by: Giuliano Procida <giuliano.procida@googlemail.com>

---

Fixed incomplete support for 32-bit compatibility ioctls in
2.6.19.1. They were unhandled in one of three case-statements.
Testing using X server before and after change.

--- linux-source-2.6.19.1.orig/arch/i386/kernel/cpu/mtrr/if.c	2006-12-11 19:32:53.000000000 +0000
+++ linux-source-2.6.19.1/arch/i386/kernel/cpu/mtrr/if.c	2007-01-16 07:31:06.000000000 +0000
@@ -211,6 +211,9 @@ mtrr_ioctl(struct file *file, unsigned i
 	default:
 		return -ENOTTY;
 	case MTRRIOC_ADD_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_ADD_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err =
@@ -218,21 +221,33 @@ mtrr_ioctl(struct file *file, unsigned i
 				  file, 0);
 		break;
 	case MTRRIOC_SET_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_SET_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err = mtrr_add(sentry.base, sentry.size, sentry.type, 0);
 		break;
 	case MTRRIOC_DEL_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_DEL_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err = mtrr_file_del(sentry.base, sentry.size, file, 0);
 		break;
 	case MTRRIOC_KILL_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_KILL_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err = mtrr_del(-1, sentry.base, sentry.size);
 		break;
 	case MTRRIOC_GET_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_GET_ENTRY:
+#endif
 		if (gentry.regnum >= num_var_ranges)
 			return -EINVAL;
 		mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type);
@@ -249,6 +264,9 @@ mtrr_ioctl(struct file *file, unsigned i
 
 		break;
 	case MTRRIOC_ADD_PAGE_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_ADD_PAGE_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err =
@@ -256,21 +274,33 @@ mtrr_ioctl(struct file *file, unsigned i
 				  file, 1);
 		break;
 	case MTRRIOC_SET_PAGE_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_SET_PAGE_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err = mtrr_add_page(sentry.base, sentry.size, sentry.type, 0);
 		break;
 	case MTRRIOC_DEL_PAGE_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_DEL_PAGE_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err = mtrr_file_del(sentry.base, sentry.size, file, 1);
 		break;
 	case MTRRIOC_KILL_PAGE_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_KILL_PAGE_ENTRY:
+#endif
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 		err = mtrr_del_page(-1, sentry.base, sentry.size);
 		break;
 	case MTRRIOC_GET_PAGE_ENTRY:
+#ifdef CONFIG_COMPAT
+	case MTRRIOC32_GET_PAGE_ENTRY:
+#endif
 		if (gentry.regnum >= num_var_ranges)
 			return -EINVAL;
 		mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type);



^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH]: MTRR: fix 32-bit ioctls on x64_32
@ 2007-01-16 12:48 Mikael Pettersson
  2007-01-16 17:59 ` Giuliano Procida
  2007-01-17  3:51 ` H. Peter Anvin
  0 siblings, 2 replies; 5+ messages in thread
From: Mikael Pettersson @ 2007-01-16 12:48 UTC (permalink / raw)
  To: giuliano.procida, rgooch; +Cc: linux-kernel

On Tue, 16 Jan 2007 08:14:30 +0000, Giuliano Procida wrote:
> [MTRR] fix 32-bit ioctls on x64_32
> 
> Signed-off-by: Giuliano Procida <giuliano.procida@googlemail.com>
> 
> ---
> 
> Fixed incomplete support for 32-bit compatibility ioctls in
> 2.6.19.1. They were unhandled in one of three case-statements.
> Testing using X server before and after change.
> 
> --- linux-source-2.6.19.1.orig/arch/i386/kernel/cpu/mtrr/if.c	2006-12-11 19:32:53.000000000 +0000
> +++ linux-source-2.6.19.1/arch/i386/kernel/cpu/mtrr/if.c	2007-01-16 07:31:06.000000000 +0000
> @@ -211,6 +211,9 @@ mtrr_ioctl(struct file *file, unsigned i
>  	default:
>  		return -ENOTTY;
>  	case MTRRIOC_ADD_ENTRY:
> +#ifdef CONFIG_COMPAT
> +	case MTRRIOC32_ADD_ENTRY:
> +#endif
>  		if (!capable(CAP_SYS_ADMIN))
>  			return -EPERM;
>  		err =
> @@ -218,21 +221,33 @@ mtrr_ioctl(struct file *file, unsigned i
>  				  file, 0);
>  		break;
>  	case MTRRIOC_SET_ENTRY:
> +#ifdef CONFIG_COMPAT
> +	case MTRRIOC32_SET_ENTRY:
> +#endif

etc

These #ifdefs are too ugly.

Since you apparently just add aliases for the case labels,
and do no actual code changes, why not
1. make the new cases unconditional, or 
2. invoke a translation function before the switch which
   maps the MTRRCIOC32_ constants to what the kernel uses

/Mikael

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-01-23 13:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-16  8:14 [PATCH]: MTRR: fix 32-bit ioctls on x64_32 Giuliano Procida
2007-01-16 12:48 Mikael Pettersson
2007-01-16 17:59 ` Giuliano Procida
2007-01-17  3:51 ` H. Peter Anvin
2007-01-23 13:23   ` Giuliano Procida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).