Linux-Integrity Archive on lore.kernel.org
 help / color / Atom feed
From: Roberto Sassu <roberto.sassu@huawei.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: <jarkko.sakkinen@linux.intel.com>, <zohar@linux.ibm.com>,
	<david.safford@ge.com>, <monty.wiseman@ge.com>,
	<matthewgarrett@google.com>, <linux-integrity@vger.kernel.org>,
	<linux-security-module@vger.kernel.org>,
	<keyrings@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<silviu.vlasceanu@huawei.com>, <ndesaulniers@google.com>
Subject: Re: [PATCH v10, RESEND 4/6] tpm: move tpm_chip definition to include/linux/tpm.h
Date: Fri, 8 Feb 2019 09:41:14 +0100
Message-ID: <cded9b3a-e321-ed05-4d41-51b8dab45c8d@huawei.com> (raw)
In-Reply-To: <20190208042411.GA4822@archlinux-ryzen>

On 2/8/2019 5:24 AM, Nathan Chancellor wrote:
>> diff --git a/include/linux/tpm.h b/include/linux/tpm.h
>> index afd022fc9d3d..816e686a73ac 100644
>> --- a/include/linux/tpm.h
>> +++ b/include/linux/tpm.h
>> @@ -22,6 +22,10 @@
>>   #ifndef __LINUX_TPM_H__
>>   #define __LINUX_TPM_H__
>>   
>> +#include <linux/hw_random.h>
>> +#include <linux/acpi.h>

Hi Nathan

I think the error comes from the line above.
security/integrity/ima/ima.h includes <linux/tpm.h>, which now includes
<linux/acpi.h>, which includes <asm/acpi.h>, which includes
<linux/efi.h> (for the arm64 architecture only). Both ima.h and efi.h
define 'NONE'.

The solution would be to rename one of them. I'm not familiar with the
EFI part. Renaming 'NONE' in IMA should be easy as it is not used
anywhere.

Thanks

Roberto


>> +#include <linux/cdev.h>
>> +#include <linux/fs.h>
>>   #include <crypto/hash_info.h>
>>   
>>   #define TPM_DIGEST_SIZE 20	/* Max TPM v1.2 PCR size */
>> @@ -75,6 +79,93 @@ struct tpm_class_ops {
>>   	void (*clk_enable)(struct tpm_chip *chip, bool value);
>>   };
>>   
>> +#define TPM_NUM_EVENT_LOG_FILES		3
>> +
>> +/* Indexes the duration array */
>> +enum tpm_duration {
>> +	TPM_SHORT = 0,
>> +	TPM_MEDIUM = 1,
>> +	TPM_LONG = 2,
>> +	TPM_LONG_LONG = 3,
>> +	TPM_UNDEFINED,
>> +	TPM_NUM_DURATIONS = TPM_UNDEFINED,
>> +};
>> +
>> +#define TPM_PPI_VERSION_LEN		3
>> +
>> +struct tpm_space {
>> +	u32 context_tbl[3];
>> +	u8 *context_buf;
>> +	u32 session_tbl[3];
>> +	u8 *session_buf;
>> +};
>> +
>> +struct tpm_bios_log {
>> +	void *bios_event_log;
>> +	void *bios_event_log_end;
>> +};
>> +
>> +struct tpm_chip_seqops {
>> +	struct tpm_chip *chip;
>> +	const struct seq_operations *seqops;
>> +};
>> +
>> +struct tpm_chip {
>> +	struct device dev;
>> +	struct device devs;
>> +	struct cdev cdev;
>> +	struct cdev cdevs;
>> +
>> +	/* A driver callback under ops cannot be run unless ops_sem is held
>> +	 * (sometimes implicitly, eg for the sysfs code). ops becomes null
>> +	 * when the driver is unregistered, see tpm_try_get_ops.
>> +	 */
>> +	struct rw_semaphore ops_sem;
>> +	const struct tpm_class_ops *ops;
>> +
>> +	struct tpm_bios_log log;
>> +	struct tpm_chip_seqops bin_log_seqops;
>> +	struct tpm_chip_seqops ascii_log_seqops;
>> +
>> +	unsigned int flags;
>> +
>> +	int dev_num;		/* /dev/tpm# */
>> +	unsigned long is_open;	/* only one allowed */
>> +
>> +	char hwrng_name[64];
>> +	struct hwrng hwrng;
>> +
>> +	struct mutex tpm_mutex;	/* tpm is processing */
>> +
>> +	unsigned long timeout_a; /* jiffies */
>> +	unsigned long timeout_b; /* jiffies */
>> +	unsigned long timeout_c; /* jiffies */
>> +	unsigned long timeout_d; /* jiffies */
>> +	bool timeout_adjusted;
>> +	unsigned long duration[TPM_NUM_DURATIONS]; /* jiffies */
>> +	bool duration_adjusted;
>> +
>> +	struct dentry *bios_dir[TPM_NUM_EVENT_LOG_FILES];
>> +
>> +	const struct attribute_group *groups[3];
>> +	unsigned int groups_cnt;
>> +
>> +	u32 nr_allocated_banks;
>> +	struct tpm_bank_info *allocated_banks;
>> +#ifdef CONFIG_ACPI
>> +	acpi_handle acpi_dev_handle;
>> +	char ppi_version[TPM_PPI_VERSION_LEN + 1];
>> +#endif /* CONFIG_ACPI */
>> +
>> +	struct tpm_space work_space;
>> +	u32 last_cc;
>> +	u32 nr_commands;
>> +	u32 *cc_attrs_tbl;
>> +
>> +	/* active locality */
>> +	int locality;
>> +};
>> +
>>   #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
>>   
>>   extern int tpm_is_tpm2(struct tpm_chip *chip);
>> -- 
>> 2.17.1
>>
> 
> Hi Robert,
> 
> This patch causes a build error with Clang (bisected on next-20190207):
> 
> security/integrity/ima/ima.h:191:2: error: redefinition of enumerator 'NONE'
>          __ima_hooks(__ima_hook_enumify)
>          ^
> security/integrity/ima/ima.h:176:7: note: expanded from macro '__ima_hooks'
>          hook(NONE)                      \
>               ^
> include/linux/efi.h:1709:2: note: previous definition is here
>          NONE,
>          ^
> 1 error generated.
> 
> I am not sure how to reconcile this otherwise I would have sent a patch.
> 
> Thanks,
> Nathan
> 

-- 
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Bo PENG, Jian LI, Yanli SHI

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06 16:24 [PATCH v10, RESEND 0/6] tpm: retrieve digest size of unknown algorithms from TPM Roberto Sassu
2019-02-06 16:24 ` [PATCH v10, RESEND 1/6] tpm: dynamically allocate the allocated_banks array Roberto Sassu
2019-02-06 16:24 ` [PATCH v10, RESEND 2/6] tpm: rename and export tpm2_digest and tpm2_algorithms Roberto Sassu
2019-02-06 16:24 ` [PATCH v10, RESEND 3/6] tpm: retrieve digest size of unknown algorithms with PCR read Roberto Sassu
2019-02-06 16:24 ` [PATCH v10, RESEND 4/6] tpm: move tpm_chip definition to include/linux/tpm.h Roberto Sassu
2019-02-08  4:24   ` Nathan Chancellor
2019-02-08  8:41     ` Roberto Sassu [this message]
2019-02-08 16:16       ` Nathan Chancellor
2019-02-08 16:38         ` Roberto Sassu
2019-02-06 16:24 ` [PATCH v10, RESEND 5/6] KEYS: trusted: explicitly use tpm_chip structure from tpm_default_chip() Roberto Sassu
2019-03-18 22:35   ` Dan Williams
2019-03-21 13:15     ` Jarkko Sakkinen
2019-03-21 13:25       ` Roberto Sassu
2019-02-06 16:24 ` [PATCH v10, RESEND 6/6] tpm: pass an array of tpm_extend_digest structures to tpm_pcr_extend() Roberto Sassu

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cded9b3a-e321-ed05-4d41-51b8dab45c8d@huawei.com \
    --to=roberto.sassu@huawei.com \
    --cc=david.safford@ge.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=matthewgarrett@google.com \
    --cc=monty.wiseman@ge.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=silviu.vlasceanu@huawei.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Integrity Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-integrity/0 linux-integrity/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-integrity linux-integrity/ https://lore.kernel.org/linux-integrity \
		linux-integrity@vger.kernel.org
	public-inbox-index linux-integrity

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-integrity


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git