<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META content=IE=5 http-equiv=X-UA-Compatible>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<STYLE id=mysingle_style type=text/css>P {
MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
TD {
MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
LI {
MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
BODY {
FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN: 10px; LINE-HEIGHT: 1.4
}
</STYLE>
<META name=GENERATOR content=ActiveSquare></HEAD>
<BODY>
<P>Thanks,</P>
<P> </P>
<P>I need a favor. Will it be possible to commit this patch. I do not have commit access.</P>
<P> </P>
<P>Regards</P>
<P>Dinesh Dwivedi</P>
<P> </P>
<P>------- <B>Original Message</B> -------</P>
<P><B>Sender</B> : Nick Lewycky<nlewycky@google.com></P>
<P><B>Date</B> : Mar 20, 2014 04:38 (GMT+05:30)</P>
<P><B>Title</B> : Re: Re: [PATCH] Fix for bitcode reader crash on invalid input [PR18704]</P>
<P> </P>
<DIV dir=ltr>Patch looks good to me. Thanks!<BR>
<DIV class=gmail_extra><BR><BR>
<DIV class=gmail_quote>On 12 March 2014 00:57, Dinesh Dwivedi <SPAN dir=ltr><<A href="mailto:dinesh.d@samsung.com" target=_blank>dinesh.d@samsung.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Gentle ping ..<BR><BR>------- Original Message -------<BR>Sender : Dinesh Dwivedi<<A href="mailto:dinesh.d@samsung.com">dinesh.d@samsung.com</A>> Chief Engineer/SRI-Bangalore-Native Framework/Samsung Electronics<BR>Date : Mar 04, 2014 20:09 (GMT+05:30)<BR>Title : Re: Re: [PATCH] Fix for bitcode reader crash on invalid input [PR18704]<BR><BR>I have gone through the code to understand in what cases, values are reserved in advance. Whenever there is some forward reference for value/ type/ metadata, BitcodeReader resize corresponding list to index of referenced value + 1. All new elements except the last one initialized to NULL. Ideally, once parsing is complete, all elements should be non-NULL.<BR><BR>This works fine if bc file has all proper references. Current bc file has one instruction referring to an invalid value.<BR><BR><INST_LOAD op0=4294966291 op1=2 op2=0 op3=0/><BR><BR>Here after adjusting for relative ID, index for op0 comes out to be 1040. For creating forward reference, we are resizing ValueList to 1041. As there aren't this many values, many of them will remains resolved, leaving null pointers in the list.<BR><BR>To safe-guard BitcodeReader, we need to add null check for all access to these list [lists which resize them-selves based on record values, as invalid value will cause list to grow to invalid range]. I have tried to add Null checks to all such places.<BR>I am assuming, new and other create type function always return non-null value. Attached fix will add null checks at required places.<BR><BR>I have one doubt about using SmallVector here. LLVM programmer manual suggest use of SmallVector for small size vector (usually less than 8). As value references in program may be much more than this, should be use Vector instead.<BR><BR>My understanding might be wrong or I have missed some cases where null check is required. Please comment.<BR><BR>Regards<BR>Dinesh Dwivedi<BR><BR>------- Original Message -------<BR>Sender : Nick Lewycky<<A href="mailto:nlewycky@google.com">nlewycky@google.com</A>><BR>Date : Mar 03, 2014 11:40 (GMT+05:30)<BR>Title : Re: [PATCH] Fix for bitcode reader crash on invalid input [PR18704]<BR><BR>On 2 March 2014 21:13, Reid Kleckner <<A href="mailto:rnk@google.com">rnk@google.com</A>> wrote:<BR><BR>Nick and I looked at this and we think there are other issues of a similar nature in the bitcode reader. There are many places where ValueList is indexed and accessed without any null check. I think Nick said the list shouldn't contain any null elements unless we're returning an error, which is what your test case does.<BR><BR><BR>I did say that, but I take it back. There is a place where it does reserve values in advance, and that's what happens in this testcase. The testcase then demonstrates an access without a null check in error handling code, but I don't see why the other non-error handling code shouldn't have it either (I kept looking, which is why I never replied).<BR><BR>On Sun, Mar 2, 2014 at 9:08 PM, Dinesh Dwivedi <<A href="mailto:dinesh.d@samsung.com">dinesh.d@samsung.com</A>> wrote:<BR><BR>ping..<BR><BR><BR><BR>Regards<BR>Dinesh Dwivedi<BR><BR>------- Original Message -------<BR><BR>Sender : Dinesh Dwivedi<<A href="mailto:dinesh.d@samsung.com">dinesh.d@samsung.com</A>> Chief Engineer/SRI-Bangalore-Native Framework/Samsung Electronics<BR>Date : Feb 27, 2014 15:51 (GMT+05:30)<BR>Title : [PATCH] Fix for bitcode reader crash on invalid input [PR18704]<BR><BR><BR><BR>Hi Reid,<BR><BR>I have attached a separate binary patch for bc file. This is same file attached in bug report. I have added llvm-bcanalyzer as comment in test case. But I do not understand much of it.<BR><BR>I have updated my fix a bit. I have update dyn_cast to dyn_cast_or_null for all location casting values from ValueList to something. If code was already returning some error code on null value, I left them as it is. For other cases, I have added null check and on null it will return "InvalidValue".<BR><BR>Regards<BR>Dinesh Dwivedi<BR><BR><BR>------- Original Message -------<BR>Sender : Reid Kleckner<<A href="mailto:rnk@google.com">rnk@google.com</A>><BR>Date : Feb 27, 2014 00:16 (GMT+05:30)<BR>Title : Re: [PATCH] Fix for bitcode reader crash on invalid input [PR18704]<BR><BR>The binary content of the .bc file isn't present in the diff. Can you attach it, and maybe paste the output of llvm-bcanalyzer into the test case as a comment? Also, the fix doesn't look correct. It looks like subsequent Arguments might leak, although that isn't really critical.<BR><BR><BR><BR>On Wed, Feb 26, 2014 at 7:37 AM, Dinesh Dwivedi <<A href="mailto:dinesh.d@samsung.com">dinesh.d@samsung.com</A>> wrote:<BR><BR>Attaching patch for PR18704. I have just gone through back-trace for the assert [dyn_cast was getting applied to NULL value], locate code causing this and added check to print error for NULL values.<BR><BR>Regards<BR>Dinesh Dwivedi<BR><BR><BR>_______________________________________________<BR>llvm-commits mailing list<BR><A href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</A><BR><BR><A href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target=_blank>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</A><p> </p><p> </p><p> </p><p> </p></BLOCKQUOTE></DIV><BR></DIV></DIV>
<P> </P>
<P> </P>
<P> </P>
<TABLE id=confidentialsignimg>
<TBODY>
<TR>
<TD NAMO_LOCK>
<P><IMG border=0 src="cid:Z5JE7EUABGFC@namo.co.kr" width=520></P></TD></TR></TBODY></TABLE></BODY></HTML><img src='http://ext.samsung.net/mailcheck/SeenTimeChecker?do=7811480e30c5489386b7f66809eff72bb4aec7db7c27725bef6b516eedac67389e881b09962f7767598ef4afaea8dfc718066911c76275ea08cece8541bc14eacf878f9a26ce15a0' border=0 width=0 height=0 style='display:none'>