Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp301483pxy; Thu, 22 Apr 2021 02:28:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk8PJPh96wmeCbWEy1g8ShXhCIi0b8lTgofzCMfkdn3XwoDcMAnMpAt3jfR4uW6KdV4yWF X-Received: by 2002:a17:902:7d89:b029:ec:c084:d4bc with SMTP id a9-20020a1709027d89b02900ecc084d4bcmr2674173plm.18.1619083683958; Thu, 22 Apr 2021 02:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619083683; cv=none; d=google.com; s=arc-20160816; b=NqtbyOQ6Lq6BYgmmwnKlMuSTmQMLdRhadk0pMMS1Kz1QfhB2qO34hIjS138L2QKW8M M65DA1JMbRcr9mzDNc3J47k5y5/U74E0Sw6g8meyda8VkvL17aJGjq4ygLESAlBxVrWy hmSQzIdiiRMPZlRo99h1O4Hp2s5FDm1NN7Xl4fTtfJOZEA+6A9bZZFr9pkvnVEt51DTK 7PGgps6V2MuZcYgpT2Qu0HcSHa+HDzweALy06ygb6IUKxwF0IY2niH/DcA9ls6EtuOB9 e3JeJ6FBEpV7ogOxwygp+/4mOUeEoM4TM68xpZG7u5Cjmjegm0fEtXXpP/KIZ0t7VVHU KUiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gWma3mBm+YHn9Z4jQTjLBmL72OVDyeV3YtSt6fSrMxA=; b=HMNrw3J5InvHgMoNRSfEvaiUbskDgZAvZwm72KvQ4FOc8f4cnFiVwU38omh31R4dnG 7TmaabZWuZt+j1B4FTzYAhi1gvoO5+VUJ3NMNtmRfajnn7LBSJgcxJ/7KkHxypCEqJtt TP1hhfM90pE8puJfMoLh6QSzeMDw+E6wsluPqAQOzgyMUYy7T0qcZlvp2NjnOCeYoYp0 XRhPmxTIOnqgm7Yo8uYpJwwKz6LDGrW87FEav58+zDMDnrm24b2YDu5ppsJqWF1UQ5yO okqqAQelWwWGdjMwocz/x2UpGo2GHyCEHwtssXSsaGAam0OF1Bp9RKnwOQ+U26UGR/pA o+jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e14si2504149pjp.79.2021.04.22.02.27.51; Thu, 22 Apr 2021 02:28:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235610AbhDVJ1S (ORCPT + 99 others); Thu, 22 Apr 2021 05:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbhDVJ1R (ORCPT ); Thu, 22 Apr 2021 05:27:17 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56CE2C06174A; Thu, 22 Apr 2021 02:26:43 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lZVbP-007H9U-Iu; Thu, 22 Apr 2021 09:26:27 +0000 Date: Thu, 22 Apr 2021 09:26:27 +0000 From: Al Viro To: Dan Carpenter Cc: Joel Stanley , Andrew Jeffery , "Chia-Wei, Wang" , Jae Hyun Yoo , John Wang , Brad Bishop , Patrick Venture , Benjamin Fair , Greg Kroah-Hartman , Robert Lippert , linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] soc: aspeed: fix a ternary sign expansion bug Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 22, 2021 at 09:24:59AM +0000, Al Viro wrote: > On Thu, Apr 22, 2021 at 12:11:44PM +0300, Dan Carpenter wrote: > > The intent here was to return negative error codes but it actually > > returns positive values. The problem is that type promotion with > > ternary operations is quite complicated. > > > > "ret" is an int. "copied" is a u32. And the snoop_file_read() function > > returns long. What happens is that "ret" is cast to u32 and becomes > > positive then it's cast to long and it's still positive. > > > > Fix this by removing the ternary so that "ret" is type promoted directly > > to long. > > Hmm... Let's grep for kfifo_to_user() - smells like a possible recurring bug... > Yup - > > samples/kfifo/bytestream-example.c:138: ret = kfifo_to_user(&test, buf, count, &copied); > samples/kfifo/inttype-example.c:131: ret = kfifo_to_user(&test, buf, count, &copied); > samples/kfifo/record-example.c:145: ret = kfifo_to_user(&test, buf, count, &copied); > > All three are exactly like that one. Nevermind, you've already caught and posted that bunch. Sorry for noise...