From patchwork Wed Aug 24 21:59:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 9298403 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 3F78560459 for ; Wed, 24 Aug 2016 21:59:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3235C27E3E for ; Wed, 24 Aug 2016 21:59:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2353829139; Wed, 24 Aug 2016 21:59:55 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 914D327E3E for ; Wed, 24 Aug 2016 21:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755200AbcHXV7x (ORCPT ); Wed, 24 Aug 2016 17:59:53 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:24298 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753631AbcHXV7w (ORCPT ); Wed, 24 Aug 2016 17:59:52 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7OLxlZ0012505 for ; Wed, 24 Aug 2016 17:59:51 -0400 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0b-001b2d01.pphosted.com with ESMTP id 250w833rx4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 24 Aug 2016 17:59:51 -0400 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 24 Aug 2016 18:59:28 -0300 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 24 Aug 2016 18:59:25 -0300 X-IBM-Helo: d24dlp01.br.ibm.com X-IBM-MailFrom: bauerman@linux.vnet.ibm.com X-IBM-RcptTo: linux-security-module@vger.kernel.org Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id B37C93520076 for ; Wed, 24 Aug 2016 17:59:03 -0400 (EDT) Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7OLxPTX4882576 for ; Wed, 24 Aug 2016 18:59:25 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u7OLxOp2023572 for ; Wed, 24 Aug 2016 18:59:25 -0300 Received: from hactar.localnet ([9.78.132.167]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u7OLxOFd023550; Wed, 24 Aug 2016 18:59:24 -0300 From: Thiago Jung Bauermann To: kbuild test robot Cc: kbuild-all@01.org, linux-ima-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, kexec@lists.infradead.org Subject: Re: [integrity:next-restore-kexec 21/31] kernel/kexec_core.c:780:10: warning: passing argument 1 of '__va' makes integer from pointer without a cast Date: Wed, 24 Aug 2016 18:59:23 -0300 User-Agent: KMail/4.14.3 (Linux/3.13.0-93-generic; KDE/4.14.13; x86_64; ; ) In-Reply-To: <201608232218.il5qUAgx%fengguang.wu@intel.com> References: <201608232218.il5qUAgx%fengguang.wu@intel.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082421-1523-0000-0000-000002187462 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082421-1524-0000-0000-0000280FEF26 Message-Id: <14446997.EfN524sbRK@hactar> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-24_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608240238 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Am Dienstag, 23 August 2016, 22:44:19 schrieb kbuild test robot: > tree: > https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git > next-restore-kexec head: 62bc4b565254de4796a0835f6f67569eb4835f9f > commit: d03a46a7730822305a2264c9defa21c06d4ff861 [21/31] kexec_file: Add > mechanism to update kexec segments. config: m68k-sun3_defconfig (attached > as .config) > compiler: m68k-linux-gcc (GCC) 4.9.0 > reproduce: > wget > https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin > /make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross > git checkout d03a46a7730822305a2264c9defa21c06d4ff861 > # save the attached .config to linux build tree > make.cross ARCH=m68k > > All warnings (new ones prefixed by >>): > > kernel/kexec_core.c: In function 'kexec_update_segment': > >> kernel/kexec_core.c:780:10: warning: passing argument 1 of '__va' makes > >> integer from pointer without a cast > ptr = __va(addr); > ^ > In file included from arch/m68k/include/asm/page.h:46:0, > from arch/m68k/include/asm/thread_info.h:5, > from include/linux/thread_info.h:54, > from include/asm-generic/preempt.h:4, > from ./arch/m68k/include/generated/asm/preempt.h:1, > from include/linux/preempt.h:59, > from include/linux/spinlock.h:50, > from include/linux/mmzone.h:7, > from include/linux/gfp.h:5, > from include/linux/mm.h:9, > from kernel/kexec_core.c:12: > arch/m68k/include/asm/page_mm.h:105:21: note: expected 'long unsigned > int' but argument is of type 'void *' static inline void *__va(unsigned > long x) > ^ This doesn't produce a warning on x86 and powerpc because on both arches __va is a macro which does a cast to unsigned long, but on m68k __va is a function expecting an unsigned long argument. > In file included from include/asm-generic/bug.h:13:0, > from arch/m68k/include/asm/bug.h:28, > from include/linux/bug.h:4, > from include/linux/mmdebug.h:4, > from include/linux/mm.h:8, > from kernel/kexec_core.c:12: > include/linux/kernel.h:742:17: warning: comparison of distinct pointer > types lacks a cast (void) (&_min1 == &_min2); \ > ^ > kernel/kexec_core.c:800:14: note: in expansion of macro 'min' > uchunk = min(bufsz, mchunk); > ^ This is because bufsz is unsigned long but mchunk is size_t. Both warnings are fixed by the changes below, which will be in my next revision of the kexec buffer hand-over series. diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 6ec09e85efd9..ea2e5a7b9b69 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -261,8 +261,8 @@ extern int kexec_purgatory_get_set_symbol(struct kimage *image, unsigned int size, bool get_value); extern void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name); -int kexec_update_segment(const char *buffer, unsigned long bufsz, - unsigned long load_addr, unsigned long memsz); +int kexec_update_segment(const char *buffer, size_t bufsz, + unsigned long load_addr, size_t memsz); extern void __crash_kexec(struct pt_regs *); extern void crash_kexec(struct pt_regs *); int kexec_should_crash(struct task_struct *); diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 3740235d6819..11ca5f8678df 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -732,8 +732,8 @@ static struct page *kimage_alloc_page(struct kimage *image, * * Return: 0 on success, negative errno on error. */ -int kexec_update_segment(const char *buffer, unsigned long bufsz, - unsigned long load_addr, unsigned long memsz) +int kexec_update_segment(const char *buffer, size_t bufsz, + unsigned long load_addr, size_t memsz) { int i; unsigned long entry; @@ -763,7 +763,7 @@ int kexec_update_segment(const char *buffer, unsigned long bufsz, break; } if (i == kexec_image->nr_segments) { - pr_err("Couldn't find segment to update: 0x%lx, size 0x%lx\n", + pr_err("Couldn't find segment to update: 0x%lx, size 0x%zx\n", load_addr, memsz); return -EINVAL; } @@ -777,7 +777,7 @@ int kexec_update_segment(const char *buffer, unsigned long bufsz, dest = addr; break; case IND_INDIRECTION: - ptr = __va(addr); + ptr = __va(entry & PAGE_MASK); break; case IND_SOURCE: /* Shouldn't happen, but verify just to be safe. */