linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* include/linux/tpm_eventlog.h:198:20: warning: taking address of packed member 'count' of class or structure 'tcg_pcr_event2_head' may result in an unaligned pointer value
@ 2021-03-01  7:58 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-03-01  7:58 UTC (permalink / raw)
  To: Will Deacon; +Cc: kbuild-all, clang-built-linux, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 26788 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
commit: a5460b5e5fb82656807840d40d3deaecad094044 READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE()
date:   11 months ago
config: mips-randconfig-r011-20210301 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project b077d82b00d81934c7c27ac89dd8b0e7f448bded)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a5460b5e5fb82656807840d40d3deaecad094044
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout a5460b5e5fb82656807840d40d3deaecad094044
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/stat.h:19:
   In file included from include/linux/time.h:6:
   In file included from include/linux/seqlock.h:36:
   In file included from include/linux/spinlock.h:83:
   In file included from include/linux/spinlock_types.h:18:
   In file included from include/linux/lockdep.h:44:
   include/linux/debug_locks.h:17:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           return xchg(&debug_locks, 0);
                  ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:7:
   In file included from include/linux/module.h:13:
   In file included from include/linux/stat.h:19:
   In file included from include/linux/time.h:74:
   In file included from include/linux/time32.h:13:
   In file included from include/linux/timex.h:65:
   In file included from arch/mips/include/asm/timex.h:19:
   In file included from arch/mips/include/asm/cpu-type.h:12:
   In file included from include/linux/smp.h:15:
   include/linux/llist.h:222:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           return xchg(&head->first, NULL);
                  ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:7:
   In file included from include/linux/module.h:16:
   In file included from include/linux/kmod.h:9:
   In file included from include/linux/umh.h:4:
   In file included from include/linux/gfp.h:9:
   include/linux/topology.h:119:9: error: implicit declaration of function 'cpu_logical_map' [-Werror,-Wimplicit-function-declaration]
           return cpu_to_node(raw_smp_processor_id());
                  ^
   arch/mips/include/asm/mach-loongson64/topology.h:7:27: note: expanded from macro 'cpu_to_node'
   #define cpu_to_node(cpu)        (cpu_logical_map(cpu) >> 2)
                                    ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:7:
   In file included from include/linux/module.h:16:
   In file included from include/linux/kmod.h:9:
   In file included from include/linux/umh.h:4:
   In file included from include/linux/gfp.h:9:
   include/linux/topology.h:176:9: error: implicit declaration of function 'cpu_logical_map' [-Werror,-Wimplicit-function-declaration]
           return cpu_to_node(cpu);
                  ^
   arch/mips/include/asm/mach-loongson64/topology.h:7:27: note: expanded from macro 'cpu_to_node'
   #define cpu_to_node(cpu)        (cpu_logical_map(cpu) >> 2)
                                    ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:7:
   In file included from include/linux/module.h:16:
   In file included from include/linux/kmod.h:9:
   In file included from include/linux/umh.h:4:
   In file included from include/linux/gfp.h:9:
   include/linux/topology.h:210:25: error: implicit declaration of function 'cpu_logical_map' [-Werror,-Wimplicit-function-declaration]
           return cpumask_of_node(cpu_to_node(cpu));
                                  ^
   arch/mips/include/asm/mach-loongson64/topology.h:7:27: note: expanded from macro 'cpu_to_node'
   #define cpu_to_node(cpu)        (cpu_logical_map(cpu) >> 2)
                                    ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:21:
   In file included from drivers/char/tpm/st33zp24/../tpm.h:27:
   In file included from include/linux/tpm.h:24:
   In file included from include/linux/highmem.h:8:
   In file included from include/linux/mm.h:95:
   arch/mips/include/asm/pgtable.h:210:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
                   cmpxchg64(&buddy->pte, 0, _PAGE_GLOBAL);
                   ^
   arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
           cmpxchg((ptr), (o), (n));                                       \
           ^
   arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:21:
   In file included from drivers/char/tpm/st33zp24/../tpm.h:27:
   In file included from include/linux/tpm.h:24:
   In file included from include/linux/highmem.h:8:
   In file included from include/linux/mm.h:95:
   arch/mips/include/asm/pgtable.h:210:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
   arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
           cmpxchg((ptr), (o), (n));                                       \
           ^
   arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:21:
   In file included from drivers/char/tpm/st33zp24/../tpm.h:28:
>> include/linux/tpm_eventlog.h:198:20: warning: taking address of packed member 'count' of class or structure 'tcg_pcr_event2_head' may result in an unaligned pointer value [-Waddress-of-packed-member]
           count = READ_ONCE(event->count);
                             ^~~~~~~~~~~~
   include/linux/compiler.h:205:30: note: expanded from macro 'READ_ONCE'
           typeof(x) __x = __READ_ONCE(x);                                 \
                                       ^
   include/linux/compiler.h:201:50: note: expanded from macro '__READ_ONCE'
   #define __READ_ONCE(x)  (*(volatile typeof(x) *)&(x))
                                                     ^
   In file included from drivers/char/tpm/st33zp24/st33zp24.c:21:
   In file included from drivers/char/tpm/st33zp24/../tpm.h:28:
>> include/linux/tpm_eventlog.h:199:25: warning: taking address of packed member 'event_type' of class or structure 'tcg_pcr_event2_head' may result in an unaligned pointer value [-Waddress-of-packed-member]
           event_type = READ_ONCE(event->event_type);
                                  ^~~~~~~~~~~~~~~~~
   include/linux/compiler.h:205:30: note: expanded from macro 'READ_ONCE'
           typeof(x) __x = __READ_ONCE(x);                                 \
                                       ^
   include/linux/compiler.h:201:50: note: expanded from macro '__READ_ONCE'
   #define __READ_ONCE(x)  (*(volatile typeof(x) *)&(x))
                                                     ^
   14 warnings and 3 errors generated.
--
   arch/mips/include/asm/pgtable.h:210:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
   arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
           cmpxchg((ptr), (o), (n));                                       \
           ^
   arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/net/wireless/ath/wcn36xx/dxe.c:27:
   In file included from drivers/net/wireless/ath/wcn36xx/wcn36xx.h:23:
   In file included from include/net/mac80211.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:28:
   In file included from include/net/checksum.h:22:
   arch/mips/include/asm/checksum.h:195:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
           : "0" ((__force unsigned long)daddr),
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/wireless/ath/wcn36xx/dxe.c:27:
   In file included from drivers/net/wireless/ath/wcn36xx/wcn36xx.h:23:
   In file included from include/net/mac80211.h:20:
   In file included from include/linux/ieee80211.h:20:
   In file included from include/linux/etherdevice.h:21:
   include/linux/netdevice.h:562:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           } while (cmpxchg(&n->state, val, new) != val);
                    ^
   arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/net/wireless/ath/wcn36xx/dxe.c:27:
   In file included from drivers/net/wireless/ath/wcn36xx/wcn36xx.h:23:
   In file included from include/net/mac80211.h:20:
   In file included from include/linux/ieee80211.h:20:
   In file included from include/linux/etherdevice.h:21:
   include/linux/netdevice.h:562:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
   arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/net/wireless/ath/wcn36xx/dxe.c:27:
   In file included from drivers/net/wireless/ath/wcn36xx/wcn36xx.h:23:
   In file included from include/net/mac80211.h:22:
   In file included from include/net/codel.h:48:
   In file included from include/net/inet_ecn.h:8:
   In file included from include/net/inet_sock.h:22:
   In file included from include/net/sock.h:61:
   include/linux/poll.h:142:27: warning: division by zero is undefined [-Wdivision-by-zero]
                   M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
                                           ^~~~~~~~~
   include/linux/poll.h:140:32: note: expanded from macro 'M'
   #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/poll.h:126:51: note: expanded from macro '__MAP'
           (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
                                                            ^ ~~~~~~~~~
   include/linux/poll.h:142:39: warning: division by zero is undefined [-Wdivision-by-zero]
                   M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
                                                       ^~~~~~~~~
   include/linux/poll.h:140:32: note: expanded from macro 'M'
   #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/poll.h:126:51: note: expanded from macro '__MAP'
           (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
                                                            ^ ~~~~~~~~~
   In file included from drivers/net/wireless/ath/wcn36xx/dxe.c:27:
   In file included from drivers/net/wireless/ath/wcn36xx/wcn36xx.h:23:
   In file included from include/net/mac80211.h:22:
   In file included from include/net/codel.h:48:
   In file included from include/net/inet_ecn.h:8:
   In file included from include/net/inet_sock.h:22:
   include/net/sock.h:1969:12: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst);
                     ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
   In file included from drivers/net/wireless/ath/wcn36xx/dxe.c:27:
   In file included from drivers/net/wireless/ath/wcn36xx/wcn36xx.h:23:
   In file included from include/net/mac80211.h:22:
   In file included from include/net/codel.h:48:
   In file included from include/net/inet_ecn.h:8:
   In file included from include/net/inet_sock.h:22:
   include/net/sock.h:2217:8: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
           err = xchg(&sk->sk_err, 0);
                 ^
   arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
           if (!__SYNC_loongson3_war)                                      \
                ^
   arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
   # define __SYNC_loongson3_war   (1 << 31)
                                      ^
>> drivers/net/wireless/ath/wcn36xx/dxe.c:565:21: warning: taking address of packed member 'ctrl' of class or structure 'wcn36xx_dxe_desc' may result in an unaligned pointer value [-Waddress-of-packed-member]
           while (!(READ_ONCE(dxe->ctrl) & WCN36xx_DXE_CTRL_VLD)) {
                              ^~~~~~~~~
   include/linux/compiler.h:205:30: note: expanded from macro 'READ_ONCE'
           typeof(x) __x = __READ_ONCE(x);                                 \
                                       ^
   include/linux/compiler.h:201:50: note: expanded from macro '__READ_ONCE'
   #define __READ_ONCE(x)  (*(volatile typeof(x) *)&(x))
                                                     ^
   19 warnings and 4 errors generated.


vim +198 include/linux/tpm_eventlog.h

c46f3405692de1 Matthew Garrett  2019-05-20  138  
44038bc514a244 Matthew Garrett  2019-05-20  139  /**
44038bc514a244 Matthew Garrett  2019-05-20  140   * __calc_tpm2_event_size - calculate the size of a TPM2 event log entry
44038bc514a244 Matthew Garrett  2019-05-20  141   * @event:        Pointer to the event whose size should be calculated
44038bc514a244 Matthew Garrett  2019-05-20  142   * @event_header: Pointer to the initial event containing the digest lengths
c46f3405692de1 Matthew Garrett  2019-05-20  143   * @do_mapping:   Whether or not the event needs to be mapped
44038bc514a244 Matthew Garrett  2019-05-20  144   *
44038bc514a244 Matthew Garrett  2019-05-20  145   * The TPM2 event log format can contain multiple digests corresponding to
44038bc514a244 Matthew Garrett  2019-05-20  146   * separate PCR banks, and also contains a variable length of the data that
44038bc514a244 Matthew Garrett  2019-05-20  147   * was measured. This requires knowledge of how long each digest type is,
44038bc514a244 Matthew Garrett  2019-05-20  148   * and this information is contained within the first event in the log.
44038bc514a244 Matthew Garrett  2019-05-20  149   *
44038bc514a244 Matthew Garrett  2019-05-20  150   * We calculate the length by examining the number of events, and then looking
44038bc514a244 Matthew Garrett  2019-05-20  151   * at each event in turn to determine how much space is used for events in
44038bc514a244 Matthew Garrett  2019-05-20  152   * total. Once we've done this we know the offset of the data length field,
44038bc514a244 Matthew Garrett  2019-05-20  153   * and can calculate the total size of the event.
44038bc514a244 Matthew Garrett  2019-05-20  154   *
e658c82be55614 Jerry Snitselaar 2019-10-02  155   * Return: size of the event on success, 0 on failure
44038bc514a244 Matthew Garrett  2019-05-20  156   */
44038bc514a244 Matthew Garrett  2019-05-20  157  
44038bc514a244 Matthew Garrett  2019-05-20  158  static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
c46f3405692de1 Matthew Garrett  2019-05-20  159  					 struct tcg_pcr_event *event_header,
c46f3405692de1 Matthew Garrett  2019-05-20  160  					 bool do_mapping)
44038bc514a244 Matthew Garrett  2019-05-20  161  {
44038bc514a244 Matthew Garrett  2019-05-20  162  	struct tcg_efi_specid_event_head *efispecid;
44038bc514a244 Matthew Garrett  2019-05-20  163  	struct tcg_event_field *event_field;
c46f3405692de1 Matthew Garrett  2019-05-20  164  	void *mapping = NULL;
c46f3405692de1 Matthew Garrett  2019-05-20  165  	int mapping_size;
44038bc514a244 Matthew Garrett  2019-05-20  166  	void *marker;
44038bc514a244 Matthew Garrett  2019-05-20  167  	void *marker_start;
44038bc514a244 Matthew Garrett  2019-05-20  168  	u32 halg_size;
44038bc514a244 Matthew Garrett  2019-05-20  169  	size_t size;
44038bc514a244 Matthew Garrett  2019-05-20  170  	u16 halg;
44038bc514a244 Matthew Garrett  2019-05-20  171  	int i;
44038bc514a244 Matthew Garrett  2019-05-20  172  	int j;
047d50aee341d9 Peter Jones      2019-10-02  173  	u32 count, event_type;
44038bc514a244 Matthew Garrett  2019-05-20  174  
44038bc514a244 Matthew Garrett  2019-05-20  175  	marker = event;
44038bc514a244 Matthew Garrett  2019-05-20  176  	marker_start = marker;
44038bc514a244 Matthew Garrett  2019-05-20  177  	marker = marker + sizeof(event->pcr_idx) + sizeof(event->event_type)
44038bc514a244 Matthew Garrett  2019-05-20  178  		+ sizeof(event->count);
44038bc514a244 Matthew Garrett  2019-05-20  179  
c46f3405692de1 Matthew Garrett  2019-05-20  180  	/* Map the event header */
c46f3405692de1 Matthew Garrett  2019-05-20  181  	if (do_mapping) {
c46f3405692de1 Matthew Garrett  2019-05-20  182  		mapping_size = marker - marker_start;
c46f3405692de1 Matthew Garrett  2019-05-20  183  		mapping = TPM_MEMREMAP((unsigned long)marker_start,
c46f3405692de1 Matthew Garrett  2019-05-20  184  				       mapping_size);
c46f3405692de1 Matthew Garrett  2019-05-20  185  		if (!mapping) {
c46f3405692de1 Matthew Garrett  2019-05-20  186  			size = 0;
c46f3405692de1 Matthew Garrett  2019-05-20  187  			goto out;
c46f3405692de1 Matthew Garrett  2019-05-20  188  		}
c46f3405692de1 Matthew Garrett  2019-05-20  189  	} else {
c46f3405692de1 Matthew Garrett  2019-05-20  190  		mapping = marker_start;
c46f3405692de1 Matthew Garrett  2019-05-20  191  	}
c46f3405692de1 Matthew Garrett  2019-05-20  192  
c46f3405692de1 Matthew Garrett  2019-05-20  193  	event = (struct tcg_pcr_event2_head *)mapping;
047d50aee341d9 Peter Jones      2019-10-02  194  	/*
047d50aee341d9 Peter Jones      2019-10-02  195  	 * The loop below will unmap these fields if the log is larger than
047d50aee341d9 Peter Jones      2019-10-02  196  	 * one page, so save them here for reference:
047d50aee341d9 Peter Jones      2019-10-02  197  	 */
047d50aee341d9 Peter Jones      2019-10-02 @198  	count = READ_ONCE(event->count);
047d50aee341d9 Peter Jones      2019-10-02 @199  	event_type = READ_ONCE(event->event_type);
c46f3405692de1 Matthew Garrett  2019-05-20  200  
44038bc514a244 Matthew Garrett  2019-05-20  201  	efispecid = (struct tcg_efi_specid_event_head *)event_header->event;
44038bc514a244 Matthew Garrett  2019-05-20  202  
44038bc514a244 Matthew Garrett  2019-05-20  203  	/* Check if event is malformed. */
047d50aee341d9 Peter Jones      2019-10-02  204  	if (count > efispecid->num_algs) {
c46f3405692de1 Matthew Garrett  2019-05-20  205  		size = 0;
c46f3405692de1 Matthew Garrett  2019-05-20  206  		goto out;
c46f3405692de1 Matthew Garrett  2019-05-20  207  	}
44038bc514a244 Matthew Garrett  2019-05-20  208  
047d50aee341d9 Peter Jones      2019-10-02  209  	for (i = 0; i < count; i++) {
44038bc514a244 Matthew Garrett  2019-05-20  210  		halg_size = sizeof(event->digests[i].alg_id);
c46f3405692de1 Matthew Garrett  2019-05-20  211  
c46f3405692de1 Matthew Garrett  2019-05-20  212  		/* Map the digest's algorithm identifier */
c46f3405692de1 Matthew Garrett  2019-05-20  213  		if (do_mapping) {
c46f3405692de1 Matthew Garrett  2019-05-20  214  			TPM_MEMUNMAP(mapping, mapping_size);
c46f3405692de1 Matthew Garrett  2019-05-20  215  			mapping_size = halg_size;
c46f3405692de1 Matthew Garrett  2019-05-20  216  			mapping = TPM_MEMREMAP((unsigned long)marker,
c46f3405692de1 Matthew Garrett  2019-05-20  217  					     mapping_size);
c46f3405692de1 Matthew Garrett  2019-05-20  218  			if (!mapping) {
c46f3405692de1 Matthew Garrett  2019-05-20  219  				size = 0;
c46f3405692de1 Matthew Garrett  2019-05-20  220  				goto out;
c46f3405692de1 Matthew Garrett  2019-05-20  221  			}
c46f3405692de1 Matthew Garrett  2019-05-20  222  		} else {
c46f3405692de1 Matthew Garrett  2019-05-20  223  			mapping = marker;
c46f3405692de1 Matthew Garrett  2019-05-20  224  		}
c46f3405692de1 Matthew Garrett  2019-05-20  225  
c46f3405692de1 Matthew Garrett  2019-05-20  226  		memcpy(&halg, mapping, halg_size);
44038bc514a244 Matthew Garrett  2019-05-20  227  		marker = marker + halg_size;
c46f3405692de1 Matthew Garrett  2019-05-20  228  
44038bc514a244 Matthew Garrett  2019-05-20  229  		for (j = 0; j < efispecid->num_algs; j++) {
44038bc514a244 Matthew Garrett  2019-05-20  230  			if (halg == efispecid->digest_sizes[j].alg_id) {
44038bc514a244 Matthew Garrett  2019-05-20  231  				marker +=
44038bc514a244 Matthew Garrett  2019-05-20  232  					efispecid->digest_sizes[j].digest_size;
44038bc514a244 Matthew Garrett  2019-05-20  233  				break;
44038bc514a244 Matthew Garrett  2019-05-20  234  			}
44038bc514a244 Matthew Garrett  2019-05-20  235  		}
44038bc514a244 Matthew Garrett  2019-05-20  236  		/* Algorithm without known length. Such event is unparseable. */
c46f3405692de1 Matthew Garrett  2019-05-20  237  		if (j == efispecid->num_algs) {
c46f3405692de1 Matthew Garrett  2019-05-20  238  			size = 0;
c46f3405692de1 Matthew Garrett  2019-05-20  239  			goto out;
c46f3405692de1 Matthew Garrett  2019-05-20  240  		}
44038bc514a244 Matthew Garrett  2019-05-20  241  	}
44038bc514a244 Matthew Garrett  2019-05-20  242  
c46f3405692de1 Matthew Garrett  2019-05-20  243  	/*
c46f3405692de1 Matthew Garrett  2019-05-20  244  	 * Map the event size - we don't read from the event itself, so
c46f3405692de1 Matthew Garrett  2019-05-20  245  	 * we don't need to map it
c46f3405692de1 Matthew Garrett  2019-05-20  246  	 */
c46f3405692de1 Matthew Garrett  2019-05-20  247  	if (do_mapping) {
c46f3405692de1 Matthew Garrett  2019-05-20  248  		TPM_MEMUNMAP(mapping, mapping_size);
c46f3405692de1 Matthew Garrett  2019-05-20  249  		mapping_size += sizeof(event_field->event_size);
c46f3405692de1 Matthew Garrett  2019-05-20  250  		mapping = TPM_MEMREMAP((unsigned long)marker,
c46f3405692de1 Matthew Garrett  2019-05-20  251  				       mapping_size);
c46f3405692de1 Matthew Garrett  2019-05-20  252  		if (!mapping) {
c46f3405692de1 Matthew Garrett  2019-05-20  253  			size = 0;
c46f3405692de1 Matthew Garrett  2019-05-20  254  			goto out;
c46f3405692de1 Matthew Garrett  2019-05-20  255  		}
c46f3405692de1 Matthew Garrett  2019-05-20  256  	} else {
c46f3405692de1 Matthew Garrett  2019-05-20  257  		mapping = marker;
c46f3405692de1 Matthew Garrett  2019-05-20  258  	}
c46f3405692de1 Matthew Garrett  2019-05-20  259  
c46f3405692de1 Matthew Garrett  2019-05-20  260  	event_field = (struct tcg_event_field *)mapping;
c46f3405692de1 Matthew Garrett  2019-05-20  261  
44038bc514a244 Matthew Garrett  2019-05-20  262  	marker = marker + sizeof(event_field->event_size)
44038bc514a244 Matthew Garrett  2019-05-20  263  		+ event_field->event_size;
44038bc514a244 Matthew Garrett  2019-05-20  264  	size = marker - marker_start;
44038bc514a244 Matthew Garrett  2019-05-20  265  
047d50aee341d9 Peter Jones      2019-10-02  266  	if (event_type == 0 && event_field->event_size == 0)
c46f3405692de1 Matthew Garrett  2019-05-20  267  		size = 0;
047d50aee341d9 Peter Jones      2019-10-02  268  
c46f3405692de1 Matthew Garrett  2019-05-20  269  out:
c46f3405692de1 Matthew Garrett  2019-05-20  270  	if (do_mapping)
c46f3405692de1 Matthew Garrett  2019-05-20  271  		TPM_MEMUNMAP(mapping, mapping_size);
44038bc514a244 Matthew Garrett  2019-05-20  272  	return size;
44038bc514a244 Matthew Garrett  2019-05-20  273  }
c46f3405692de1 Matthew Garrett  2019-05-20  274  

:::::: The code at line 198 was first introduced by commit
:::::: 047d50aee341d940350897c85799e56ae57c3849 efi/tpm: Don't access event->count when it isn't mapped

:::::: TO: Peter Jones <pjones@redhat.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29801 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-01  7:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01  7:58 include/linux/tpm_eventlog.h:198:20: warning: taking address of packed member 'count' of class or structure 'tcg_pcr_event2_head' may result in an unaligned pointer value kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).