Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp300867pxy; Thu, 22 Apr 2021 02:27:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxae0hnAeCuM5g+jd8oas7YRrHsEBCeXX+hv7RJ2eZbJ8gp9R0LoghoevZXD12oaISa+A9F X-Received: by 2002:a17:906:6ce:: with SMTP id v14mr2337060ejb.296.1619083620500; Thu, 22 Apr 2021 02:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619083620; cv=none; d=google.com; s=arc-20160816; b=AMhVJQBvPUT82te+cHuOis8Cdf8U7Rsfq1z/Guo3rAwbHsZcU/iaUfj3ZMA52DoQsE KazDZJ9vI2XU7vaFhK6yTGfnfCaiC/rsc23FpREMcH9UgjRdofhmUPOnwQqzBNO7aOv2 h+ZXhx4oI0pfQ42lggMOij0k3Z/d4H2EQuJASzXIAUb9+dfWzZjPlSX1+IKqXc1wr6dr kZU+HjwqlgxxMJTFew2rmKkysZljQJ1drK0V8IXjZphLfl1zFhoon8G4NKLoD5Lko/MZ nd75l5CaKTdfw9vzaveu58vdtb8kkp1+bWh0DYZCByBgMohklmSxJJxSvVVByehYs9Tq ikCQ== 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=88o/2qQP7DL2EvGjcMhL/rXGRuMNmfXFuWL8lPjx/Lo=; b=MyUkzXNgKlx9ZpabfXCxFjt7ApSLy/g6dxZ1/rjKPqQ+F99PDSEprfC4edHFZyFlrl H14OdBAaTK2hGvfl+UO/KxErD5647kPWrGfpVI3Fw2QqPN1ROuiNzC2lbIVB8pD+9SUY bVGOK2yEIB1PRen/EAeb81YLIA9WO2SBDGOxfNFKBX1nV6YIotca7x/prnK92icL7Lw6 2cmA4K5QitvSVtUKvhzXc4gQylZVjccfU8Q0zhbbRkcncyBPoQcnhoh9GoIhLdGm4oBo av4FJ2wyvhf2QOvlW+ZjIyJiVnBj+Fcs+HOmIoE6YD2oS/HQIaThnwjVLwu5SgpHGwzE iPqA== 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 ci2si1798955ejb.750.2021.04.22.02.26.35; Thu, 22 Apr 2021 02:27:00 -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 S235581AbhDVJZ6 (ORCPT + 99 others); Thu, 22 Apr 2021 05:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235232AbhDVJZ6 (ORCPT ); Thu, 22 Apr 2021 05:25:58 -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 DEFD2C06174A; Thu, 22 Apr 2021 02:25:23 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lZVZz-007H7H-RC; Thu, 22 Apr 2021 09:24:59 +0000 Date: Thu, 22 Apr 2021 09:24:59 +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 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.