From patchwork Thu Jul 26 08:13:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142941 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp173185ljj; Thu, 26 Jul 2018 01:14:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcDzPAVv3YKuPSJG0IcUSBgWZKaCBG7b+reOdYyi+hAFTHnsYd5f0OkYyLaRHzc+/Sf6t7/ X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr932285pga.181.1532592874308; Thu, 26 Jul 2018 01:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532592874; cv=none; d=google.com; s=arc-20160816; b=hylF96YHp6XJzWi/BDN+9fKszROnUCg7gZcl14k3Tjyz8KjondP1lBG6hI08NleIZl 2iWXs/qrWcBwbc83JK5rh/GoH+mpeXzvIATGorXtaXU2pxVTrLgpWq6voKENnx9Vw4f+ zHrzbC35TTiC0kCM1UYIAdDwPfZ66ZYA5XFmwci9w00PiBpoE1Pn7TIwWBH9/N81NT0v /qxHg4qJorFsHWj2WQGzuQd3Q8Q0WxHnBDbDriK4AFn1+qMYubIrfOu25vH+LQurfObe j8jjbNtHAKsFRGG3dEfrPLreIIsftThPhCped9N7ahHbsOolQl7kGx9eTEc2wTj/cAm3 BNDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=V2uZu2vpkyQ+4GZ4ocE9+OYlxItLufhp/EzqjoYhpNY=; b=gNB25zaixUkSJMbMy2uIWosToll5dkBbywRT7K4IUjMmYHJzioffuBybqjco0uDGBP fBvhjZtiXmtZv5pHK65nYyclcSgd/HvggRWZqyq5+QMg0rab/kTI8C5z0RlguR7w/dKR v9zCxqN8lmYcQYzOu7KYykRjvVcggbbrLVzjlYap/dD35bPh24ixDG1YtA4FgVreAOsa AjRh4yjP7SydVYiODM1g/fuePcuV94F8qqHVTwJbe6pdavodJhvK/2TZJiQ3gJsuuwLG 9pKCpEuyio9yrRhu7K4y2f/1msXJuQea0GPkGV2U00gL86X+nOFOsuDZZS08Qh6G+1ef h99g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l184-v6si790427pge.257.2018.07.26.01.14.34; Thu, 26 Jul 2018 01:14:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbeGZJaO (ORCPT + 13 others); Thu, 26 Jul 2018 05:30:14 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:33507 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729111AbeGZJaN (ORCPT ); Thu, 26 Jul 2018 05:30:13 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0MTP5b-1fbHfA2uyF-00SOZS; Thu, 26 Jul 2018 10:14:27 +0200 From: Arnd Bergmann To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, Arnd Bergmann , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [stable 4.14] turn off -Wattribute-alias Date: Thu, 26 Jul 2018 10:13:22 +0200 Message-Id: <20180726081358.3829157-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 X-Provags-ID: V03:K1:fHpgrsexntLLsSc/URMhUQgv1faNscQ1vwHLBRJtJShiQHRy+L2 Gh1BqIbuYq0w5d4Vv/Ug+W8h8Durf0FqZRIvM2SYpEcxZCmYMPUNasYAUikwP0blSsOXoJY 9zTAL49sFheiElRoVX4A0qwJS3IliA9nZPXWeN4P6wgoeDc9mNtNz1n82nnlQRQIye9kCLK ynh8C8OHBhe1V9LIp++Jw== X-UI-Out-Filterresults: notjunk:1; V01:K0:bxKCtIWwhKM=:FwmdEtgtcQlhzMFuv/L2LF FKu2rPv53Pkn/HgKw7Y7gEoCibJ85fP1kpHBsG+VUCTxpP+WD9J85IBhjGFPweUApfOWEk9s3 S3jWzb9cqqdWwDNyAlb6SHG6HcsLTS0dnSmAlpRz8mEy0DwXH0QYchH+nVnR3UIiXZ+tvGjIG 13MepYcvD7Ah6Ln9RMMiF+MCs8j7Nfly5TADF+LjsbH+d/YVDr99OmK/4Y3dxB/TrDgCcpuDd cep1c0TsqcuA+l09FGTzclQ025QMkIIzufgoBYvBiakxaudz0YFyj2lIaxByaeK5i+/yT34N+ ECjqnRwqmOtzcvuXHwyjrp8gyAFGMIFl+OjzoSTPk1LhyxH9xgXN+QRXNFSp5hv0jpil0cs7Y DRFasYUCDpR8m9z39o3v1BSUgZYAn5dbenRvezvvZOF6cU9AAMMpw/kpp+nKUWpOIXCUoffp0 Hcpa2klWl6ZGWgksA2WAR7Ndo5gyr99GG7xpG4UeF768e7eV8TMhaw7D2satA8dsLWHAuav+q QagHNPZSXSRpz3cIF9UD88JTbNeo4iEi2mO/OaWrGlee/+3dTKJObxMzUmNZpR1pinVm6IozW bhkERfv/zRrOSv8X0mrXOIwcTtwybV+bzlTxDfHnE0iYW85Hpm5hRGA2W8BAKZpigo0rZ+OFQ f0FDfdjzCfQpK45dg71T/8Zaww3gRE9P1aOixRHsg5o+TaI3rrAEzK6XRjU1opxRMl/Y= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Starting with gcc-8.1, we get a warning about all system call definitions, which use an alias between functions with incompatible prototypes, e.g.: In file included from ../mm/process_vm_access.c:19: ../include/linux/syscalls.h:211:18: warning: 'sys_process_vm_readv' alias between functions of incompatible types 'long int(pid_t, const struct iovec *, long unsigned int, const struct iovec *, long unsigned int, long unsigned int)' {aka 'long int(int, const struct iovec *, long unsigned int, const struct iovec *, long unsigned int, long unsigned int)'} and 'long int(long int, long int, long int, long int, long int, long int)' [-Wattribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ ../include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^~~~~~~~~~~~~~~~~ ../include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) ^~~~~~~~~~~~~~~ ../mm/process_vm_access.c:300:1: note: in expansion of macro 'SYSCALL_DEFINE6' SYSCALL_DEFINE6(process_vm_readv, pid_t, pid, const struct iovec __user *, lvec, ^~~~~~~~~~~~~~~ ../include/linux/syscalls.h:215:18: note: aliased declaration here asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ ^~~ ../include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^~~~~~~~~~~~~~~~~ ../include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) ^~~~~~~~~~~~~~~ ../mm/process_vm_access.c:300:1: note: in expansion of macro 'SYSCALL_DEFINE6' SYSCALL_DEFINE6(process_vm_readv, pid_t, pid, const struct iovec __user *, lvec, This is really noisy and does not indicate a real problem. In the latest mainline kernel, this was addressed by commit bee20031772a ("disable -Wattribute-alias warning for SYSCALL_DEFINEx()"), which seems too invasive to backport. This takes a much simpler approach and just disables the warning across the kernel. Signed-off-by: Arnd Bergmann --- Makefile | 1 + 1 file changed, 1 insertion(+) -- 2.18.0 diff --git a/Makefile b/Makefile index a44d6b2adb76..91f9d2d56eac 100644 --- a/Makefile +++ b/Makefile @@ -642,6 +642,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) +KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) From patchwork Thu Jul 26 08:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142945 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp177549ljj; Thu, 26 Jul 2018 01:19:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd19/R7pyW7/9I7v43+perhKiE/91SLXDF2nkRSjbymL2U+scoJz6e7lYYD6W4Uz+TNnDrK X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr1045136pld.118.1532593196848; Thu, 26 Jul 2018 01:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532593196; cv=none; d=google.com; s=arc-20160816; b=B0OOsRQcOFJe+w865ZTe3qk1erBVHflcXGxf/FidSsfiJ6YfkqlqZ+ADPrF/l/535P flnr63ZFjIWg3HEM8ytaraQlnB2CTjoYtoIXQ5JsNuMJLob2cMez+te85SCE7IDqPZ9L L9Mq2bX9/JbGr3KHvI8AFrHCkovUteA8ucuVtAmwh0F7A1Q5j8DFm4ySc9k6zxSYXxq2 R/1wXu8GwGBjyWa7FftGy8gC34Wtjg2meGFReOQ2L11ymYwqpIpqzdIOYoC0+Ga/Q/1S AdkTbUAZRK37CCB4UlwNXvPBeeo9/boK6z3/Do7Q9fYDCMPu7LagLynRQdjL9uWtANnK v4mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WPUKofCHKBt1ymmc/uzUWnpTLMP+SsS/pAFTKJcOBf8=; b=0445rOAG1RSLPM7+nLKXxaChfwYGoLeKkIHezgkcGkU/3jCkgI9zGVKdz5s04cd2Ji HWoLy8Nvr4s40o2PPQGCK3ky6MPzzEY3lUNjfBWdy3jROCqAYq+vZWILvab1PqenjKde UvhAX4BTLXW16pI6AdqIan73dOcdn1Fp3Bkalg31PNIuPilyhheA3EP7lYq1oh7ls7Ic vZaNoF4y0s2/4a+c5mYuZC3BtT34+A9lFIHVUWPrQjifCk4NCJYuo7EKDGIyiCLi7YjX DhHCc8U0hH/4DXOfhOk+GdbeeVNzgfQox8KNavdItj3Hq9F+JdwLpw90smz6j5MP8t/N Dbpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65-v6si775999pld.451.2018.07.26.01.19.56; Thu, 26 Jul 2018 01:19:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbeGZJfi (ORCPT + 13 others); Thu, 26 Jul 2018 05:35:38 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:43425 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbeGZJfh (ORCPT ); Thu, 26 Jul 2018 05:35:37 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lutsn-1g8gw70ABF-0104xc; Thu, 26 Jul 2018 10:15:22 +0200 From: Arnd Bergmann To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, Arnd Bergmann , Alexander Viro , Peter Zijlstra , Serge Hallyn , James Morris , Aleksa Sarai , "Eric W. Biederman" , Frederic Weisbecker , Thomas Gleixner , Andrew Morton , Linus Torvalds Subject: [PATCH 2/2] [stable-4.9] exec: avoid gcc-8 warning for get_task_comm Date: Thu, 26 Jul 2018 10:13:26 +0200 Message-Id: <20180726081358.3829157-5-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180726081358.3829157-1-arnd@arndb.de> References: <20180726081358.3829157-1-arnd@arndb.de> X-Provags-ID: V03:K1:ygwcy1pEtdaiy91b1W5kuw7bd72pA/4vKfZ09R8yKGuZLUtEPsY hVxD2Iy8mdKSii+ri98EHXf8WLwF2md5900dqUrqPnijRye8PNfmrGVyKhyaV8oqlFT+37g xDZc3a95HvxwXaIUM+Ch1KDzvv6LE76soCyRMdKuywA/VV+gfL1Zs/DuVT3JWah3wnsUeFZ ETbK22auCv3HMcjJRii9w== X-UI-Out-Filterresults: notjunk:1; V01:K0:xHRr5YkpUp0=:0SjgYHYU07n+Po0Qv7OhYo +3lJOuaZNwaUQRQztymRx3j1B5VT06vz0qSVy5G+eUqaYs+T7gFzqI9i9gxEWC3ZwfLICnyXX El272K6avnTJpGUQ4xgofHNBwmH9z5NuFOaJO7zoVce4jvZxwBWRbux4pSFSuYziT6LT8FSCy bW2MhbfD0cYiH4iklLfzEQtaRwBbwMWIJl7GsGPXiXyBHXDKgTsFBa2FncH50VK/Wluslx8x4 QUM/Rn64wYy32UpnZZpSFQuZ3oRVALlrVM1ksKfYSSt2qXtlMKW0WWMgkD4V03GdioaG10Ak2 2L/fp3ZDU+lSD273Bt7u3uBCy9SjzSGcg3D6Y+1zFtV3Jggv5U44EJG+XoPWZv1+xpDVa0x6T nSGwqzoUCiwILREtIRAKRHd+bSPyUr/NqQP47rMxA1sp8mr9MYTDIUTooIOSO0iyfuZ+VZxTB Yuqbpgy/ijO3oDHfkWm+8+tKyXRdbJFkRUELdmhp1F1P2uth+ecg/A3wJ3Syut1v9E0PLXmRF k2Of67norojLYrW8RnjNLF8+VzK2OzjkdEFW0MMFX+YZZVB30yUbRmO2O0hEcgjtpj0STMKkQ YirJeT0Mo9vyu2+gwpSSzh8C8d5Ol56aTWWBA6mhy3CIC0rF/o7d81ffDXuAnue8+1XfMis7r 2ACQYOtTtq754CuYqvI5B6AamGo86yddlawyboP5WX5Dxk4oejvHHtxLzrFhhuKyDeTk= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit 3756f6401c302617c5e091081ca4d26ab604bec5 upstream. gcc-8 warns about using strncpy() with the source size as the limit: fs/exec.c:1223:32: error: argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess] This is indeed slightly suspicious, as it protects us from source arguments without NUL-termination, but does not guarantee that the destination is terminated. This keeps the strncpy() to ensure we have properly padded target buffer, but ensures that we use the correct length, by passing the actual length of the destination buffer as well as adding a build-time check to ensure it is exactly TASK_COMM_LEN. There are only 23 callsites which I all reviewed to ensure this is currently the case. We could get away with doing only the check or passing the right length, but it doesn't hurt to do both. Link: http://lkml.kernel.org/r/20171205151724.1764896-1-arnd@arndb.de Signed-off-by: Arnd Bergmann Suggested-by: Kees Cook Acked-by: Kees Cook Acked-by: Ingo Molnar Cc: Alexander Viro Cc: Peter Zijlstra Cc: Serge Hallyn Cc: James Morris Cc: Aleksa Sarai Cc: "Eric W. Biederman" Cc: Frederic Weisbecker Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Arnd Bergmann --- fs/exec.c | 7 +++---- include/linux/sched.h | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) -- 2.18.0 diff --git a/fs/exec.c b/fs/exec.c index b8c43be24751..fcd8642ef2d2 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1228,15 +1228,14 @@ static int de_thread(struct task_struct *tsk) return -EAGAIN; } -char *get_task_comm(char *buf, struct task_struct *tsk) +char *__get_task_comm(char *buf, size_t buf_size, struct task_struct *tsk) { - /* buf must be at least sizeof(tsk->comm) in size */ task_lock(tsk); - strncpy(buf, tsk->comm, sizeof(tsk->comm)); + strncpy(buf, tsk->comm, buf_size); task_unlock(tsk); return buf; } -EXPORT_SYMBOL_GPL(get_task_comm); +EXPORT_SYMBOL_GPL(__get_task_comm); /* * These functions flushes out all traces of the currently running executable diff --git a/include/linux/sched.h b/include/linux/sched.h index 5ebef8c86c26..1cc5723a7821 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2999,7 +2999,11 @@ static inline void set_task_comm(struct task_struct *tsk, const char *from) { __set_task_comm(tsk, from, false); } -extern char *get_task_comm(char *to, struct task_struct *tsk); +extern char *__get_task_comm(char *to, size_t len, struct task_struct *tsk); +#define get_task_comm(buf, tsk) ({ \ + BUILD_BUG_ON(sizeof(buf) != TASK_COMM_LEN); \ + __get_task_comm(buf, sizeof(buf), tsk); \ +}) #ifdef CONFIG_SMP void scheduler_ipi(void);