From patchwork Thu Sep 21 02:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 9963203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D37BB6056D for ; Thu, 21 Sep 2017 02:33:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE82F292AA for ; Thu, 21 Sep 2017 02:33:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABB52292B0; Thu, 21 Sep 2017 02:33:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9B2B292AF for ; Thu, 21 Sep 2017 02:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751648AbdIUCdJ (ORCPT ); Wed, 20 Sep 2017 22:33:09 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:57161 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbdIUCdG (ORCPT ); Wed, 20 Sep 2017 22:33:06 -0400 Received: by mail-pf0-f181.google.com with SMTP id g65so2493990pfe.13 for ; Wed, 20 Sep 2017 19:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=tVIHvBV4coE/mlPwwVc0ankgsTizCJifp2126pNWpr4=; b=i4TD/5mP98yHUGPAzbPBCg++x8v6zUOvAvwfNR9g3fLexpS93Fm7W7Owg54eclEsAh bffaz1v8OmUXU1olm8rTSOyMFzoYg57lHfTLpv3PMhNy3CBHVHyeXItnn3V4F23OAqOT vxfUJPFfasYNTH5+Z7kTHRzX4uswtBYO8nrlw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=tVIHvBV4coE/mlPwwVc0ankgsTizCJifp2126pNWpr4=; b=jko54VQQ6pM5Rv+LJLJ3ZnhBZ0OqeOTBU5Lp09mKyS2ISTo8oPr39yU3rl7KzhdAna mGgE2bhBndYndLkA/pJVOXNS0ZMfTkzwPbVeZwNCUpDb9FezTYFoSIlHZj4a3vHsMZXo Rm+TpJionL713ZZNPKl/3KcaA4WZRZAruBjWJafTGxXqe4rYa+6rIPG45BdD9WaxkpEl 8O4MahvoRNWfUhmkFWYcI/giVVoSA2wvacStDnhKxTBGcePS6nQgeFngrc0ND4uDExpy HY5RhhWTq8q2Z4s6li8YDxpWB1rGei6pJS6jt6YIwlLi6UD71mFn9AoO3R+ZMDiQMPVn xwEQ== X-Gm-Message-State: AHPjjUiLwAIgZsviOdJg0sRHBMmwMJzZoe9MXKFKPYFxW1Eqd9kZSqHY cwBKwP3V5kL2AY5x6K+DHacaJg== X-Google-Smtp-Source: AOwi7QAqcKYJuXb9oH4yP9W2fQxa/J1Hj709zqbgnFUegObmLUhZU7t1mWjmMxgbGYC+NTHoP5qUUA== X-Received: by 10.99.95.204 with SMTP id t195mr4185327pgb.135.1505961186281; Wed, 20 Sep 2017 19:33:06 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id b22sm328291pfh.175.2017.09.20.19.33.03 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 19:33:05 -0700 (PDT) From: Baolin Wang To: dhowells@redhat.com Cc: james.l.morris@oracle.com, serge@hallyn.com, arnd@arndb.de, broonie@kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v2 2/2] security: keys: Replace time_t with time64_t for struct key_preparsed_payload Date: Thu, 21 Sep 2017 10:32:03 +0800 Message-Id: <0f08ea5fb66780d40f104244d5fcaa8c610ffe30.1505960744.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The 'struct key_preparsed_payload' will use 'time_t' which we will try to remove in the kernel, since 'time_t' is not year 2038 safe on 32bits systems. Thus this patch replaces 'time_t' with 'time64_t' which is year 2038 safe on 32 bits system for 'struct key_preparsed_payload', moreover we should use the 'TIME64_MAX' macro to initialize the 'time64_t' type variable. Signed-off-by: Baolin Wang Reviewed-by: Arnd Bergmann --- include/linux/key-type.h | 2 +- security/keys/key.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/key-type.h b/include/linux/key-type.h index 9520fc3..05d8fb5 100644 --- a/include/linux/key-type.h +++ b/include/linux/key-type.h @@ -44,7 +44,7 @@ struct key_preparsed_payload { const void *data; /* Raw data */ size_t datalen; /* Raw datalen */ size_t quotalen; /* Quota length for proposed payload */ - time_t expiry; /* Expiry time of key */ + time64_t expiry; /* Expiry time of key */ } __randomize_layout; typedef int (*request_key_actor_t)(struct key_construction *key, diff --git a/security/keys/key.c b/security/keys/key.c index 291a67c..d5c8941 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -446,7 +446,7 @@ static int __key_instantiate_and_link(struct key *key, if (authkey) key_revoke(authkey); - if (prep->expiry != TIME_T_MAX) { + if (prep->expiry != TIME64_MAX) { key->expiry = prep->expiry; key_schedule_gc(prep->expiry + key_gc_delay); } @@ -492,7 +492,7 @@ int key_instantiate_and_link(struct key *key, prep.data = data; prep.datalen = datalen; prep.quotalen = key->type->def_datalen; - prep.expiry = TIME_T_MAX; + prep.expiry = TIME64_MAX; if (key->type->preparse) { ret = key->type->preparse(&prep); if (ret < 0) @@ -834,7 +834,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, prep.data = payload; prep.datalen = plen; prep.quotalen = index_key.type->def_datalen; - prep.expiry = TIME_T_MAX; + prep.expiry = TIME64_MAX; if (index_key.type->preparse) { ret = index_key.type->preparse(&prep); if (ret < 0) { @@ -968,7 +968,7 @@ int key_update(key_ref_t key_ref, const void *payload, size_t plen) prep.data = payload; prep.datalen = plen; prep.quotalen = key->type->def_datalen; - prep.expiry = TIME_T_MAX; + prep.expiry = TIME64_MAX; if (key->type->preparse) { ret = key->type->preparse(&prep); if (ret < 0)