From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037AbdBOQUQ (ORCPT ); Wed, 15 Feb 2017 11:20:16 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58933 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751484AbdBOQUO (ORCPT ); Wed, 15 Feb 2017 11:20:14 -0500 Subject: Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck() To: Arnd Bergmann , Dmitry Vyukov References: <1745339.Zp71hEDpdI@wuerfel> <30a6c19f-c854-786d-8b36-1825528b64cf@de.ibm.com> Cc: "kasan-dev@googlegroups.com" , Andrey Ryabinin , Alexander Potapenko , linux-kernel@vger.kernel.org From: Christian Borntraeger Date: Wed, 15 Feb 2017 17:20:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <30a6c19f-c854-786d-8b36-1825528b64cf@de.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17021516-0004-0000-0000-00001197E971 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006621; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000203; SDB=6.00822355; UDB=6.00402299; IPR=6.00599808; BA=6.00005142; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014293; XFM=3.00000011; UTC=2017-02-15 16:20:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17021516-0005-0000-0000-00007D16E6B0 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-15_08:,, 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-1612050000 definitions=main-1702150156 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/15/2017 05:18 PM, Christian Borntraeger wrote: > On 02/15/2017 12:03 AM, Arnd Bergmann wrote: >> >> -#define WRITE_ONCE(x, val) \ >> -({ \ >> - union { typeof(x) __val; char __c[1]; } __u = \ >> - { .__val = (__force typeof(x)) (val) }; \ >> - __write_once_size(&(x), __u.__c, sizeof(x)); \ >> - __u.__val; \ >> -}) >> +#define WRITE_ONCE(x, val) \ >> +( \ >> + __builtin_choose_expr(sizeof(x) == 1, *(volatile typeof(&(x)))&(x) = (val), \ >> + __builtin_choose_expr(sizeof(x) == 2, *(volatile typeof(&(x)))&(x) = (val), \ >> + __builtin_choose_expr(sizeof(x) == 4, *(volatile typeof(&(x)))&(x) = (val), \ >> + __builtin_choose_expr(sizeof(x) == sizeof(long), *(volatile typeof(&(x)))&(x) = (val), \ > > Have you run sparse on those changes? > IIRC we had to add the __force to get rid of address space annotations > in that macro above. Cannot tell if we need something like that here. > The original warning was fs/afs/inode.c:448:9: sparse: incorrect type in initializer (different address spaces) fs/afs/inode.c:448:9: expected struct afs_permits *__val fs/afs/inode.c:448:9: got void [noderef] *