From patchwork Fri Jun 12 07:48:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 49789 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0EC0F228DB for ; Fri, 12 Jun 2015 07:50:05 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf7647861lbb.0 for ; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=UFx3enViNwidUwUuoKmr+eh8f6Dy2SxuJabt8srFxs4=; b=hRdYfvqsXSOJGA3SnHvBSkPWRWSn+tCJilz1/v4nKUuM5GChcKylGjP2MMiMiYu/Ao 0J1wlCPA9HgbiEd9Y+6SSvyPAVNs7ucw1PzpeJqCRI8aRsVL2GxepEVP0deW6pTfkd/+ x2i77oCLuJOCLe1q/ONDFfJBnh+jglQ9yaNjVcEqeemks7CnzIKc6YC/aFmwOGODP5A7 R6GlhDMWR1LgfOcSogi5gElX31kjkEbBnwpWt8bj9QW3edc4xMJ8j6XtEdSRAcaSBy9w DW5Z5GoDRgxc1t10Jm8dHRvNx14nKrn01LbWy9Tn38PMN3RVo5Z7n1r5KZB5f1slX0nd 0SDQ== X-Gm-Message-State: ALoCoQlBER6crn8YI0v6XeGYmJbn1UWBqhFjumXvlevSUznsdjaZirj5/sAleacWqUqrmx9eKrkp X-Received: by 10.113.11.3 with SMTP id ee3mr13012848lbd.9.1434095403706; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.129 with SMTP id s1ls307800las.89.gmail; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) X-Received: by 10.152.44.132 with SMTP id e4mr14090408lam.34.1434095403514; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id gj2si2707542lbc.159.2015.06.12.00.50.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2015 00:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbtu8 with SMTP id tu8so15384645lbb.2 for ; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr13847161lae.19.1434095403192; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp355824lbb; Fri, 12 Jun 2015 00:50:02 -0700 (PDT) X-Received: by 10.68.57.209 with SMTP id k17mr21367217pbq.118.1434095401438; Fri, 12 Jun 2015 00:50:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si4228324pap.184.2015.06.12.00.49.49; Fri, 12 Jun 2015 00:50:01 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753328AbbFLHto (ORCPT + 29 others); Fri, 12 Jun 2015 03:49:44 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:36312 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbbFLHtm (ORCPT ); Fri, 12 Jun 2015 03:49:42 -0400 Received: by pdjm12 with SMTP id m12so19577805pdj.3 for ; Fri, 12 Jun 2015 00:49:42 -0700 (PDT) X-Received: by 10.70.88.145 with SMTP id bg17mr21230425pdb.167.1434095382485; Fri, 12 Jun 2015 00:49:42 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id yv6sm2734372pac.29.2015.06.12.00.49.40 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 00:49:41 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v5 05/24] posix-timers: Introduce {get, put}_timespec and {get, put}_itimerspec Date: Fri, 12 Jun 2015 15:48:20 +0800 Message-Id: <647dcc7ede88d9d95a6f9a2878487d46c233fb2a.1434079262.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , These are new helper macros that convert between a user timespec/ itimerspec and a kernel timespec64/itimerspec64 structure. When converting syscall functions, it need to deal with these conversions: user timespec (32 bit), kernel timespec (32 bit) user timespec (64 bit), kernel timespec (64 bit) user timespec (32 bit), kernel timespec64 (64 bit) user timespec (64 bit), kernel timespec64 (64 bit) user itimerspec (32 bit), kernel itimerspec (32 bit) user itimerspec (64 bit), kernel itimerspec (64 bit) user itimerspec (32 bit), kernel itimerspec64 (64 bit) user itimerspec (64 bit), kernel itimerspec64 (64 bit) In order to handle all these conversions, and ensure that it can change over all callers at the same time with the structure type above, and introduce the get/put macros based on __put_user() and __get_user(). Signed-off-by: Baolin Wang --- kernel/time/posix-timers.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 31d11ac..5ddd912 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -147,6 +147,35 @@ static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags); __timr; \ }) +#define __get_timespec(kts, uts) \ + (__get_user((kts)->tv_sec, &(uts)->tv_sec) || \ + __get_user((kts)->tv_nsec, &(uts)->tv_nsec)) + +#define __put_timespec(kts, uts) \ + (__put_user((kts)->tv_sec, &(uts)->tv_sec) || \ + __put_user((kts)->tv_nsec, &(uts)->tv_nsec)) + +#define get_timespec(kts, uts) \ + ((access_ok(VERIFY_READ, (uts), sizeof(*(uts))) || \ + __get_timespec((kts), (uts))) ? \ + -EFAULT : 0) + +#define put_timespec(kts, uts) \ + ((access_ok(VERIFY_WRITE, (uts), sizeof(*(uts))) || \ + __put_timespec((kts), (uts))) ? \ + -EFAULT : 0) + +#define get_itimerspec(kit, uit) \ + ((access_ok(VERIFY_READ, (uit), sizeof(*(uit))) || \ + __get_timespec(&(kit)->it_interval, &(uit)->it_interval) || \ + __get_timespec(&(kit)->it_value, &(uit)->it_value))) + +#define put_itimerspec(kit, uit) \ + ((access_ok(VERIFY_WRITE, (uit), sizeof(*(uit))) || \ + __put_timespec(&(kit)->it_interval, &(uit)->it_interval) || \ + __put_timespec(&(kit)->it_value, &(uit)->it_value)) ? \ + -EFAULT : 0) + static int hash(struct signal_struct *sig, unsigned int nr) { return hash_32(hash32_ptr(sig) ^ nr, HASH_BITS(posix_timers_hashtable));