From patchwork Wed Dec 30 13:24:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bamvor Zhang Jian X-Patchwork-Id: 59078 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2845213lbb; Wed, 30 Dec 2015 05:24:42 -0800 (PST) X-Received: by 10.98.9.2 with SMTP id e2mr92342317pfd.89.1451481882575; Wed, 30 Dec 2015 05:24:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si23868248pfl.182.2015.12.30.05.24.42; Wed, 30 Dec 2015 05:24:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754884AbbL3NYe (ORCPT + 29 others); Wed, 30 Dec 2015 08:24:34 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36424 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754863AbbL3NY2 (ORCPT ); Wed, 30 Dec 2015 08:24:28 -0500 Received: by mail-pa0-f49.google.com with SMTP id yy13so46187310pab.3 for ; Wed, 30 Dec 2015 05:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=0rkQJl3/nX7byV+Grpk233xUfDNiD3AJaUJecRu3gvI=; b=Guwt7mP3ErHS5NEFIn7opL8Fpe6JM/q/8jWlYcMwJRa0K02gwVG/XHKU2Ln/ROIz0K Jkx7Atm2Fkt/VKc+DNrUSv9nw3OQWfguDCpWf3AkdThu5TAA0duuFytIAaePrSr50USn jDwERfOty5x9Z+KwPEODTqrQtWhXObXnka5g4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=0rkQJl3/nX7byV+Grpk233xUfDNiD3AJaUJecRu3gvI=; b=Am0sSjcLCrJmvekbPE6HdrtioiTPXa0+XwQc6LUu5aXZ2EXSN0iS5y2hqmtPWc38U+ tqS2XgIB2jn8a5Zx1ClkfdDZJLAJaUcqWg7ykv+Q83ixURnwHhfDxIjSLztomVZPSoJ1 IJoz+koY+TBZ8872KjajmjfI6LKW3OL576pmDdwmegs4d3EpWCz8Pb1IE5rlwhau+i7H U/VPEEnOhZrWnRfpUGc1szeviHf4m8bvLRSiMvp/eu0SnMVa4iN6yEsEdB9A4gtqPt/6 DrdBBVn20jbCRJEJheyoKYWvYoMPSO+f7dX0NRcqk7t3W+MnHqt4BrToTqCG06ZfklMh P+kw== X-Gm-Message-State: ALoCoQn6fJMoF253U1ITnH6bvgsPXPiFJiCb4qyOn7xj/W86FkumCiejU6q5xtZg0N2Q53jxm+pi0lQpiG1Yv/ndCx1WfliH5w== X-Received: by 10.66.102.9 with SMTP id fk9mr86719234pab.77.1451481868145; Wed, 30 Dec 2015 05:24:28 -0800 (PST) Received: from linux-j170.site ([211.22.145.200]) by smtp.gmail.com with ESMTPSA id 11sm31361385pfp.38.2015.12.30.05.24.24 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Dec 2015 05:24:27 -0800 (PST) Subject: Re: [PATCH v2 2/2] ppdev: add support for compat ioctl To: Sudip Mukherjee , Arnd Bergmann References: <1450346332-31830-1-git-send-email-bamvor.zhangjian@linaro.org> <1450346332-31830-3-git-send-email-bamvor.zhangjian@linaro.org> <2687762.Ja01N3hBuT@wuerfel> <20151230111648.GA29697@sudip-pc> Cc: linux-kernel@vger.kernel.org, y2038@lists.linaro.org, gregkh@linuxfoundation.org, broonie@kernel.org, Bamvor Zhang Jian From: Bamvor Jian Zhang Message-ID: <5683DB05.7000704@linaro.org> Date: Wed, 30 Dec 2015 21:24:21 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151230111648.GA29697@sudip-pc> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sudip On 12/30/2015 07:16 PM, Sudip Mukherjee wrote: > On Fri, Dec 18, 2015 at 12:12:05AM +0100, Arnd Bergmann wrote: >> On Thursday 17 December 2015 17:58:52 Bamvor Jian Zhang wrote: >>> The arg of ioctl in ppdev is the pointer of integer except the >>> timeval in PPSETTIME, PPGETTIME. Different size of timeval >>> is already supported by the previous patches. So, it is safe >>> to add compat support. >>> >>> Signed-off-by: Bamvor Jian Zhang >>> >> >> Reviewed-by: Arnd Bergmann >> >> (I think I replied with the reviewed-by tag before to this patch) > > I was testing this series today. And it is breaking my userspace code. I > am attaching my userspace code for you to check. Its very simple > userspace code: > 1: open > 2: ioctl to claim > 3: ioctl - PPGETTIME > 4: ioctl - PPSETTIME > 5: ioctl - PPGETTIME > 6: ioctl - release > 7: close > > Without this series it works as expected. > > With this series applied, the userspace code prints the error message: > PPNEGOT: Bad address > > I traced it with strace and: > ioctl(3, PPGETTIME, 0xbfe91508) = -1 EFAULT (Bad address) Thanks for your testing. It seems that I misuse the parameters. Could you please apply the following patch and try it again? There is no parport in my computer, Thanks. Regards Bamvor > > regards > sudip > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 31bc7b7..9e98d01 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -636,7 +636,7 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if ((time32[0] < 0) || (time32[1] < 0)) return -EINVAL; - if (copy_to_user(time32, argp, sizeof(time32))) + if (copy_to_user(argp, time32, sizeof(time32))) return -EFAULT; return 0; @@ -648,7 +648,7 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if ((time64[0] < 0) || (time64[1] < 0)) return -EINVAL; - if (copy_to_user(time64, argp, sizeof(time64))) + if (copy_to_user(argp, time64, sizeof(time64))) return -EFAULT; return 0;