Received: by 10.213.65.68 with SMTP id h4csp2566595imn; Mon, 9 Apr 2018 05:44:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx49wWjOYd5TsvajIsnQzkRjHWQSjCaTY7x5cNCXSksO/Agpzh0ZPuZzNI0QnYNLnUZW//9nN X-Received: by 10.98.223.149 with SMTP id d21mr28924965pfl.160.1523277840999; Mon, 09 Apr 2018 05:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523277840; cv=none; d=google.com; s=arc-20160816; b=vlv3cqOMAx/JIMqa0ViUp4WJYqVLJEaPwJgjlnDtsAIA43QBaanxFUu818bE3sblzh PrPF7YVvcMVLS6uTNfjzGG2IjPpUmhOLwNw5y1Yd5JdkIWTmTBKKfgpJyCHBwaXDZT1W gAsOGQJa8psBMYcjoJUzoT0egUXPf/LUYhnrISNAIIWDr4ijAx8rNsHeEx15l5nQUuQz DzcJJWo31Cm8l+T42ue2Y3iqhtB4x53Mv7sMO45JR2pJJWN7+tXrew1b93Ok5xaC1eEB Rg/BzndiWWIjgqo5qaNtMPDZqXBKWK9dR2u3pGCU132G16dDC2qhMzeYVCb/7ziAXBP+ N7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=w46Dloze1+2d7CSESioctRcCPQNQBLL/pF/xj465fqc=; b=bXldLRLQLtQQrQoIgD6zukdGfqpMTr8Ezj2BIB18lH2klxz8fJr1avTzWL+v4Yo3Mk 3QPu6JartHwPi4d4/UuMTVCbKE71LRthayDC3bserIb4B6iAzeSE+li6NIQmUuHJ0KUq 221VsbqudzdmtcqcseOtp5qStmDQ6+GEdF/1REIZVzv4OuBBqN2vJ2o33pXkbtsbYhRC k+fbYmGtRqisKGtGSqsMVXUl4/wFmtNCxsgJpdwvalRT9jWPLCeGXIs/18A22TIZz8so D7RkAry14Pju3/rUWMDCO0uyVxy9AXiSvR0V8K14dn/iwTQUUnBJR5HcP3ZwzuLdoaMH 1M3A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15-v6si259504pli.163.2018.04.09.05.43.24; Mon, 09 Apr 2018 05:44:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751886AbeDIMj5 (ORCPT + 99 others); Mon, 9 Apr 2018 08:39:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38672 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751786AbeDIMj4 (ORCPT ); Mon, 9 Apr 2018 08:39:56 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w39CbbxJ068245 for ; Mon, 9 Apr 2018 08:39:55 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h847ukbvn-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 09 Apr 2018 08:39:42 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Apr 2018 13:39:39 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 9 Apr 2018 13:39:36 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w39CdZiL5833142; Mon, 9 Apr 2018 12:39:35 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28E334C046; Mon, 9 Apr 2018 13:32:18 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EBC904C04E; Mon, 9 Apr 2018 13:32:17 +0100 (BST) Received: from mschwideX1 (unknown [9.152.212.220]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Apr 2018 13:32:17 +0100 (BST) Date: Mon, 9 Apr 2018 14:39:34 +0200 From: Martin Schwidefsky To: Joe Perches Cc: Heiko Carstens , linux-s390@vger.kernel.org, LKML , Rasmus Villemoes , Petr Mladek Subject: Re: s390: defective uses of va_arg in __debug_sprintf_event In-Reply-To: <1523041723.6127.33.camel@perches.com> References: <1523041723.6127.33.camel@perches.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18040912-0008-0000-0000-000004E858E5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040912-0009-0000-0000-00001E7B7D10 Message-Id: <20180409143934.3f27902c@mschwideX1> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-09_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804090136 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 06 Apr 2018 12:08:43 -0700 Joe Perches wrote: > debug_sprintf_event calls __debug_sprintf_event > with a format and arguments. > > There various types of arguments used in these > call, but __debug_sprintf_event uses va_arg > with only long as the type argument so random > errors could occur because the type and argument > are supposed to match. > > debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, ...) > { > [...] > va_start(ap, string); > curr_event->string = string; > for (idx = 0; idx < min(numargs, (int)(id->buf_size / sizeof(long)) - 1); idx++) > curr_event->args[idx] = va_arg(ap, long); > va_end(ap); > [...] > } > > from man va_arg > > va_arg() > > if type is not compatible with the type of the actual next argument > (as promoted according to the default argument promotions), > random errors will occur. > > For instance, uses like: > > arch/s390/kernel/perf_cpum_sf.c:919: debug_sprintf_event(sfdbg, 6, "pmu_enable: es=%i cs=%i ed=%i cd=%i " > arch/s390/kernel/perf_cpum_sf.c-920- "tear=%p dear=%p\n", cpuhw->lsctl.es, cpuhw->lsctl.cs, > arch/s390/kernel/perf_cpum_sf.c-921- cpuhw->lsctl.ed, cpuhw->lsctl.cd, > arch/s390/kernel/perf_cpum_sf.c-922- (void *) cpuhw->lsctl.tear, (void *) cpuhw->lsctl.dear); > > where the first 3 arguments are int but their type > as used by va_arg in __debug_sprintf_event is long > which could produce random errors. In principle you are right that the va_arg handling is not 100% correct. It works though because the C ABI for s390x requires that arguments are sign- or zero-extended to 64 bits by the caller of a function. This is true for values passed in registers and for the variable argument list. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.