Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp859455ybx; Wed, 6 Nov 2019 09:27:36 -0800 (PST) X-Google-Smtp-Source: APXvYqw0qL4J5lgCg1VGplbPpXQa/ZlHWTUl882g8WBOV+4Pf+rNl35Ln9hIczIlmcDmVrgw/jtE X-Received: by 2002:a50:aad2:: with SMTP id r18mr4075376edc.44.1573061255851; Wed, 06 Nov 2019 09:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573061255; cv=none; d=google.com; s=arc-20160816; b=TSpgO3t3YqIDQB69AFWbKx6kWMBj5fnt2XAkkb11I2hxKADE5jZX1ntLk/IEQotpFK MZWwDVoDfHYJwIu0OgVb2k3lynkt1z8jJJzcFCu+MvvAOxJtz58T9FrS59/qrb1hr70d 3ZpMzSJOHF7fMHK6I+dkUeHqUSSiYjpnrv49CGrIthuwZ7S3zDzS9tcergWRscjUXNOH HXrp7myNUZeixz70H4kYLcNQm2KMoOJ/qXEk/3Id6SdewJF6NcMm6omTbWVKsZpQFnTY FIfndKqcPBYJGE9afThwAr0Lm6wmosVcsmccZ3mGX4F99hL0YPIZUteciaSL+p1qqyso WI8A== 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 :dkim-signature; bh=12yzcHf1qZ16w0lmbe/z8YOyijtRMnml2sd6alF7R5E=; b=i9v+a2JyW7yapskVmxG6vmP553EjlOZUbn7rw0rat4M1GTsWmYy3DDGsD9YbgYKsGg wx9S5sczVAjifnzCMOJh55Ptm9+4/8TASz5//lnp6j9MbCpFrsQ27cPLUvpf2IHB/gwJ fwa+BwLzGgzyCh1tI4ksDWS/FjREdxiHJdC5LAC3Y/5sU7BcUljKaIrOpriPjdlk3oBK esMN3G+IdF95dvcBL+vTU7aLHwuyrUpi0Opuvb/QqY+cRoXqOIU8W956EbgNzxMPq/Om puoqkrUJ8/t+gCTSaYnf1yFtM7XGfL7DSGEL6o3hsUmuwpTBSCZqipqydlmTffTBlWrP rq2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Kjeez8xg; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si5939936ejx.220.2019.11.06.09.27.12; Wed, 06 Nov 2019 09:27:35 -0800 (PST) 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=@chromium.org header.s=google header.b=Kjeez8xg; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732415AbfKFRYV (ORCPT + 99 others); Wed, 6 Nov 2019 12:24:21 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42761 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729511AbfKFRYV (ORCPT ); Wed, 6 Nov 2019 12:24:21 -0500 Received: by mail-pg1-f194.google.com with SMTP id q17so2138642pgt.9 for ; Wed, 06 Nov 2019 09:24:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=12yzcHf1qZ16w0lmbe/z8YOyijtRMnml2sd6alF7R5E=; b=Kjeez8xg9w1G0Sz1XNlqaJiqB+5U+nf27WRtq9ESx/wrXx9XWIlBYGf3N+a1s30Lqf PO9E2S/zhEHf1DsS35YdbMoLwH66sXNTBbln/nDtH4nNulV3cDyG24+euda4cLAG+myE aM2/vQI5JXoWUGhG8qnNOmPeigi3l2obzYdKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=12yzcHf1qZ16w0lmbe/z8YOyijtRMnml2sd6alF7R5E=; b=S6u5gb/CpY14+rKzSv708SzwdLlQ7kLFxOS3m4hgrR1cRzFYs+dtsbMuVQhXaslEGM vt19VV36gIOEdiIykTvT65AmeeflKozAEzo+OWz32nejMptfJwr1BtHlEQXmr9XbeAlj zEMwqMWpQa3KIJNwbS6cAZCMf9Q9KRmAgGRFiR8SuIH5hCu4PD0NyUUpjHNUDjKoDPZw JH5aMmv/nhTujWI7fHso6sWayKO7fe7ZNYIBOP0TFsvywyvz2jrVS1JkVAVVrVJEypIa QE+qiKO8VHW1d7oXdf0hdf0Rwn7HEhp22r7XiutVBeWU/IzdT5E/1k8n8Is9xKbB80Al w7xA== X-Gm-Message-State: APjAAAW96e0VBCIC26NRIJgDMHxmbqFHPIn70YQmRtjJZyl0WmmIOmvs afXbk0vv0Pd6UHyyipK9cfjUcw== X-Received: by 2002:a63:9a09:: with SMTP id o9mr4197481pge.276.1573061060339; Wed, 06 Nov 2019 09:24:20 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j7sm3606496pjz.12.2019.11.06.09.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 09:24:19 -0800 (PST) Date: Wed, 6 Nov 2019 09:24:18 -0800 From: Kees Cook To: Daniel Vetter Cc: DRI Development , LKML , syzbot+fb77e97ebf0612ee6914@syzkaller.appspotmail.com, Alexander Viro , Andrew Morton , Stephen Rothwell , Daniel Vetter Subject: Re: [PATCH] drm: Limit to INT_MAX in create_blob ioctl Message-ID: <201911060920.71D7E76E@keescook> References: <20191106164755.31478-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191106164755.31478-1-daniel.vetter@ffwll.ch> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 06, 2019 at 05:47:55PM +0100, Daniel Vetter wrote: > The hardened usercpy code is too paranoid ever since: > > commit 6a30afa8c1fbde5f10f9c584c2992aa3c7f7a8fe > Author: Kees Cook > Date: Wed Nov 6 16:07:01 2019 +1100 > > uaccess: disallow > INT_MAX copy sizes > > Code itself should have been fine as-is. I had to go read the syzbot report to understand what was actually being fixed here. Can you be a bit more verbose in this commit log? It sounds like huge usercopy sizes were allowed by drm (though I guess they would fail gracefully in some other way?) but after 6a30afa8c1fb, the copy would yell about sizes where INT_MAX < size < ULONG_MAX - sizeof(...) ? What was the prior failure mode that made the existing ULONG_MAX check safe? Your patch looks fine, though: Reviewed-by: Kees Cook > Reported-by: syzbot+fb77e97ebf0612ee6914@syzkaller.appspotmail.com > Fixes: 6a30afa8c1fb ("uaccess: disallow > INT_MAX copy sizes") > Cc: Kees Cook > Cc: Alexander Viro > Cc: Andrew Morton > Cc: Stephen Rothwell > Signed-off-by: Daniel Vetter > -- > Kees/Andrew, > > Since this is -mm can I have a stable sha1 or something for > referencing? Or do you want to include this in the -mm patch bomb for > the merge window? Traditionally these things live in akpm's tree when they are fixes for patches in there. I have no idea how the Fixes tags work in that case, though... -Kees > -Daniel > --- > drivers/gpu/drm/drm_property.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c > index 892ce636ef72..6ee04803c362 100644 > --- a/drivers/gpu/drm/drm_property.c > +++ b/drivers/gpu/drm/drm_property.c > @@ -561,7 +561,7 @@ drm_property_create_blob(struct drm_device *dev, size_t length, > struct drm_property_blob *blob; > int ret; > > - if (!length || length > ULONG_MAX - sizeof(struct drm_property_blob)) > + if (!length || length > INT_MAX - sizeof(struct drm_property_blob)) > return ERR_PTR(-EINVAL); > > blob = kvzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL); > -- > 2.24.0.rc2 > -- Kees Cook