Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp720090imm; Fri, 1 Jun 2018 08:24:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKmbk8CF/vrcxIx4e4kAYh5gObYYRL+naShUHO8RHhIo7GM6VFgVJ7CLZMD5YBHYFOO8jME X-Received: by 2002:a17:902:1e3:: with SMTP id b90-v6mr11280260plb.273.1527866672620; Fri, 01 Jun 2018 08:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527866672; cv=none; d=google.com; s=arc-20160816; b=CLiukfX72kSnLtFN2ata09bV02o2h4i6ODTgNtnvCraEcOkltRlMibKcGkvk6Tgwz9 Xhij1eI77TiFF+Xkz4WPMH8pS39W5zOaMCDW/XdyvRoMU7mBt78/qrfzKfo1rXKIo5TG Z9dn0I4VbOg7tjYJ7eIYhDC4/4iR0Hh0ywAXqaEqGJE1Qhx49lYSXJnQSsHAMp9iHzhL KGNtiz6MUSbkk+U9Z5KvSgiaXdl+k8wvNC+sjWM4ZN9PgIYPO77SOkQQ6vpu4eNW8OFq HX/6Bij6+1EyV85Lbq7yMaw1e+8EPPjpuHDzhfMnablc8AumTiLfAa6aPPC7Y8Wjw/pO QDXg== 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:dkim-signature:arc-authentication-results; bh=K3rXWwhwJvMABntZqqBfDhUYJV2QRa6OEeAxFi/HiMM=; b=Ss1Kl5vDzhSRm+SG2lhd+z8KWW6JP1zxjm6k90FsvDaPGDStOuGaRqrx6ScE8JBJvl fdLyACTrwGlqcTTO5ePz0GVCvrhZgzfIcsYAdbt43nd+uYKC2bFwy4AEi+coJW6uRIEN IuL3iHm2Kzh7gqP8LjRHgFbmCuoWRwYJmFTNmJytmnjLCrvPcmkK96egDSHjnw9upBmg 4lXqt/g6Fl3VK2Q9PSmoQGAUNMn4K5br/BRhCWuhjX2wJPkhBIQ7T/xFHny697+CumC3 5DnyTzIPLFpn7ZtYanoq3o2eKq4dZLla5UtouqRf7Grq8ZqDNTEoVAWjrbGsUuElloTQ v0vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ispBwhUa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11-v6si1402914pge.290.2018.06.01.08.24.17; Fri, 01 Jun 2018 08:24:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ispBwhUa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbeFAPWE (ORCPT + 99 others); Fri, 1 Jun 2018 11:22:04 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54662 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752981AbeFAPVd (ORCPT ); Fri, 1 Jun 2018 11:21:33 -0400 Received: by mail-wm0-f66.google.com with SMTP id o13-v6so3718784wmf.4 for ; Fri, 01 Jun 2018 08:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K3rXWwhwJvMABntZqqBfDhUYJV2QRa6OEeAxFi/HiMM=; b=ispBwhUaiREYsmofFxS89Dwrp1QIHWTyLHG3TPewWhRUimY3djRz0wqgCcjg9ARybB VC3QAzYtYy0pEMC3AHnqas7+Hww+ubMbGLLU9jcxOF2dqMLc1Zui1QbTfLdtCYZrdgqT hVyRT3beoD4+MQjKuk+biXeZm06koQr0ATa+ajVSiDAnUDFtkeVDyACeaSA+362yoEY2 ZT4fQhE28XDEMZ3GopALIkdh8ufJdMHNwNtR1nYetG9+UMM8p5fXfwtiyVhlVYNK2xG1 7/7/8M13ChYq1Ry8JL939nLFf1Q7yKbTFYOxMJuvo9caztzq1y22ZEVF9df2l83FzM6y Djow== 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; bh=K3rXWwhwJvMABntZqqBfDhUYJV2QRa6OEeAxFi/HiMM=; b=iLBVW4By0Yf6AiM1QkmwCCbw0Bxd9mveF4Qz6sk93pM0hQY4F+GgljPZTGbdoWfjVJ eixfwVcVfcOcL1ogOPmOpBn6eP2UHCpn6wywocP0FHozIA7OeJtLQMpDJZH3TFyBiqVn ZusQD4KtP24Od5U+0W7DRk1XOpuMI28Uuaki3KmsMyzgPhZ5W6RNP9LfVXqNFDzG6vqW xTJrn3zPdZqiiY1CtOObHP7F0PP7ezhSl5NiLcW17iUv+W57HSl7V6fnZbBnM/lc0bCe H5AyVBf8yzePpPTmtzxawwITkXeo+NE2YXcWhDhD/1qg0KHI2CgUNfDsaZ9vr4NHPR0L KoLQ== X-Gm-Message-State: ALKqPwddA+kPdIguvtSZYg6Wv2XUph1hd39ALAIenmidNRIvCD3mtEIN LM1bJpz2KZAHC+9i+CVgcy0= X-Received: by 2002:a50:8987:: with SMTP id g7-v6mr12778582edg.25.1527866491806; Fri, 01 Jun 2018 08:21:31 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4023:8a00:1051:9318:8490:3b94]) by smtp.gmail.com with ESMTPSA id j16-v6sm516409edp.22.2018.06.01.08.21.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 08:21:31 -0700 (PDT) From: Luc Van Oostenryck To: Palmer Dabbelt Cc: Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Luc Van Oostenryck Subject: [PATCH 3/3] riscv: fix __user annotation for __copy_user() Date: Fri, 1 Jun 2018 17:21:23 +0200 Message-Id: <20180601152123.47256-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180601152123.47256-1-luc.vanoostenryck@gmail.com> References: <20180601152123.47256-1-luc.vanoostenryck@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __copy_user() is a function, written in assembly, used to copy memory between kernel & user space. As such its to & from args may both take a user pointer or a kernel pointer. However the prototype for this function declare these two args as 'void __user *', which is no more & no less correct than declaring them as 'void *'. In fact theer is no possible correct annotation for such a function. The problem is worked around here by declaring these args as unsigned long and casting them to the right type in each of two callers raw_copy_{to,from}_user() as some kind of cast would be needed anyway. Note: another solution, maybe cleaner but slightly more complex, would be to declare two version of __copy_user, either in the asm file or via an alias, each having already the correct typing for raw_copy_{to,from}_user(). Signed-off-by: Luc Van Oostenryck --- arch/riscv/include/asm/uaccess.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h index 14b0b22fb..c7a6a4a4a 100644 --- a/arch/riscv/include/asm/uaccess.h +++ b/arch/riscv/include/asm/uaccess.h @@ -392,19 +392,19 @@ do { \ }) -extern unsigned long __must_check __copy_user(void __user *to, - const void __user *from, unsigned long n); +extern unsigned long __must_check __copy_user(unsigned long to, + const unsigned long from, unsigned long n); static inline unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n) { - return __copy_user(to, from, n); + return __copy_user((unsigned long)to, (unsigned long)from, n); } static inline unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n) { - return __copy_user(to, from, n); + return __copy_user((unsigned long)to, (unsigned long)from, n); } extern long strncpy_from_user(char *dest, const char __user *src, long count); -- 2.17.1