[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110706134806.GA8286@n2100.arm.linux.org.uk>
Date: Wed, 6 Jul 2011 14:48:06 +0100
From: Russell King - ARM Linux <linux@....linux.org.uk>
To: Vitaly Kuzmichev <vkuzmichev@...sta.com>
Cc: linux-arm-kernel@...ts.infradead.org,
linux-watchdog@...r.kernel.org,
Marc Zyngier <marc.zyngier@....com>,
Wim Van Sebroeck <wim@...ana.be>,
Arnd Bergmann <arnd@...db.de>,
Nicolas Pitre <nico@...xnic.net>,
John Stultz <johnstul@...ibm.com>,
linux-kernel@...r.kernel.org, arm@...nel.org,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH V2 3/6] mpcore_wdt: Fix WDIOC_SETOPTIONS handling
On Tue, Jul 05, 2011 at 11:00:37PM +0400, Vitaly Kuzmichev wrote:
> According to the include/linux/watchdog.h WDIOC_SETOPTIONS is
> classified as 'read from device' ioctl call:
> #define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int)
>
> However, the driver 'mpcore_wdt' performs 'copy_from_user' only if
> _IOC_WRITE is set, thus the local variable 'uarg' which is used in
> WDIOC_SETOPTIONS handling remains uninitialized.
>
> The proper way to fix this is to bind WDIOC_SETOPTIONS to _IOW,
> but this will break compatibility.
> So adding additional condition for performing 'copy_from_user'.
That looks like something which needs fixing in watchdog land. And it's
not too difficult:
1. Change the existing WDIOC_SETOPTIONS to WDIOC_SETOPTIONS_OLD
2. Add a new, correctly defined WDIOC_SETOPTIONS.
3. Update all drivers to use WDIOC_SETOPTIONS.
4. Provide a helper which deals with WDIOC_SETOPTIONS_OLD and translates
it to the proper WDIOC_SETOPTIONS call (this could be just:
if (cmd == WDIOC_SETOPTIONS_OLD) {
static int first = 1;
if (first)
pr_warn("%s:%d used old WDIOC_SETOPTIONS call. Please rebuild\n",
current->comm, current->pid);
first = 0;
cmd = WDIOC_SETOPTIONS;
}
before any argument copies.
This means you preserve existing compatibility with userspace, yet gain
a path to a non-broken ioctl interface.
As stuff gets rebuilt and replaced, you'll eventually be able to remove
the above. That period used to be two years for such simple changes.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists