text
stringlengths
3
1.74M
label
class label
2 classes
source
stringclasses
3 values
Optimized for iPhone 6 info text in App Store. <p>I've updated my "old" Objective-C app to use the new storyboard with size classes, set the deployment target to iOS 8 and uploaded the new binary to the App Store. Still, the App Store doesn't show the text "this app is optimized for iPhone 6 and 6 plus". The text only mentions iPhone 5S and everything below. </p> <p>What am I supposed to do in order to get the app iPhone 6 approved?</p>
0non-cybersec
Stackexchange
Number of cyclic difference sets. <p>A subset $D=\{a_1,\ldots,a_k\}$ of $\mathbb{Z}/v\mathbb{Z}$ is said to be a $(v,k,\lambda)$-cycic difference set if for each nonzero $b\in\mathbb{Z}/v\mathbb{Z}$, there are exactly $\lambda$ ordered pairs $(a_s,a_t)\in D^2$ such that $a_s-a_t=b$. For a $(v,k,\lambda)$-difference set $D$, $k-\lambda$ is called the order of $D$.</p> <p>Let $N_v$ be the number of different (even they are equivalent, different subsets of $\mathbb{Z}/v\mathbb{Z}$ viewd as different) cyclic difference sets in $\mathbb{Z}/v\mathbb{Z}$, and $N_{v,n}$ be the number of different $(v,k,\lambda)$-cyclic difference sets of order $n$. Are there any nontrivial upper bounds known for $N_v$ or $N_{v,n}$?</p>
0non-cybersec
Stackexchange
wifi iw setting bit rate. <p>iw list (intel ax200) My wifi adaptor spec for 802.11ax is as followings,</p> <pre><code> HE Iftypes: Station HE MAC Capabilities (0x780312a0abc0): +HTC HE Supported TWT Requester Trigger Frame MAC Padding Duration: 2 Multi-TID Aggregation Support: 7 32-bit BA Bitmap Ack-Enabled Aggregation OM Control Maximum A-MPDU Length Exponent: 2 A-MSDU in A-MPDU Multi-TID Aggregation TX: 7 UL 2x996-Tone RU HE PHY Capabilities: (0x0e3f0200fd09800ecff200): HE40/2.4GHz HE40/HE80/5GHz HE160/5GHz Punctured Preamble RX: 15 Device Class: 1 LDPC Coding in Payload NDP with 4x HE-LTF and 3.2us GI SU Beamformee Beamformee STS &lt;= 80Mhz: 7 Beamformee STS &gt; 80Mhz: 7 Sounding Dimensions &lt;= 80Mhz: 1 Sounding Dimensions &gt; 80Mhz: 1 PPE Threshold Present Power Boost Factor ar HE SU PPDU &amp; HE PPDU 4x HE-LTF 0.8us GI Max NC: 1 HE ER SU PPDU 4x HE-LTF 0.8us GI 20MHz in 40MHz HE PPDU 2.4GHz 20MHz in 160/80+80MHz HE PPDU 80MHz in 160/80+80MHz HE PPDU DCM Max BW: 3 Non-Triggered CQI Feedback RX Full BW SU Using HE MU PPDU with Compression SIGB RX Full BW SU Using HE MU PPDU with Non-Compression SIGB HE RX MCS and NSS set &lt;= 80 MHz 1 streams: MCS 0-11 2 streams: MCS 0-11 3 streams: not supported 4 streams: not supported 5 streams: not supported 6 streams: not supported 7 streams: not supported 8 streams: not supported HE TX MCS and NSS set &lt;= 80 MHz 1 streams: MCS 0-11 2 streams: MCS 0-11 3 streams: not supported 4 streams: not supported 5 streams: not supported 6 streams: not supported 7 streams: not supported 8 streams: not supported HE RX MCS and NSS set 160 MHz 1 streams: MCS 0-11 2 streams: MCS 0-11 3 streams: not supported 4 streams: not supported 5 streams: not supported 6 streams: not supported 7 streams: not supported 8 streams: not supported HE TX MCS and NSS set 160 MHz 1 streams: MCS 0-11 2 streams: MCS 0-11 3 streams: not supported 4 streams: not supported 5 streams: not supported 6 streams: not supported 7 streams: not supported 8 streams: not supported PPE Threshold 0x61 0x1c 0xc7 0x7 </code></pre> <p>how to set bitrates as followings . but I don't know how to set for HE and MCS..?</p> <p>dev set bitrates [legacy-&lt;2.4|5> <em>] [ht-mcs-&lt;2.4|5> </em>] [vht-mcs-&lt;2.4|5> *] [sgi-2.4|lgi-2.4] [sgi-5|lgi-5] Sets up the specified rate masks. Not passing any arguments would clear the existing mask (if any).</p> <p>Would you help me how to set...</p> <p>Nick.</p>
0non-cybersec
Stackexchange
Make boost::progress_display work when more information is being printed to the screen. <p>I have a console program which can take some time for its calculations. I am using <code>boost::progress_display</code> to provide some feedback to the user.</p> <p>My problem is that I also want to print other updates to the standard output if certain things happen, and that breaks progress bar:</p> <pre><code>0% 10 20 30 40 50 60 70 80 90 100% |----|----|----|----|----|----|----|----|----|----| **Found temporary candidate with score: 40 Found temporary candidate with score: 46 *Found temporary candidate with score: 52 ********Found temporary candidate with score: 55 **Found temporary candidate with score: 67 ************************************** </code></pre> <p>Is there an easy way to have both a progress bar (ideally as non-intrusive in the code as <code>boost::progress_display</code>) and updates to the screen?</p> <p><strong>EDIT:</strong> after a suggestion in comments saying that I have not provided an example of what I am looking for, I want code which looks similar to this:</p> <pre><code>boost::progress_display progress(10); for (size_t i = 0; i&lt; 10; ++i) { std::cout &lt;&lt; "Number is: " &lt;&lt; i &lt;&lt; "\n"; ++progress; } </code></pre> <p>but that doesn't result in this output:</p> <pre><code>0% 10 20 30 40 50 60 70 80 90 100% |----|----|----|----|----|----|----|----|----|----| Number is: 0 *****Number is: 1 *****Number is: 2 *****Number is: 3 *****Number is: 4 *****Number is: 5 *****Number is: 6 *****Number is: 7 *****Number is: 8 *****Number is: 9 ****** </code></pre> <p>Instead, I'd like the lines sayin <code>Number is: z</code> to show up after the progress bar or before it:</p> <pre><code>Number is: 0 Number is: 1 Number is: 2 Number is: 3 Number is: 4 Number is: 5 Number is: 6 Number is: 7 Number is: 8 Number is: 9 0% 10 20 30 40 50 60 70 80 90 100% |----|----|----|----|----|----|----|----|----|----| *************************************************** </code></pre>
0non-cybersec
Stackexchange
Alistair Davidson: Wikileaks, Karl Marx and You - [Strong crypto permits unbreakable encryption, unforgeable signatures, untraceable electronic messages, and unlinkable pseudonymous identities. This ensures that some transactions and communications can be entered into only voluntarily.].
1cybersec
Reddit
Format vertically maintaining first column. <p>It's been a long time since I've used grep or sed but I think this can be done. How do I take a csv and format it vertically while maintaining/replicating the first columns.</p> <pre><code>Ex. Input: A, 1, 2, 3 B, 1, 2, 3 C, 1, 2, 3 Output: A, 1 A, 2 A, 3 B, 1 B, 2 B, 3 C, 1 C, 2 C, 3 </code></pre>
0non-cybersec
Stackexchange
IntersectionObserver when element is centered. <p>I want to fix an elements position when it's perfectly centered. Currently it's being fixed when it's fully visible and hence snaps to the center. - Can I somehow observe when the element is centered?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const box = document.querySelector(".box"); const obs = new IntersectionObserver(entries =&gt; { if (entries[0].isIntersecting) { box.style.position = "fixed"; box.style.top = "50%"; box.style.transform = "translateY(-50%)" } }, {threshold: 1}) obs.observe(box);</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.v-detail__video { width: 100vw; height: 300vh; display: flex; padding-top: 70vh; justify-content: center; } .box { background-color: black; width: 50vw; height: 200px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="v-detail__video"&gt; &lt;div class="box"&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0non-cybersec
Stackexchange
Boeing 747 by SSG for PC.
0non-cybersec
Reddit
🚨CyberSecurity Cheat Sheet Alert 🚨 This glossary covers of all the technical jargon that industry insiders love (and hate) to use. Credits: NCSC.
1cybersec
Reddit
Toasted sandwich: melted mozzarella, tomato slices, basil leafs, and cucumber. I suck at making this. How do I do it right?. I want a warm melted cheese, basil, and tomato sandwich with cool cucumber slices. Every time I try I end up burning the bread, under-cooking the cheese, or over-cooking the tomato or cucumber. Warm tomato is nice, but not warm cucumber. What procedure or cooking tips do I need to make this thing right? I'm also planning on dipping it in olive hummus. My shitty version still tasted kinda good in the olive hummus. Dip recommendations would be cool too.
0non-cybersec
Reddit
android.graphics.drawable.RippleDrawable error. <p>First my target API was 22 (Android L). Everything was worked fine until I lowered my target API to 19 for supporting Android 4.4 (Kitkat). Now I am getting this weird error. The App don´t crashes but only some normal buttons are disappearing. I am setting my layout via a XML file and via code. <strong>Error</strong></p> <blockquote> <p>Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering</p> </blockquote> <p>Does anyone know what causes this error? How can I solve it?</p> <p>My dependencies:</p> <pre><code>compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:design:24.2.1' compile 'com.android.support:support-v4:24.2.1' compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' </code></pre> <p><strong>Update:</strong> I moved every Vector File to the new drwabale-v21 folder. Now I am getting this error.:</p> <blockquote> <p>Android.view.InflateException: Binary XML file line #11: Error inflating class at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at at </p> </blockquote> <p>....</p> <p>Unfortunately Android 4.4 doesn´t have support for vector drawables. What can I do you support vector drawables for => Android 4.4?</p>
0non-cybersec
Stackexchange
apache access.log requests from localhost to localhost. <p>My server is spamming via postfix from www-data user.</p> <p>In apache access.log:</p> <pre><code>90.156.208.121 - - [20/Jan/2014:17:24:01 +0300] "GET /treningi.php HTTP/1.0" 200 21025 "-" "Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" 90.156.208.121 - - [20/Jan/2014:17:23:56 +0300] "POST /public/files/__DxS_NEWDIR__a3X/nd24f62.php HTTP/1.0" 200 - "-" "-" 90.156.208.121 - - [20/Jan/2014:17:24:31 +0300] "GET / HTTP/1.0" 200 9499 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot-Mobile/2.1; +http:// www.google.com/bot.html)" 90.156.208.121 - - [20/Jan/2014:17:25:08 +0300] "POST /public/files/__DxS_NEWDIR__a3X/nd24f62.php HTTP/1.0" 200 - "-" "-" 90.156.208.121 - - [20/Jan/2014:17:25:36 +0300] "GET / HTTP/1.0" 200 9499 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 YaBrowser/13.10.1500.9323 Safari/537.36" 90.156.208.121 - - [20/Jan/2014:17:25:46 +0300] "GET /novostibankov.php HTTP/1.0" 200 28410 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 YaBrowser/13.10.1500.9323 Safari/537.36" </code></pre> <p>Server IP is 90.156.208.121. "POST /public/files/__DxS_NEWDIR__a3X/nd24f62.php" is request by spambot, but it shown from server IP.</p> <p>But 20/Jan/2014:17:25:46 +0300 is my request from YaBrowser, not from server!</p> <p>Why is it shown from the server IP, not mine?</p> <p>Some request shown not from the server:</p> <p>10.16.24.221 - - [20/Jan/2014:17:05:28 +0300] "GET /main.php HTTP/1.0" 200 9499 </p> <blockquote> <p>"http:// www.DOMAIN.ru/generatepasswordpage.php" "Opera/9.80 (Windows NT 6.1; Win64; x64) Presto/2.12.388 Version/12.16" 10.16.24.221 - - [20/Jan/2014:17:05:31 +0300] "GET /r_vse.php HTTP/1.0" 200 14623 "http:// www.DOMAIN.ru/main.php" "Opera/9.80 (Windows NT 6.1; Win64; x64) Presto/2.12.388 Version/12.16" 10.16.24.221 - - [20/Jan/2014:17:05:42 +0300] "GET /myrich.php HTTP/1.0" 200 11449 "http:// www.DOMAIN.ru/r_vse.php" "Opera/9.80 (Windows NT 6.1; Win64; x64) Presto/2.12.388 Version/12.16"</p> </blockquote>
1cybersec
Stackexchange
How can I prevent a package from being automatically removed in order to install another one?. <p>This is the example: I want to install elementary-desktop (from PPA), but it requires to remove esound in order to install pulseaudio (which I removed because it was causing problems with many apps). I already pinned both esound and pulseaudio and held them through <code>sudo aptitude hold esound</code> and <code>sudo aptitude hold pulseaudio</code> but, in Synaptic, the prompt still states that esound must be removed. Thanks in advance for your help!</p>
0non-cybersec
Stackexchange
Is Samsung MZ-75E250B compatible with dell inspiron 5520. <p>I have a 3 year old Dell Inspiron 5520 laptop. I was planning on getting a samsung SSD,</p> <ul> <li><a href="http://rads.stackoverflow.com/amzn/click/B00OAJ412U" rel="nofollow noreferrer">Samsung 850 EVO 250GB 2.5-Inch SATA III Internal SSD (MZ-75E250B/AM)</a> </li> </ul> <p>I tried to find if this SSD is compatible but all I found is <a href="http://www.userbenchmark.com/System/Dell-Inspiron-5520/2918" rel="nofollow noreferrer">info on this page</a>.</p> <p>Can someone here confirm that it is indeed compatible. If not I was going to get the Crucial equivalent model:</p> <ul> <li><a href="http://www.crucial.com/usa/en/ct250mx200ssd1" rel="nofollow noreferrer">Crucial MX200 250GB SATA 2.5 Inch Internal Solid State Drive - CT250MX200SSD1</a></li> </ul> <p>The Crucial web site indicates that this is indeed compatible with my laptop model.</p>
0non-cybersec
Stackexchange
Pig gets saved from slaughterhouse.
0non-cybersec
Reddit
[No spoilers] So I got to meet Joffrey today.
0non-cybersec
Reddit
I was given the phone number of a "secret admirer" at dinner tonight. When should/should I call it?. Just for clarity's sake, I'm a guy. Went out to dinner with my mother tonight. Had some time on my hands before she picked me up so I decided to dress up a little bit. Turned out to be a good decision! When I was leaving the restaurant our waitress stopped me and said, "Someone wanted me to give this to you." She handed me a folded slip of receipt paper with a phone number and a name on it. Now I assume this is not a CIA operative, or some other type of secret agent trying (albeit mistakenly) to arrange a dead drop, and that it is instead an interested young woman (or man I guess? based on the name/handwriting I'm guessing woman.) Ordinarily I would wait a few days to call if I'd had to ask for the number. I've never gotten a number without asking aside from a select few occasions and I had the chance to knowingly meet them beforehand. As I'm typing this, I do recall making eye contact a few times with a pretty young woman about my age. If it was her, I'm definitely interested but originally I was thinking it had to be a staff member from the establishment. So when should I call? Also, in the US at least, this is pretty out of the norm. Should I just steer clear entirely? TL;DR Someone in a restaurant (presumably a woman) gave me a phone number through a waitress. I do not know the person, and never saw them. Should I call it, and if so, when? EDIT: I sent a text to the number. It is pretty late though. Haven't heard back, will check my phone in the morning. If you don't hear from me, assume I got a booty call and was murdered or that I'm being held at a CIA black site. Otherwise, OP will surely deliver. EDIT 2: We got coffee this morning. She was pretty cute and seems cool. She didn't seem batshit insane or anything. Time will tell. Going on a date later this week.
0non-cybersec
Reddit
How to use order by with multiple isdescendantnode. <p>I am attempting to grab multiple nodes of the same type from different areas in the jcr and order them by a date.</p> <pre><code>SELECT * FROM [social:asiResource] WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND [isFeatured_b] = true AND NOT CONTAINS([cq:tags],'administrative:blacklist') AND (ISDESCENDANTNODE([/path/to/content]) OR ISDESCENDANTNODE([/path/to/content])) ORDER BY [cq:lastModified] DESC </code></pre> <p>This will return me the correct set of results but not in the correct order. In fact altering <code>DESC</code> to <code>ASC</code> does not alter the results in any way.</p> <p>My solution currently is to do multiple queries and perform a union which allows <code>ORDER BY</code> to function like it should.</p> <pre><code>SELECT * FROM [social:asiResource] WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND [isFeatured_b] = true AND NOT CONTAINS([cq:tags],'administrative:blacklist') AND ISDESCENDANTNODE([/path/to/content]) UNION SELECT * FROM [social:asiResource] WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND [isFeatured_b] = true AND NOT CONTAINS([cq:tags],'administrative:blacklist') AND ISDESCENDANTNODE([/path/to/content]) ORDER BY [cq:lastModified] DESC </code></pre> <p>Unfortunately I have around 30 nodes that I am searching through making the latter query unusable. Is there a way to use <code>ORDER BY</code> without using a <code>UNION</code>?</p>
0non-cybersec
Stackexchange
I have the runnies.
0non-cybersec
Reddit
MotorWeek's review of perhaps the greatest car of the last two decades, the Chrysler PT Cruiser..
0non-cybersec
Reddit
Im an atheist she is a rather religious individual, anybody have any experience. i have been dating this girl for almost 8 months. I knew she was religous but did not know just how religious, she didnt wear it on her sleeve. Latley its becoming more and more appearant. Today she told me she didnt believe in evolution. Im not willing to change and neither is she. Anybody have any experience with this
0non-cybersec
Reddit
[NO SPOILERS] I see your glasses and raise you these hand drawn whiskey glasses my wife got me last Christmas.
0non-cybersec
Reddit
Expression evaluation tree in Haskell. <p>In an exam today I was asked to create an expression evaluation tree in Haskell. Usually the answer is as simple as:</p> <pre><code>data Expr = Value Integer | Add Expr Expr | Sub Expr Expr | Mul Expr Expr </code></pre> <p>And to evaluate it, you just use a function such as:</p> <pre><code>eval :: Expr -&gt; Integer eval (Value x) = x eval (Add l r) = eval l + eval r eval (Sub l r) = eval l - eval r eval (Mul l r) = eval l * eval r </code></pre> <p>However today, we were given a data type:</p> <pre><code>data Op = Add | Sub | Mul </code></pre> <p>So I assumed to create the expression tree I could just do:</p> <pre><code>data Expr = Value Integer | Op Expr Expr </code></pre> <p>And use the same <code>eval</code> function. However, I have since written that function and loaded it into GHCI, but it does not seem to work. Could anyone explain why this doesn't work?</p>
0non-cybersec
Stackexchange
Holder: US has no authority to kill Americans with drones on US soil.
0non-cybersec
Reddit
`yum history undo $everything` to bring CentOS back to original state?. <p>I made a few yum transactions (8 to be exact), and now my CentOS 7 is messed up. Is there a way to undo everything in one command?</p>
0non-cybersec
Stackexchange
How to find the integration of $\int \limits _{-\infty}^x e ^ \frac{-t^2}{2}{d}t$?. <p>What is the value of the $\displaystyle \int \limits_{-\infty}^xe ^ {\large{-t^2/2}}dt$ ? </p> <p>thank you for your time.</p>
0non-cybersec
Stackexchange
A small farm called “Miami Fruit” grows avacados up to 3-feet long in South Florida.
0non-cybersec
Reddit
Prove that $\lim_{x\to 2}x^2=4$ using $\epsilon-\delta$ definition.. <blockquote> <p>Prove that $\lim_{x\to 2}x^2=4$ using $\epsilon-\delta$ definition.</p> </blockquote> <p>By the mean of $\epsilon-\delta$ definition, $|x-2|\le \delta,|x+2|\le \delta+4$</p> <p>then $|x-2||x+2|\le \delta(\delta+4),|x^2-4|\le \delta^2+4\delta$.</p> <p>Assign $\epsilon=\delta^2+4\delta,|x^2-4|\le\epsilon$.</p> <p>Q.E.D.</p> <p>Is this method correct? If yes, why I always see people do this by putting $\delta = \min(1,\epsilon/5)$...?</p> <p>Thanks.</p>
0non-cybersec
Stackexchange
What did Grandfather say before he passed Away?. "Hey, I know a great little restaurant called "Away." It's up here on the left."
0non-cybersec
Reddit
Nonconventional ergodic averages for commuting transformations. <p>Let $S$ and $T$ be commuting measure-preserving transformations of a standard probability space $(X,\mu)$, so $S$ and $T$ define an action of $\mathbb{Z}^2$ on $(X,\mu)$. I am wondering about sequences of finite subsets $(F_n)_{n=1}^\infty$ of $\mathbb{Z}^2$ which are $L^p$-good for the pointwise ergodic theorem in the sense that for every $f \in L^p(X,\mu)$ the limit</p> <p>$$ \lim_{n \to \infty} \frac{1}{|F_n|} \sum_{(m_1,m_2) \in F_n} f(S^{m_1} T^{m_2} x) $$</p> <p>exists for almost every $x \in X$. If $(F_n)_{n=1}^\infty$ forms a tempered Folner sequence, it is well known that $(F_n)_{n=1}^\infty$ is $L^1$-good. I would like to hear what is known about analogs of Bourgain's subsequential ergodic theorems - i.e. the case where the $F_n$ are quite sparse. Specific examples of interest are $$F_n = \{(m_1^2,m_2^2): 0 \leq m_1,m_2 \leq n \},$$ more generally $$F_n = \{(p(m_1),q(m_2)): 0 \leq m_1,m_2 \leq n \}$$ for two polynomials $p$ and $q$ with integer coefficients, or $$ F_n = \{ (p_1,p_2): p_1 \mbox{ and } p_2 \mbox{ are among the first } n \mbox{ primes } \}.$$</p> <p>There doesn't seem to be anything about this in Nevo's extensive survey 'Pointwise Ergodic Theorems for Actions of Groups' from the Handbook of Dynamical Systems.</p>
0non-cybersec
Stackexchange
How to break your back in a pool.
0non-cybersec
Reddit
From bottom to top, brick to Asphalt 108 years of Indianapolis Motor Speedway Track surfaces..
0non-cybersec
Reddit
Is the DEVOPS concept ruining IT?. I have been seeing lately a lot of job postings that are requiring more of a diverse background. Example: system junior role requiring, linux,cisco,windows,phython,c#, and storage. I mean really where are you going to find that wrapped up in one person? Do you really expect that person to work for less than $85K per year. There is a reason why DELL/EMC charges the government $300K to have an employee there and pay him $150K. Are we becoming jack of all trades master of none?
0non-cybersec
Reddit
For continuous $f:[a,b] \to \mathbb{R}$, prove $\exists \ c\in[a,b]$ such that $f(c)=\frac{1}{b-a}\int\limits_{a}^{b}f(x)dx$.. <p>Consider a continuous function $f:[a,b]\to \mathbb{R}$. Prove that there exists a $c\in[a,b]$ such that: $$f(c)=\frac{1}{b-a}\int\limits_{a}^{b}f(x)dx$$ Does this also hold if $f:[a,b]\to \mathbb{R}$ is bounded but continuous only on $(a,b)$?</p> <p>The first part seems intuitive to me because the $\frac{1}{b-a}\int\limits_{a}^{b}f(x)dx$ (let's call this value $\alpha$) loosely represents the area per unit length, and since $f(x)$ is continuous on $[a,b]$ it must either always be equal to $\alpha$, or at one point lower and at one point higher. Therefore by the intermediate value theorem there exists a $c\in[a,b]$ such that $f(c)=\alpha$. </p> <p>For the second part I think the conclusion still holds because integral are not concerned with what happens at single discontinuous points as long as the function is bounded.</p> <p>So those are my intuitive ideas but I m struggling to make it rigorous (if my ideas are even correct). If anyone could help me with some insight on how to do this I would be ver thankful!</p>
0non-cybersec
Stackexchange
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
Eating a Wookie.
0non-cybersec
Reddit
Prove inequality $\arccos \left( \frac{\sin 1-\sin x}{1-x} \right) \leq \sqrt{\frac{1+x+x^2}{3}}$. <p>I was trying to figure out if the following function can serve as a mean (see mean value theorem):</p> <p><span class="math-container">$$\arccos \left( \frac{\sin y-\sin x}{y-x} \right)$$</span></p> <p>And turns out that for <span class="math-container">$x,y \leq \pi$</span> it does serve as a mean admirably.</p> <p>But then I've noticed that for <span class="math-container">$0&lt;x&lt;1$</span> the following two functions are very close (see the picture):</p> <p><a href="https://i.stack.imgur.com/vJCqV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vJCqV.png" alt="enter image description here" /></a></p> <blockquote> <p>Now how would you prove:</p> <p><span class="math-container">$$\arccos \left( \frac{\sin 1-\sin x}{1-x} \right) \leq \sqrt{\frac{1+x+x^2}{3}}$$</span></p> </blockquote> <p>It's probably easier to consider another equivalent inequality:</p> <p><span class="math-container">$$\frac{\sin 1-\sin x}{1-x} \geq \cos \sqrt{\frac{1+x+x^2}{3}}$$</span></p> <p>Or even:</p> <p><span class="math-container">$$ \text{sinc} \left(\frac{1-x}{2} \right) \cos \left(\frac{1+x}{2} \right) \geq \cos \sqrt{\frac{1+x+x^2}{3}}$$</span></p> <p>We could use Taylor series, but that's too cumbersome in my opinion.</p> <p>Another way would be Mean value theorem itself, but I encounter the same problem.</p> <blockquote> <p>Is there a simple way to prove this inequality?</p> </blockquote> <p>My calculus is not as sharp as it used to be (just kidding, it was never sharp).</p> <hr /> <p><strong>Edit</strong></p> <p>Just to confirm (numerically) that the inequality holds, here is the plot of the difference between the two functions:</p> <p><a href="https://i.stack.imgur.com/m4Y6y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m4Y6y.png" alt="enter image description here" /></a></p>
0non-cybersec
Stackexchange
Thiruda Thirud Movie Online.
0non-cybersec
Reddit
We can teach children to smell bullshit: a new experiment published in the medical journal The Lancet, demonstrates it’s possible to train kids to spot “alternative facts" with regards to specious health claims..
0non-cybersec
Reddit
What is Jared Goff ceiling?. And how does he compare to other QB in their first 3 years? &#x200B; Goff hasn't been outplay by any QB so far this year.
0non-cybersec
Reddit
How to increase the size of /dev?. <p>I have run into a rather unusual situation:</p> <pre><code>... cp: failed to extend ‘/dev/mapper/loop0p1’: No space left on device nathan@nathan-desktop:~$ df Filesystem 1K-blocks Used Available Use% Mounted on udev 4017004 4017004 0 100% /dev </code></pre> <p>I have run out of "disk" space on <code>/dev</code>. (For the curious, I am using <code>kpartx</code> to copy some partition images to a disk image.)</p> <p>There is no entry for <code>/dev</code> in <code>/etc/fstab</code> - how do I change the amount of space allocated for <code>/dev</code>? Is there a configuration file I can modify?</p>
0non-cybersec
Stackexchange
Lettuce Eat! ❤️ growing my very first garden this year! Q: to harvest this should I take a few lettuce leafs at a time or would I take the whole bunch!?.
0non-cybersec
Reddit
ar X iv :1 90 9. 09 56 7v 2 [ cs .C R ] 2 5 M ar 2 02 0 Output-sensitive Information flow analysis⋆ Cristian Ene[0000−0001−6322−0383], Laurent Mounier[0000−0001−9925−098X], and Marie-Laure Potet[0000−0002−7070−6290] Univ. Grenoble Alpes, CNRS, Grenoble INP, VERIMAG, 38000 Grenoble, France [email protected] Abstract. Constant-time programming is a countermeasure to prevent cache based attacks where programs should not perform memory accesses that depend on secrets. In some cases this policy can be safely relaxed if one can prove that the program does not leak more information than the public outputs of the computation. We propose a novel approach for verifying constant-time programming based on a new information flow property, called output-sensitive non- interference. Noninterference states that a public observer cannot learn anything about the private data. Since real systems need to intentionally declassify some information, this property is too strong in practice. In order to take into account public outputs we proceed as follows: instead of using complex explicit declassification policies, we partition variables in three sets: input, output and leakage variables. Then, we propose a typing system to statically check that leakage variables do not leak more information about the secret inputs than the public normal output. The novelty of our approach is that we track the dependence of leakage vari- ables with respect not only to the initial values of input variables (as in classical approaches for noninterference), but taking also into account the final values of output variables. We adapted this approach to LLVM IR and we developed a prototype to verify LLVM implementations. Keywords: Information flow · Output-sensitive non-interference · Type system. 1 Introduction An important task of cryptographic research is to verify cryptographic imple- mentations for security flaws, in particular to avoid so-called timing attacks. Such attacks consist in measuring the execution time of an implementation on its execution platform. For instance, Brumley and Boneh [12] showed that it was possible to mount remote timing attacks by against OpenSSL’s implementation of the RSA decryption operation and to recover the key. Albrecht and Paterson [3] showed that the two levels of protection offered against the Lucky 13 attack from [2] in the first release of the new implementation of TLS were imperfect. A ⋆ This work is supported by the French National Research Agency in the framework of the “Investissements d’ avenir” program (ANR-15-IDEX-02) http://arxiv.org/abs/1909.09567v2 2 Cristian Ene, Laurent Mounier, and Marie-Laure Potet related class of attacks are cache-based attacks in which a malicious party is able to obtain memory-access addresses of the target program which may depend on secret data through observing cache accesses. Such attacks allow to recover the complete AES keys [17]. A possible countermeasure is to follow a very strict programming discipline called constant-time programming. Its principle is to avoid branchings con- trolled by secret data and memory load/store operations indexed by secret data. Recent secure C libraries such as NaCl [10] or mbedTLS1 follow this program- ming discipline. Until recently, there was no rigorous proof that constant-time algorithms are protected to cache-based attacks. Moreover, many cryptographic implementations such as PolarSSL AES, DES, and RC4 make array accesses that depend on secret keys and are not constant time. Recent works [6,4,11] fill this gap and develop the first formal analyzes that allow to verify if programs are correct with respect to the constant-time paradigm. An interesting extension was brought by Almeida et al. [4] who enriched the constant-time paradigm “distinguishing not only between public and private input values, but also between private and publicly observable output values”. This distinction raises interesting technical and theoretical challenges. Indeed, constant-time implementations in cryptographic libraries like OpenSSL include optimizations for which paths and addresses can depend not only on public input values, but also on publicly observable output values. Hence, considering only input values as non-secret information would thus incorrectly characterize those implementations as non-constant-time. [4] also develops a verification technique based on symbolic execution. However, the soundness of their approach depends in practice on the soundness of the underlying symbolic execution engine, which is very difficult to guarantee for real-world programs with loops. Moreover, their product construction can be very expensive in the worst case. In this paper we deal with statically checking programs for output-sensitive constant-time correctness: programs can still do branchings or memory ac- cesses controlled by secret data if the information that is leaked is subsumed by the normal output of the program. To give more intuition about the property that we want to deal with, let us consider the following example, where ct eq is a constant time function that allows to compare the arguments: good = 1 ; for ( i =0; i<B Size ; i++){ good = good & c t eq ( s e c r e t [ i ] , i n p [ i ] ) ; } i f ( ! good ){ for ( i =0; i<B Size ; i++) s e c r e t [ i ] = 0 ; } return good ; Let suppose that the array variable secret is secret, and all the other vari- ables are public. Intuitively this a sort of one-time check password verifying that 1 mbed TLS (formerly known as PolarSSL). https://tls.mbed.org/ Output-sensitive Information flow analysis 3 in p = secret and otherwise overwrites the array secret with zero. Obviously, this function is not constant-time as the variable good depends on secret, and hence branching on good violates the principles of constant-time programming. It is easy to transform this program into an equivalent one which is constant time. For example one could replace i f ( ! good ){ for ( i =0; i<B Size ; i++) s e c r e t [ i ] = 0 ; } by for ( i =0; i<B Size ; i++){ s e c r e t [ i ] = s e c r e t [ i ] & c t e q ( good , 1 ) ; } But branching on good is a benign optimization, since anyway, the value of good is the normal output of the program. Hence, even if the function is not constant- time, it should be considered output-sensitive constant time with respect to its specification. Such optimization opportunities arise whenever the interface of the target application specifies what are the publicly observable outputs, and this information is sufficient to classify the extra leakage as benign [4]. The objective of this work is to propose a static method to check if a program is output-sensitive constant time secure. We emphasize that our goal is not to verify that the legal output leaks “too much”, but rather to ensure that the unintended (side-channel) output does not leak more than this legal output. First, we propose a novel approach for verifying constant-time security based on a new information flow property, called output-sensitive noninterference. Information-flow security prevents confidential information to be leaked to pub- lic channels. Noninterference states that a public observer cannot learn anything about the private data. Since real systems need to intentionally declassify some information, this property is too strong. An alternative is relaxed noninterfer- ence which allows to specify explicit downgrading policies. In order to take into account public outputs while staying independent of how programs intention- ally declassify information, we develop an alternative solution: instead of using complex explicit policies for functions, we partition variables in three sets: in- put, output and leakage variables. Hence we distinguish between the legal public output and the information that can leak through side-channels, expressed by adding fresh additional leakage variables. Then we propose a typing system that can statically check that leakage variables do not leak more secret information than the public normal output. The novelty of our approach is that we track the dependence of leakage variables with respect to both the initial value of input variables (as classically the case for noninterference) and final values of output variables. Then, we show how to verify that a program written in a high-level language is output-sensitive constant time secure by using this typing system. Since timed and cache-based attacks target the executions of programs, it is important to carry out this verification in a language close to the machine- executed assembly code. Hence, we adapt our approach to a generic unstructured 4 Cristian Ene, Laurent Mounier, and Marie-Laure Potet assembly language inspired from LLVM and we show how we can verify programs coded in LLVM. Finally, we developed a prototype tool implementing our type system and we show how it can be used to verify LLVM implementations. To summarize, this work makes the following contributions described above: - in section 2 we reformulate output-sensitive constant-time as a new interesting noninterference property and we provide a sound type system that guarantees that well-typed programs are output-sensitive noninterferent; - in section 3 we show that this general approach can be used to verify that programs written in a high-level language are output-sensitive constant time; - in section 4 we adapt our approach to the LLVM-IR language and we develop a prototype tool that can be used to verify LLVM implementations. 2 Output-sensitive non-interference 2.1 The While language and Output-sensitive noninterference In order to reason about the security of the code, we first develop our framework in While, a simple high-level structured programming language. In section 3 we shall enrich this simple language with arrays and in section 4 we adapt our approach to a generic unstructured assembly language. The syntax of While programs is listed below: c ::= x := e | skip | c1; c2 | If e then c1 else c2 fi | While e Do c oD Meta-variables x, e and c range over the sets of program variables V ar, expres- sions and programs, respectively. We leave the syntax of expressions unspecified, but we assume they are deterministic and side-effect free. The semantics is shown in Figure 1. The reflexive and transitive closure of −→ is denoted by =⇒. A state σ maps variables to values, and we write σ(e) to denote the value of expression e in state σ. A configuration (c, σ) is a program c to be executed along with the current state σ. Intuitively, if we want to model the security of some program c with respect to side-channel attacks, we can assume that there are three special subsets of variables: XI the public input variables, XO the public output vari- ables and XL the variables that leak information to some malicious adversary. Then, output sensitive nonintereference asks that every two complete executions starting with XI -equivalent states and ending with XO-equivalent final states must be indistinguishable with respect to the leakage variables XL . In the fol- lowing definition, =X relates two states that coincide on all variables belonging to X . Definition 1. (adapted from [4]) Let XI , XO, XL ⊆ V ar be three sets of vari- ables, intended to represent the input, the output and the leakage of a program. A program c is (XI , XO, XL)-output-sensitive non-interferent when all its executions starting with XI-equivalent stores and leading to XO-equivalent final stores, give XL-equivalent final stores. Formally, for all σ, σ ′, ρ, ρ′, if 〈c, σ〉 =⇒ σ′ and 〈c, ρ〉 =⇒ ρ′ and σ =XI ρ and σ ′ =XO ρ ′, then σ′ =XL ρ ′. Output-sensitive Information flow analysis 5 (x := e, σ) −→ σ[x 7→ σ(e)] (skip, σ) −→ σ (c1, σ) −→ σ ′ (c1; c2, σ) −→ (c2, σ ′) (c1, σ) −→ (c ′ 1, σ ′) (c1; c2, σ) −→ (c ′ 1; c2, σ ′) σ(e) = 1 ? i = 1 : i = 2 (If e then c1 else c2 fi , σ) −→ (ci, σ) (While e Do c oD , σ) −→ (If e then c;While e Do c oD else skip fi , σ) Fig. 1. Operational semantics of the While language To illustrate the usefulness of the output-sensitive non-interference property let us consider again the example given in the previous section, shown on Fig- ure 2. good = 1 ; i = 0 ; for ( ; i<B Size ; i++){ good = good & c t eq ( s e c r e t [ i ] , i n p [ i ] ) ; } i f ( ! good ) { i =0; for ( ; i<B Size ; i++) s e c r e t [ i ] = 0 ; } return good ; Fig. 2. C code example from Section 1 Then, in order to reduce its output-sensitive constant time security to the output-sensitive non-interference property (as in Definition 1), first, we add a fresh variable xl to accumulate the leakage information (using the abstract con- catenation operator @). Then, variable xl is updated with the boolean condition of each branching instruction and with each expression used as an index array. The result of this transformation is given on Figure 3 (we denote by ct eq ni the function obtained by applying recursively the same transformation to ct eq): We consider the following sets of variables: XI = {in p}, XL = {xl} and XO = {good}. One can check that, for each pair of executions starting with the same value of in p and ending with the same value of good, then the final 6 Cristian Ene, Laurent Mounier, and Marie-Laure Potet good = 1 ; i =0; x l = x l @ ( i<B Size ) ; for ( ; i<B Size ; i++){ x l = x l @ i ; good = good & c t e q n i ( s e c r e t [ i ] , i n p [ i ] ) ; x l = x l @ ( i<B Size ) ; } x l = x l @ good ; i f ( ! good ) { x l = x l @ ( i<B Size ) ; i =0; for ( ; i<B Size ; i++) { x l = x l @ i ; s e c r e t [ i ] = 0 ; x l = x l @ ( i<B Size ) ; } } return good ; Fig. 3. C code example from Section 1 with explicit leakage value of xl will be the same. Then, according to Definition 1, this program is (XI , XO, XL)-output-sensitive non-interferent. In the remaining of the paper we will show that this transformation is general and, moreover, whenever the transformed program satisfies Definition 1, then the initial program is output- sensitive constant-time. The remaining of this section introduces a type-based information flow anal- ysis that allows to check whether a While program is output-sensitive noninter- ferent, i.e. the program does not leak more information about the secret inputs than the public normal output. 2.2 Preliminary definitions and notations As usual, we consider a flow lattice of security types L (also called security levels). An element x of L is an atom if x 6= ⊥ and there exists no element y ∈ L such that ⊥ ⊏ y ⊏ x. A lattice is called atomistic if every element x ∈ L is the join of the set of atoms below it [25]. This set is denoted by At(x). Assumption 2.21 Let (L,⊓,⊔,⊥,⊤) be an atomistic bounded lattice. As usual, we denote t1 ⊑ t2 iff t2 = t1 ⊔ t2. We assume that there exists a distinguished subset TO ⊆ L of atoms. Hence, from the above assumption, for any τo, τ ′ o ∈ TO and for any t1, t2 ∈ L: it holds that A1. τo ⊑ τ ′ o implies τo = τ ′ o, A2. τo ⊑ t1 ⊔ t2 implies τo ⊑ t1 or τo ⊑ t2, Output-sensitive Information flow analysis 7 A3. τo ⊑ t1 implies that there exists t ∈ L such that t1 = t ⊔ τo and τ0 6⊑ t. The assumption that our set L of security types is an atomistic lattice pro- vides a general structure which is sufficient for our purposes: it ensures the exis- tence of decompositions in atoms for any element in the lattice, and the ability to syntactically replace an atomic type by another (not necessarily atomic) type. A type environment Γ : V ar 7→ L describes the security levels of variables and the dependency with respect to the current values of variables in XO. In order to catch dependencies with respect to current values of output variables, we associate to each output variable o ∈ XO a fixed and unique symbolic type α(o) ∈ TO. For example if some variable x ∈ V ar has the type Γ (x) = Low⊔α(o), it means that the value of x depends only on public input and the current value of the output variable o ∈ XO. Hence, we assume that there is a fixed injective mapping α : X0 7→ T0 such that ∧ o1,o2∈XO ( o1 6= o2 ⇒ α(o1) 6= α(o2) ) ∧ ∧ o∈XO ( α(o) ∈ TO ) . We extend mappings Γ and α to sets of variables in the usual way: given A ⊆ V ar and B ⊆ XO we note Γ (A) def = ⊔ x∈A Γ (x) , α(B) def = ⊔ x∈B α(x). Our type system aims to satisfy the following output sensitive non-interference condition: if the final values of output variables in XO remain the same, only changes to initial inputs with types ⊑ t should be visible to leakage outputs with type ⊑ t ⊔ α(XO). More precisely, given a derivation ⊢α Γ{c}Γ ′, the final value of a variable x with final type Γ ′(x) = t ⊔ α(A) for some t ∈ L and A ⊆ XO, should depend at most on the initial values of those variables y with initial types Γ (y) ⊑ t and on the final values of variables in A. We call “real dependencies” the dependencies with respect to initial values of variables and “symbolic depen- dencies” the dependencies with respect to the current values of output variables. Following [19] we formalize the non-interference condition satisfied by the typing system using reflexive and symmetric relations. We write =A0 for relation which relates mappings which are equal on all values in A0 i.e. for two mappings f1, f2 : A 7→ B and A0 ⊆ A, f1 =A0 f2 iff ∀a ∈ A0, f1(a) = f2(a). For any mappings f1 : A1 7→ B and f2 : A2 7→ B, we write f1[f2] the operation which updates f1 according to f2, namely f1[f2](x) def = { f2(x) if x ∈ A1 ∩A2 f1(x) if x ∈ A1 \A2 Given Γ : V ar 7→ L , X ⊆ V ar and t ∈ L, we write =Γ,X,t for the reflexive and symmetric relation which relates states that are equal on all variables having type v ⊑ t in environment Γ , provided that they are equal on all variables in X : σ =Γ,X,t σ ′ iff σ =X σ ′ ⇒ ( ∀x, (Γ (x) ⊑ t ⇒ σ(x) = σ′(x)) ) . When X = ∅, we omit it, hence we write =Γ,t instead of =Γ,∅,t. Definition 2. [20] Let R and S be reflexive and symmetric relations on states. We say that program c maps R into S, written c : R =⇒ S, iff ∀σ, ρ, if 〈c, σ〉 =⇒ σ′ and 〈c, ρ〉 =⇒ ρ′ then σRρ ⇒ σ′Sρ′. 8 Cristian Ene, Laurent Mounier, and Marie-Laure Potet The type system we propose enjoys the following useful property: if ⊢α Γ{c}Γ ′ then c : =Γ,Γ (XI ) =⇒ =Γ ′,XO,α(XO)⊔Γ (XI) This property is an immediate consequence of Theorem 2. Hence, in order to prove that the above program c is output sensitive non- interferent according to Definition 1, it is enough to check that for all xl ∈ XL, Γ ′(xl) ⊑ α(XO)⊔ Γ (XI). Two executions of the program c starting from initial states that coincide on input variablesXI , and ending in final states that coincide on output variables XO, will coincide also on the leaking variables XL. We now formally introduce our typing system. Due to assignments, values and types of variables change dynamically. For example let us assume that at some point during the execution, the value of x depends on the initial value of some variable y and the current value of some output variable o (which itself depends on the initial value of some variable h), formally captured by an environment Γ where Γ (o) = Γ0(h) and Γ (x) = Γ0(y) ⊔ α(o), where Γ0 represents the initial environment. If the next to be executed instruction is some assignment to o, then the current value of o will change, so we have to mirror this in the new type of x: even if the value of x does not change, its new type will be Γ ′(x) = Γ0(y)⊔Γ0(h) (assuming that α(o) 6⊑ Γ0(y)). Hence Γ ′(x) is obtained by replacing in Γ (x) the symbolic dependency α(o) with the real dependency Γ (o). The following definition formalizes this operation that allows to replace an atom t0 by another type t′ in a type t (seen as the join of the atoms of its decomposition). Definition 3. If t0 ∈ TO is an atom and t ′, t ∈ L are arbitrary types, then we denote by t[t′/t0] the type obtained by replacing (if any) the occurrence of t0 by t′ in the decomposition At(t) in atoms of t t[t′/t0] def = { t if t0 6∈ At(t) t′ ⊔ ⊔b∈At(t)\{t0}b if t 0 ∈ At(t) Now we extend this definition to environments: let x ∈ XO and p ∈ L. Then Γ1 def = Γ ⊳α x represents the environment where the symbolic dependency on the last value of x of all variables is replaced by the real type of x: Γ1(y) def = (Γ (y))[Γ (x)/α(x)]. Similarly, (p, Γ )⊳α x def = p[Γ (x)/α(x)]. 2.3 Useful basic lemmas The following lemma is an immediate consequence of the Assumption 2.21 and Definition 3. Lemma 1. Let x ∈ XO, p ∈ L and let us denote Γ1 def = Γ ⊳α x and p1 def = (p, Γ )⊳α x. If α(x) 6⊑ Γ (x), then, 1. For any v ∈ X, Γ1(v) = (Γ (v), Γ )⊳α x, 2. For all variables y ∈ V ar, α(x) 6⊑ Γ1(y). 3. α(x) 6⊑ p1. Output-sensitive Information flow analysis 9 We want now to extend the above definition from a single output variable x to subsetsX ⊆ XO. Our typing system will ensure that each generated environment Γ will not contain circular symbolic dependencies between output variables, i.e., there are no output variable o1, o2 ∈ XO such that α(o1) ⊑ Γ (o2) and α(o2) ⊑ Γ (o1). We can associate a graph G(Γ ) = (XO, E) to an environment Γ , such that (o1, o2) ∈ E iff α(o1) ⊑ Γ (o2). We say that Γ is well formed, denoted WF(Γ ), if G(Γ ) is an acyclic graph. For acyclic graphs G(Γ ), we define a preorder over XO, denoted ⊑Γ , as the transitive closure of the relation {(o1, o2) ∈ XO ×XO | α(o1) ⊑ Γ (o2)}, i.e. o1 ⊑Γ o2 iff there is a path from o1 to o2 in G(Γ ). We also define the reachable variables of x ∈ XO w.r.t. Γ , denoted GT Γ (x), to be the set of all o ∈ XO such that x ⊑Γ o. Now, for acyclic graphs G(Γ ), we can extend Definition 3 to subsets X ⊆ XO, by first fixing an ordering X = {x1, x2, . . . xn} of variables in XO compatible with the graph (i.e. j ≤ k implies that xj 6⊑Γ xk), and then (p, Γ )⊳αX def = (((p, Γ )⊳αx1)⊳αx2) . . .⊳αxn. We also denote Γ ⊳αX def = ((Γ ⊳α x1)⊳α x2) . . .⊳α xn (in this case the ordering is not important, i.e. (Γ ⊳α x1)⊳α x2 = (Γ ⊳α x2)⊳α x1). The following lemma can be proved by induction on the size of X using Lemma 1. Lemma 2. Let X ⊆ XO, p ∈ L and let us denote Γ2 def = Γ ⊳α X and p2 def = (p, Γ )⊳α X. If WF(Γ ), then, 1. For any v ∈ X, Γ2(v) = (Γ (v), Γ )⊳α X, 2. For all variables x ∈ X, and all variables y ∈ V ar, α(x) 6⊑ Γ2(y). 3. For all variables x ∈ X, α(x) 6⊑ p2. Next Lemma gives a precise characterization of the new preorder induced by the application of the operator ⊳α. Lemma 3. Let Γ be a well formed environment and let x ∈ XO and X ⊆ XO. Let us denote Γ1 def = Γ ⊳αx and Γ2 def = Γ⊳αX. Then Γ1 and Γ2 are well formed. Moreover, ⊑Γ1=⊑Γ \{(x, o) | o ∈ XO} and ⊑Γ2=⊑Γ \{(x, o) | x ∈ X, o ∈ XO}. Proof: The key remark is that any edge of G(Γ1) where Γ1 def = Γ ⊳α x corresponds to either an edge or to a path of length two in G(Γ ). Indeed, let x1, x2 ∈ XO such that there exists an edge from x1 to x2 in G(Γ1), that is α(x1) ⊑ Γ1(x2) = Γ (x2)[Γ (x)/α(x)]. Then either α(x1) ⊑ Γ (x2) or α(x) ⊑ Γ (x2) and α(x1) ⊑ Γ (x). Hence either there is an edge from x1 to x2 in G(Γ ) or there must exist edges from x1 to x and from x to x2 (and hence a path of length two from x1 to x2) in G(Γ ). Now the assertion of the Lemma is an immediate consequence of the above remark and Lemma 1. 10 Cristian Ene, Laurent Mounier, and Marie-Laure Potet x 6∈ XO As1 p ⊢α Γ{x := e}Γ [x 7→ p ⊔ Γ [α](fv(e))] x ∈ XO \ fv(e) Γ1 = Γ ⊳α x As2 p ⊢α Γ{x := e}Γ1 [x 7→ p ⊔ Γ1[α](fv(e))] Skip p ⊢α Γ{skip}Γ x ∈ XO ∩ fv(e) Γ1 = Γ ⊳α x As3 p ⊢α Γ{x := e}Γ1 [x 7→ p ⊔ Γ (x) ⊔ Γ1[α](fv(e) \ x)] p ⊢α Γ{c1}Γ1 p ⊢α Γ1{c2}Γ2 Seq p ⊢α Γ{c1; c2}Γ2 p0 ⊑r p1 Γ ⊑r Γ ′ p1 ⊢α Γ ′{c}Γ ′1 Γ ′ 1 ⊑r Γ1 Sub p0 ⊢α Γ{c}Γ1 p ⊔ p′ ⊢α Γ{ci}Γi p ′ = (Γ [α](fv(e)), Γ ) ⊳α (def O(c1) ∪ def O(c2)) Γ ′ = Γ1 ⊳α def O(c2) ⊔ Γ2 ⊳α def O(c1) If p ⊢α Γ{If e then c1 else c2 fi }Γ ′ p ⊔ pe ⊢α Γ1{c}Γ ′ pe = Γ1[α](fv(e)) (Γ ⊳α def O(c)) ⊔ (Γ ′ ⊳α def O(c)) ⊑r Γ1 Wh p ⊢α Γ{While e Do c oD }Γ1 Fig. 4. Flow-sensitive typing rules for commands with output Let def(c) be the set of assigned variables in a program c, formally defined by: def(c) def =            {x} if c ≡ x := e ∅ if c ≡ skip def(c1) ∪ def(c2) if c ≡ c1; c2 def(c1) ∪ def(c2) if c ≡ If e then c1 else c2 fi def(c) if c ≡ While e Do c oD and let us denote def I(c) def = def(c)∩ (V ar \XO) and def O(c) def = def(c)∩XO. We define the ordering over environments as usual: Γ1 ⊑ Γ2 def = ∧ x∈V ar Γ1(x) ⊑ Γ2(x). We also define a restricted ordering over environments: Γ1 ⊑r Γ2 def = ∧ x∈V ar Γ1(x) ⊑ Γ2(x) ∧ ∧ o∈XO,x∈V ar (α(o) ⊑ Γ2(x) ⇒ α(o) ⊑ Γ1(x)). It is immediate that Γ1 ⊑r Γ2 implies Γ1 ⊑ Γ2. Intuitively, when enriching an environment using ⊑r, we have the right to add only “real dependencies” (and not “symbolic” dependencies with respect to variables in XO). We adapt this definition for elements t1, t2 ∈ L as well: we denote t1 ⊑r t2 when t1 ⊑ t2, and for all o ∈ XO, α(o) ⊑ t2 ⇒ α(o) ⊑ t1, i.e. t2 does not contain new symbolic dependencies w.r.t. t1. Next lemma is immediate from the definitions. Output-sensitive Information flow analysis 11 Lemma 4. Let Γ1, Γ2, Γ3 such that Γ1 ⊑ Γ2, p1, p2 ∈ L, o ∈ XO and X ⊆ XO with p1 ⊑r p2. Then Γ1 ⊳α o ⊑ Γ2 ⊳α o, Γ1 ⊳α X ⊑ Γ2 ⊳α X, (p1, Γ1) ⊳α o ⊑ (p2, Γ2) ⊳α o and (p1, Γ1) ⊳α X ⊑ (p2, Γ2) ⊳α X. Moreover, Γ1 ⊳α X ⊑r Γ3 implies that Γ3 ⊳α X = Γ3. The last assertion of the lemma is a consequence of the remark that Γ1⊳αX ⊑r Γ3 implies that Γ3 does not contain more “symbolic dependencies” than Γ1⊳αX , and Γ1 ⊳α X does not contain any “symbolic dependencies” with respect to variables in X . Obviously, using that ⊑r⊆⊑, all inequalities hold also when the premise Γ1 ⊑ Γ2 is replaced by Γ1 ⊑r Γ2. 2.4 Typing rules For a command c, judgements have the form p ⊢α Γ{c}Γ ′ where p ∈ L and Γ and Γ ′ are type environments well-formed. The inference rules are shown in Figure 4. The idea is that if Γ describes the security levels of variables which hold before execution of c, then Γ ′ will describe the security levels of those variables after execution of c. The type p represents the usual program counter level and serves to eliminate indirect information flows; the derivation rules ensure that all variables that can be changed by c will end up (in Γ ′) with types greater than or equal to p. As usual, whenever p = ⊥ we drop it and write ⊢α Γ{c}Γ ′ instead of ⊥ ⊢α Γ{c}Γ ′. Throughout this paper the type of an expression e is defined simply by taking the lub of the types of its free variables Γ [α](fv(e)), for example the type of x+ y + o where o is the only output variable is Γ (x) ⊔ Γ (y) ⊔ α(o). This is consistent with the typing rules used in many systems, though more sophisticated typing rules for expressions would be possible in principle. Let us explain some of the typing rules: – The rule As1 is a standard rule for assignment, the new value of x depends on the variables occuring in the right-hand side e. Since x is not an output variable, we do not need to update the type of the other variables. Moreover, notice that considering the type of an expression to be Γ [α](fv(e)) instead of Γ (fv(e)) allows to capture the dependencies with respect to the current values of output variables. – The rule As2 captures the fact that when assigning an output variable x we need to update the types of all the other variables depending on the last previous value of x: Γ1 = Γ ⊳α x express that symbolic dependencies with respect to the last previous value of x should be replaced with real dependencies with respect to the initial types of variables. – The rule As3 is similar to As2 when the assigned variable x occurs also on the right-hand side. – The rule Sub is the standard subtyping rule. Notice that we use relation ⊑r instead of ⊑ in order to prevent introducing circular dependencies. – The rule If deals with conditional statements. In an If statement, the pro- gram counter level changes for the typing of each branch in order to take into account the indirect information flow. Moreover, at the end of the If command, we do the join of the two environments obtained after the both 12 Cristian Ene, Laurent Mounier, and Marie-Laure Potet p = ⊥, Γ0 = [y → Y, z → Z, o1 → O1, o2 → O2] (1) o1 := x+ 1 Γ1 = [y → Y, z → Z, o1 → X, o2 → O2] (2) y := o1 + z Γ2 = [y → O1 ⊔ Z, z → Z, o1 → X, o2 → O2] (3) o1 := u Γ3 = [y→ X ⊔ Z, z → Z,o1 → U, o2 → O2] (4) z := o1 + o3 Γ4 = [y → X ⊔ Z, z→ O1 ⊔O3, o1 → U, o2 → O2] (5) If (o2 = o3 + x) p = O3 ⊔O2 ⊔X (6) then o1 := o2 Γ6 = [y → X ⊔ Z, z→ U ⊔O3,o1 → O3 ⊔O2 ⊔X ⊔O2, o2 → O2] (7) else o2 := o1 Γ7 = [y → X ⊔ Z, z → O1 ⊔ O3, o1 → U, o2 → O3 ⊔O2 ⊔X ⊔O1] (8) fi Γ8 = (Γ6 ⊳α o2) ⊔ (Γ7 ⊳α o1) = [y → X ⊔ Z, z→ U ⊔O3, o1 → O3 ⊔O2 ⊔X ⊔U, o2 → O3 ⊔O2 ⊔X ⊔U] Fig. 5. Example of application for our typing system branches, but in order to prevent cycles, we first replace the “symbolic” de- pendencies by the corresponding “real” dependencies for each output vari- able that is assigned by the other branch. In order to give some intuition about the rules, we present a simple example in Figure 5. Example 1. Let {x, y, z, u} ⊆ V ar \XO and {o1, o2, o3} ⊆ XO be some variables and let {X,Y, Z, U,O1, O2, O3, O1, O2, O3} be some atoms of a lattice of security levels. Let us assume that ∀i ∈ {1, 2, 3}, α(oi) = Oi. We assume that the initial environment is Γ0 = [x → X, y → Y, z → Z, u → U, o1 → O1, o2 → O2, o3 → O3]. Since the types of variables x, u and o3 do not change, we omit them in the following. We highlighted the changes with respect to the previous environment. After the first assignment, the type of o1 becomes X , meaning that the current value of o1 depends on the initial value of x. After the assignment y := o1 + z, the type of y becomes O1 ⊔ Z, meaning that the current value of y depends on the initial value of z and the current value of o1. After the assignment o1 = u, the type of y becomes X ⊔ Z as o1 changed and we have to mirror this in the dependencies of y, and the type of o1 becomes X . When we enter in the If , the program counter level changes to p = O3 ⊔O2 ⊔X as the expression o2 = o3 +x depends on the values of variables o2, o3, x, but o2 and o3 are output variables and o2 will be assigned by the If command, hence we replace the “symbolic” dependency α(o2) = O2 by its “real” dependency Γ (o2) = O2. At the end of the If command, we do the join of the two environments obtained after the both branches, but in order to prevent cycles, we first replace the “symbolic” Output-sensitive Information flow analysis 13 dependencies by the corresponding “real” dependencies for each output variable that is assigned by the other branch. 2.5 Well-formed environments In this section we prove that, if the initial environment is well-formed, then all the environments generated by the typing system are well-formed too. To do so, the following lemma states some useful properties, where for any p ∈ L, we denote by atomO(p) def = {o ∈ XO | α(o) ⊑ p}. Lemma 5. For all Γ , if WF(Γ ) and p ⊢α Γ{c}Γ ′ and atomO(p)∩defO(c) = ∅ then 1. WF(Γ ′), 2. for any o ∈ XO \ (def O(c) ∪ atomO(p)), GT Γ ′(o) ⊆ GT Γ (o), 3. for any o ∈ atomO(p), GT Γ ′(o) ⊆ GT Γ (o) ∪ def O(c), 4. for any o ∈ defO(c), GT Γ ′(o) ⊆ def O(c), 5. for any x 6∈ def(c), (Γ ⊳α def O(c))(x) ⊑r Γ ′(x). Proof: Proof is by induction on the derivation of p ⊢α Γ{c}Γ ′ for all assertions in the same time. We do a case analysis according to the last rule applied (case Skip is trivial). (Ass1) c is an assignment x := e for some x 6∈ XO. Since x 6∈ XO, it follows that G(Γ ′) = G(Γ ) and obviously for any x 6∈ def(c), Γ (x) = Γ ′(x) and ⊑Γ=⊑Γ ′ and WF(Γ ) implies WF(Γ ′). (Ass2) c is an assignment o := e for some o ∈ XO \ fv(e). Hence in this case def(c) = defO(c) = {o}, and by assumption, α(o) 6⊑ p. Then Γ ′ = Γ1[o 7→ p ⊔ Γ1[α](fv(e))] with Γ1 = Γ ⊳α o. By Lemma 3, WF(Γ1), and using Lemma 1 we get that WF(Γ1) does not contain any edge with origin o and hence WF(Γ ′). The second part follows from the remark that using Lemma 3 we get ⊑Γ1=⊑Γ \{(o, o ′) | o′ ∈ XO} and ⊑Γ ′=⊑Γ1 ∪{(o ′, o) | o′ ∈ atomO(p)} , and for any o′ 6= o, Γ1(o ′) = Γ (o′). Hence, GT Γ ′(o) = ∅. Finally, for any x 6∈ def(c), (Γ ⊳α o)(x) = Γ1(x) = Γ ′(x). (Ass3) c is an assignment o := e for some o ∈ XO ∩ fv(e). Similar to the previous case. (Seq) c is c1; c2. Then p ⊢α Γ{c1; c2}Γ2 was inferred based on p ⊢α Γ{c1}Γ1 and p ⊢α Γ1{c2}Γ2. Let us denote Ui = def O(ci), for i = 1, 2. Using the induction hypothesis for p ⊢α Γ{c1}Γ1 we get that WF(Γ1), and for any o ∈ XO \ (U1 ∪ atomO(p)), GT Γ1(o) ⊆ GT Γ (o), for any o ∈ atomO(p), GT Γ1(o) ⊆ GT Γ (o) ∪ U1 and for any o ∈ U1, GT Γ1(o) ⊆ U1. In addition, for any x 6∈ U1, (Γ ⊳α U1))(x) ⊑r Γ1(x). Using the induction hypothesis for p ⊢α Γ1{c2}Γ2 we get that WF(Γ2), and for any o ∈ XO \ (U2 ∪ atomO(p)), GT Γ2(o) ⊆ GT Γ1(o), for any o ∈ atomO(p), GT Γ2(o) ⊆ GT Γ1(o) ∪ U2 and for any o ∈ U2, GT Γ2(o) ⊆ U2. In addition, for any x 6∈ U2, (Γ1 ⊳α U2)(x) ⊑r Γ2(x). 14 Cristian Ene, Laurent Mounier, and Marie-Laure Potet Since defO(c) = U1 ∪ U2, for any o ∈ XO \ (U1 ∪ U2 ∪ atomO(p)), we have both o ∈ XO \ (U1 ∪ atomO(p)) and o ∈ XO \ (U2 ∪ atomO(p)) and hence GT Γ2(o) ⊆ GT Γ1(o) ⊆ GT Γ (o). For any o ∈ atomO(p), GT Γ2(o) ⊆ GT Γ1(o) ∪ U2 ⊆ GT Γ (o) ∪ U1 ∪ U2. Now, for any o ∈ (U1 ∪ U2), either o ∈ U2 or o ∈ U1 \ U2. If o ∈ U2, then GT Γ2(o) ⊆ U2 ⊆ U1 ∪ U2. If o ∈ U1 \ U2, then GT Γ2(o) ⊆ GT Γ1(o) ⊆ U1 ⊆ U1 ∪ U2. Finally, for any x 6∈ def(c), we have (Γ ⊳α (U1 ∪ U2)(x) = ((Γ ⊳α U1) ⊳α U2)(x) = ((Γ ⊳α U1)(x), Γ ⊳α U1) ⊳α U2 (1) ⊑ r ((Γ ⊳α U1)(x), Γ1) ⊳α U2 (2) ⊑ r (Γ1(x), Γ1)⊳α U2 = (Γ1 ⊳α U2)(x) (3) ⊑ r Γ2(x). We used whenever necessarily Lemma 5; in addition, in (1) we used that (Γ ⊳α U1)(x) does not depend on variables in U1, and by induction hypothesis for all variables v 6∈ U1, (Γ ⊳α U1)(v) ⊑r Γ1(v), in (2) we used that by induction hypothesis (Γ⊳αU1)(x) ⊑r Γ1(x), in (3) we used that x 6∈ U2, and hence by induction hypothesis, (Γ1 ⊳α U2)(x) ⊑r Γ2(x). (If) c is If e then c1 else c2 fi . Then p ⊢α Γ{If e then c1 else c2 fi }Γ ′ was in- ferred based on p⊔p′ ⊢α Γ{ci}Γi, where p ′ = (Γ [α](fv(e)), Γ )⊳α(def O(c1)∪ defO(c2)) and Γ ′ = Γ ′1 ⊔ Γ ′ 2 where Γ ′ 1 = Γ1 ⊳α def O(c2) and Γ ′ 2 = Γ2 ⊳α defO(c1). Let us denote Ui = def O(ci), for i = 1, 2. First notice that atomO(p) ∩ (U1 ∪ U2) = ∅ ensures that atomO(p ⊔ p ′) ∩ (U1 ∪ U2) = ∅ . Using the induction hypothesis for p ⊔ p′ ⊢α Γ{c1}Γ1 we get that WF(Γ1), and for any o ∈ XO \ (U1 ∪ atomO(p⊔ p ′)), GT Γ1(o) ⊆ GT Γ (o), for any o ∈ atomO(p⊔ p′), GT Γ1(o) ⊆ GT Γ (o)∪U1 and for any o ∈ U1, GT Γ1(o) ⊆ U1. In addition, for any x 6∈ U1, (Γ ⊳α U1))(x) ⊑r Γ1(x). Using the induction hypothesis for p ⊔ p′ ⊢α Γ{c2}Γ2 we get that WF(Γ2), and for any o ∈ XO \ (U2 ∪ atomO(p ⊔ p ′), GT Γ2(o) ⊆ GT Γ (o), for any o ∈ atomO(p⊔ p′), GT Γ2(o) ⊆ GT Γ (o)∪U2 and for any o ∈ U2, GT Γ2(o) ⊆ U2. In addition, for any x 6∈ U2, (Γ ⊳α U2))(x) ⊑r Γ2(x). For any o ∈ XO\(U1∪U2∪atomO(p⊔p ′)), GT Γ ′1∪Γ ′2(o) = GT (Γ1⊳αU2)∪(Γ2⊳αU1)(o) ⊆ GT Γ (o) since both GT Γ1⊳αU2(o) ⊆ GT Γ1(o) ⊆ GT Γ (o) and GT Γ2⊳αU1(o) ⊆ GT Γ2(o) ⊆ GT Γ (o). For any o ∈ U1, GT Γ2⊳αU1(o) = ∅ and by induction hypothesis GT Γ1⊳αU2(o) ⊆ GT Γ1(o) ⊆ U1. For any o ∈ U2, GT Γ1⊳αU2(o) = ∅ and by induction hypoth- esis GT Γ2⊳αU1(o) ⊆ GT Γ2(o) ⊆ U2. This implies that for any o ∈ (U1 ∪ U2), GT Γ ′ 1 ∪Γ ′ 2 (o) = GT (Γ1⊳αU1)∪(Γ2⊳αU2)(o) ⊆ U1 ∪ U2. For any o ∈ atomO(p⊔p′), by induction hypothesis GT Γ1⊳αU2(o) ⊆ GT Γ1(o) ⊆ GT Γ (o)∪U1 and GT Γ2⊳αU1(o) ⊆ GT Γ2(o) ⊆ GT Γ (o)∪U2. We already proved that for any o ∈ (U1 ∪ U2), GT Γ ′ 1 ∪Γ ′ 2 (o) ⊆ U1 ∪ U2. The previous inclusions imply that for any o ∈ atomO(p ⊔ p′), GT Γ ′ 1 ∪Γ ′ 2 (o) ⊆ GT Γ (o) ∪ U1 ∪ U2. Now if we assume by contradiction that ¬WF(Γ ′), we get that there must exist x1, x2 ∈ XO such that x1 ⊑Γ ′ 1 ⊔Γ ′ 2 x2 and x2 ⊑Γ ′ 1 ⊔Γ ′ 2 x1. We make an analysis by case: • x1 ∈ U1 ∩ U2. Impossible, since we have that WF(Γ1 ⊳α U2) and WF(Γ2 ⊳α U1), and for any o ∈ XO, x1 6⊑Γ1⊳αU2 o and x1 6⊑Γ2⊳αU1 o. Output-sensitive Information flow analysis 15 • x1, x2 ∈ U1 \U2. From induction hypothesis we get GT Γ ′ 1 (xi) ⊆ U1 and GT Γ ′2(xi) = ∅. This implies that for any x ∈ GT Γ ′1(xi), it holds x ∈ U1 and hence GT Γ ′2(x) = ∅. It means that x1 ⊑Γ ′1⊔Γ ′2 x2 and x2 ⊑Γ ′1⊔Γ ′2 x1 implies that x1 ⊑Γ ′ 1 x2 and x2 ⊑Γ ′ 1 x1 which contradicts WF(Γ ′ 1). • x1 ∈ U1\U2 and x2 6∈ U1. From induction hypothesis we get GT Γ ′1(x1) ⊆ U1 and GT Γ ′2(x1) = ∅. This implies that for any x ∈ GT Γ ′1(x1), it holds x ∈ U1 and hence GT Γ ′ 2 (x) = ∅. It means that x1 ⊑Γ ′ 1 ⊔Γ ′ 2 x implies that x ∈ GT Γ ′1(x1) ⊆ U1, contradiction with x2 6∈ U1 and x1 ⊑Γ ′1⊔Γ ′2 x2. • x1 6∈ U1∪U2 and x2 6∈ U1∪U2. In this case, by induction GT Γ ′1⊔Γ ′2(x1) ⊆ GT Γ (x1) ∪ (U1 ∪ U2) and GT Γ ′ 1 ⊔Γ ′ 2 (x2) ⊆ GT Γ (x2) ∪ (U1 ∪ U2). Hence x1 ⊑Γ ′1⊔Γ ′2 x2 implies that x1 ⊑Γ x2, x2 ⊑Γ ′1⊔Γ ′2 x1 implies that x2 ⊑Γ x1, contradiction with WF(Γ ). • The remaining cases are symmetrical ones with the previous cases. (While) Similar to the rule (If). (Sub) Trivial from the premises of the rule, using the induction hypothesis, the transitivity of ⊑r and that Γ1 ⊑r Γ2 implies that G(Γ1) = G(Γ2). 2.6 Soundness of the typing system As already stated above, our type system aims to capture the following non- interference condition: given a derivation p ⊢α Γ{c}Γ ′, the final value of a vari- able x with final type t ⊔ α(XO), should depend at most on the initial values of those variables y with initial types Γ (y) ⊑ t and on the final values of variables in XO. Or otherwise said, executing a program c on two initial states σ and ρ such that σ(y) = ρ(y) for all y with Γ (y) ⊑ t which ends with two final states σ′ and ρ′ such that σ′(o) = ρ′(o) for all o ∈ XO will satisfy σ ′(x) = ρ′(x) for all x with Γ ′(x) ⊑ t⊔α(XO). In order to prove the soundness of the typing system, we need a stronger invariant denoted I(t, Γ ): intuitively, (σ, ρ) ∈ I(t, Γ ) means that for each variable x and A ⊆ XO, if σ =A ρ and Γ (x) ⊑ t ⊔ α(A), then σ(x) = ρ(x). Formally, given t ∈ L and Γ : V ar 7→ L, we define I(t, Γ ) def = ⋂ A⊆XO =Γ,A,α(A)⊔t . The following lemmas provide some useful properties satisfied by the invari- ant I(t, Γ ). Lemma 6. If Γ1 ⊑ Γ2 then for all t ∈ L, I(t, Γ1) ⊆ I(t, Γ2). Proof: Assume (σ, ρ) ∈ I(t, Γ1). We prove that (σ, ρ) ∈ I(t, Γ2). Let A ⊆ XO and let y ∈ V ar such that Γ2(y) ⊑ α(A) ⊔ t. Assume that σ =A ρ. We have to prove that σ(y) = ρ(y). We have Γ1(y) ⊑r Γ2(y) ⊑ α(A) ⊔ t, and since (σ, ρ) ∈ I(t, Γ1) and σ =A ρ, we get σ(y) = ρ(y). Lemma 7. Let x ∈ XO, X ⊆ XO and let Γ be well-formed. Let Γ1 = Γ ⊳α x and Γ2 = Γ ⊳α X.Then for all t ∈ L, it holds I(t, Γ ) ⊆ I(t, Γ1) and I(t, Γ ) ⊆ I(t, Γ2). 16 Cristian Ene, Laurent Mounier, and Marie-Laure Potet Proof: We prove only the first inclusion, the second one can be easily proved by induction using the first one. Let σ, ρ such that (σ, ρ) ∈ I(t, Γ ) and let us prove that (σ, ρ) ∈ I(t, Γ1). Let B ⊆ XO and let y ∈ V ar such that Γ1(y) ⊑ α(B) ⊔ t. Assume that σ =B ρ. We have to prove that σ(y) = ρ(y). Then Γ1(y) ⊑ α(B) ⊔ t implies that ( Γ (y) ) [Γ (x)/α(x)] ⊑ α(B) ⊔ t. That is, either Γ (y) ⊑ α(B) ⊔ t or Γ (y) ⊑ α(B) ⊔ α(x) ⊔ t and Γ (x) ⊑ α(B) ⊔ t. – If Γ (y) ⊑ α(B) ⊔ t, since σ =B ρ and (σ, ρ) ∈ I(t, Γ ) we get σ(y) = ρ(y). – If Γ (y) ⊑ α(B) ⊔ α(x) ⊔ t and Γ (x) ⊑ α(B) ⊔ t, from σ =B ρ and (σ, ρ) ∈ I(t, Γ ), we get σ ={x} ρ, and hence σ =B∪{x} ρ. Since Γ (y) ⊑ α(B)⊔α(x)⊔t and σ =Γ,B∪{x},α(B∪{x})⊔t ρ, we get σ(y) = ρ(y). Lemma 8. Let o ∈ XO and let Γ ′ = Γ ⊳α o with well formed WF(Γ ). Let t ∈ L and let (σ, ρ) ∈ I(t, Γ ).For any A ⊆ XO such that σ =A\{o} ρ and for any y ∈ V ar such that Γ ′(y) ⊑ α(A) ⊔ t it holds that σ(y) = ρ(y). Proof: WF(Γ ) and Γ ′(y) ⊑ α(A) ⊔ t implies that ( Γ (y) ) [Γ (o)/α(o)] ⊑ α(A \ {o}) ⊔ t. That is, either Γ (y) ⊑ α(A \ {o}) ⊔ t or Γ (y) ⊑ α(A) ⊔ t and Γ (o) ⊑ α(A \ {o}) ⊔ t. – If Γ (y) ⊑ α(A\{o})⊔t, as σ =A\{o} ρ and (σ, ρ) ∈ I(t, Γ ) we get σ(y) = ρ(y). – If Γ (y) ⊑ α(A) ⊔ t and Γ (o) ⊑ α(A \ {o}) ⊔ t, from σ =A\{o} ρ and (σ, ρ) ∈ I(t, Γ ), we get σ ={o} ρ, and hence σ =A ρ. Since Γ (y) ⊑ α(A) ⊔ t and σ =Γ,A,α(A)⊔t ρ, we get σ(y) = ρ(y). Lemma 9. Let Γ ′ = Γ⊳αU for a well formed WF(Γ ) where U = {o1, . . . , on} ⊆ XO . Let t ∈ L and let (σ, ρ) ∈ I(t, Γ ). For any A ⊆ XO such that σ =A\U ρ and for any y ∈ V ar such that Γ ′(y) ⊑ α(A) ⊔ t it holds that σ(y) = ρ(y). Proof: By induction on n. The case n = 1 follows from the lemma 8. Let us denote Un−1 = U \ {on} = {o1, . . . , on−1}. and let Γn−1 = Γ ⊳α Un−1. Hence Γ ′ = Γn−1 ⊳α on. By lemma 3, Γn−1 is well formed too.WF(Γn−1) and Γ ′(y) ⊑ α(A)⊔t implies that ( Γn−1(y) ) [Γn−1(on)/α(on)] ⊑ α(A \ {on}) ⊔ t. That is, either Γn−1(y) ⊑ α(A \ {on}) ⊔ t or Γn−1(y) ⊑ α(A) ⊔ t and Γn−1(on) ⊑ α(A \ {on}) ⊔ t. – If Γn−1(y) ⊑ α(A \ {on})⊔ t, since σ =(A\{on})\Un−1 ρ, by induction (taking U ′ = {o1, . . . , on−1} and A ′ = A \ {on}) we get σ(y) = ρ(y). – If Γn−1(y) ⊑ α(A)⊔t and Γn−1(on) ⊑ α(A\{on})⊔t, since σ =(A\{on})\Un−1 ρ, we get by induction (taking U ′ = Un−1 and A ′ = A\{on}) that σ ={on} ρ, and hence σ =A\Un−1 ρ. From Γn−1(y) ⊑ α(A) ⊔ t and σ =A\Un−1 ρ using the induction again (taking U ′ = Un−1 and A ′ = A) we get σ(y) = ρ(y). The following theorem states the soundness of our typing system. Output-sensitive Information flow analysis 17 Theorem 1. Let us assume that WF(Γ ) and ∀o ∈ XO, α(o) 6⊑ t. If p ⊢α Γ{c}Γ ′ then c : I(t, Γ ) =⇒ I(t, Γ ′). Proof: Proof is by induction on the derivation of p ⊢α Γ{c}Γ ′. Let σ, σ′, ρ, ρ′ such that (σ, ρ) ∈ I(t, Γ ) and 〈c, σ〉 =⇒ σ′ and 〈c, ρ〉 =⇒ ρ′. We prove that (σ′, ρ′) ∈ I(t, Γ ′). Let A ⊆ XO and let y ∈ V ar such that Γ ′(y) ⊑ α(A) ⊔ t. Assume that σ′ =A ρ ′. We have to prove that σ′(y) = ρ′(y). We do a case analysis according to the last rule applied (case Skip is trivial). (Ass1) c is an assignment x := e for some x 6∈ XO. Then Γ ′ = Γ [x 7→ p ⊔ Γ [α](fv(e))]. Hence σ′ =A ρ ′ implies σ =A ρ. If y 6≡ x, then Γ (y) = Γ ′(y) ⊑ α(A) ⊔ t, and since σ =Γ,A,α(A)⊔t ρ, we get σ′(y) = σ(y) = ρ(y) = ρ′(y). Let us assume that c is y := e for some e and y 6∈ XO. Then Γ [α](fv(e)) ⊑ Γ ′(y) ⊑ α(A) ⊔ t, and this implies that: 1) for all variables v ∈ fv(e) \XO, Γ (v) ⊑ α(A) ⊔ t, hence σ(v) = ρ(v) and 2) for all variables v ∈ fv(e) ∩XO, α(v) ⊑ α(A)⊔ t, hence v ∈ A and σ(v) = ρ(v). We get that σ(e) = ρ(e), and hence σ′(y) = ρ′(y). (Ass2) c is an assignment o := e for some o ∈ XO \ fv(e). Using Lemma 7, we get that (σ, ρ) ∈ I(t, Γ1), where Γ1 = Γ ⊳α o and Γ ′ = Γ1[o 7→ p ⊔ Γ1[α](fv(e) \ o)]. If y 6≡ o, then Γ1(y) = Γ ′(y) ⊑ α(A) ⊔ t, and since σ =Γ1,A,α(A)⊔t ρ, we get σ′(y) = σ(y) = ρ(y) = ρ′(y). If y ≡ o, then p⊔ Γ1[α](fv(e) \ o) = Γ ′(o) ⊑ α(A) ⊔ t, and this implies that: 1) for all variables v ∈ fv(e) \ XO, Γ1(v) ⊑ α(A) ⊔ t, hence σ(v) = ρ(v) and 2) for all variables v ∈ fv(e) ∩ XO, α(v) ⊑ α(A) ⊔ t, hence v ∈ A and σ(v) = ρ(v). We get that σ(e) = ρ(e), and hence σ′(y) = ρ′(y). (Ass3) c is an assignment o := e for some o ∈ XO ∩ fv(e). Similar to the previous case, using the remark that Γ (o) ⊑ α(A) ⊔ t implies that σ(o) = ρ(o). (Seq) Trivial, using the transitivity of =⇒. (If) Let us denote Ui = {o i 1, o i 2, . . . , o i n} = def O(ci) for i = 1, 2 for some good orderings Ui of def O(ci). • If (Γ [α](fv(e)), Γ ) ⊳α (U1 ∪ U2) 6⊑ Γ ′(y), obviously we get y 6∈ def(c), i.e. c contains no assignments to y. Hence σ′(y) = σ(y) and ρ(y) = ρ′(y). Then from Lemma 7, we get that (Γ⊳α(U1∪U2))(y) ⊑r Γ ′(y) ⊑ α(A)⊔t. Moreover, σ′ =A ρ ′ implies that σ =A\(U1∪U2) ρ and using Lemma 9 we get σ(y) = ρ(y), and hence σ′(y) = σ(y) = ρ(y) = ρ′(y). • Let us suppose that (Γ [α](fv(e)), Γ ) ⊳α (U1 ∪ U2) ⊑ Γ ′(y). We denote Γ i0 = Γ ⊳α Ui. Then (Γ [α](fv(e)), Γ ) ⊳α (U1 ∪ U2) ⊑ Γ ′(y) ⊑ α(A) ⊔ t, and this implies that (Γ [α](fv(e)), Γ )⊳α (U1 ∪U2) ⊑ α(A \ (U1 ∪U2))⊔ t. Moreover, σ ′ =A ρ ′ implies that σ =A\(U1∪U2) ρ. Using Lemma 9, we get for each variable v ∈ fv(e) that σ(v) = ρ(v). This proves that σ(e) = ρ(e) and hence both executions 〈c, σ〉 =⇒ σ′ and 〈c, ρ〉 =⇒ ρ′ take the same branch i. Then we use the induction hypothesis applied to p⊔ p′ ⊢α Γ{ci}Γi to get that (σ′, ρ′) ∈ I(t, Γi), and then, since Γ ′ = Γ1 ⊳α U2 ⊔ Γ2 ⊳α U1, we use Lemmas 6 and 7 to conclude (σ′, ρ′) ∈ I(t, Γ ′). 18 Cristian Ene, Laurent Mounier, and Marie-Laure Potet (While) c is While e Do c1 oD . Then p ⊢α Γ{c}Γ ′ was inferred based on p⊔ pe ⊢α Γ ′{c}Γ1 and (Γ ⊳α U)⊔ (Γ1 ⊳α U) ⊑r Γ ′ where U = defO(c) and pe = Γ ′[α](fv(e)). From (σ, ρ) ∈ I(t, Γ ), using Lemma 7, we get (σ, ρ) ∈ I(t, Γ ⊳αU) and using now Lemma 6 and the inequality Γ ⊳α U ⊑ (Γ ⊳αU)⊔ (Γ1 ⊳α U) ⊑r Γ ′, we obtain (σ, ρ) ∈ I(t, Γ ′). Using the induction hypothesis applied to p ⊔ pe ⊢α Γ ′{c}Γ1, we get that (σ ′, ρ′) ∈ I(t, Γ1). We apply again Lemma 7 and we get (σ′, ρ′) ∈ I(t, Γ1⊳αU), and using Lemma 6 and that (Γ⊳αU)⊔(Γ1⊳αU) ⊑r Γ ′, we obtain (σ′, ρ′) ∈ I(t, Γ ′). (Sub) Trivial, from Lemma 6 and the induction hypothesis. 2.7 Soundness w.r.t. to output-sensitive non-interference In this section we show how we can use the typing system in order to prove that a program c is output-sensitive noninterferent. Let V are = V ar ∪ {o | o ∈ XO}. Let us define L def = {τA | A ⊆ V ar e}. We denote ⊥ = τ∅ and ⊤ = τV are and we consider the lattice (L,⊥,⊤,⊑) with τA ⊔ τA′ def = τA∪A′ and τA ⊑ τA′ iff A ⊆ A′. Obviously, L is a bounded atomistic lattice, its set of atoms being {τx | x ∈ V ar} ∪ {τo | o ∈ XO}. The following Theorem is a consequence of the Definition 1 and Theorem 1. Theorem 2. Let L be the lattice described above. Let (Γ, α) be defined by Γ (x) = {τx}, for all x ∈ V ar and α(o) = {τo}, for all o ∈ XO. If ⊢α Γ{c}Γ ′ and for all xl ∈ XL, Γ ′(xl) ⊑ Γ (XI) ⊔ α(XO), then c is (XI , XO, XL)-secure. Proof: Let t = Γ (XI). First, we prove that if σ =XI ρ, then (σ, ρ) ∈ I(t, Γ ). Let A ⊆ XO such that σ =A ρ and let y ∈ V ar such that Γ (y) ⊑ α(A) ⊔ t = α(A)⊔Γ (XI). This implies that y ∈ XI , and since σ =XI ρ, we get σ(y) = ρ(y). Now let σ, σ′, ρ, ρ′, such 〈c, σ〉 =⇒ σ′ and 〈c, ρ〉 =⇒ ρ′ and σ =XI ρ and σ′ =XO ρ ′. Let xl ∈ XL. We have to prove that σ ′ =Xl ρ ′. Let us apply the Theorem 1 with t = Γ (XI). Since ⊢α Γ{c}Γ ′ and (σ, ρ) ∈ I1(t, Γ ), we get that (σ′, ρ′) ∈ I(t, Γ ′). It means that σ′ =Γ ′,XO,α(XO)⊔Γ (XI ) ρ ′. Since by hypothesis we have that σ′ =XO ρ ′ and Γ ′(xl) ⊑ α(XO) ⊔ Γ (XI), we get that σ ′ =xl ρ ′. 3 Output-sensitive constant-time In this section we illustrate how our approach can be applied to a more realistic setting, considering a specific side-channel leakage due to the cache usage. How- ever, this approach could be applied to any other side-channel setting as soon as one can model the leakage produced by each command. Following [1,4], we consider two types of cache-based information leaks: 1) disclosures that happen when secret data determine which parts of the program are executed; 2) disclosures that arise when access to memory is indexed by Output-sensitive Information flow analysis 19 act ≡ r(σ( −→ f )) (x := e, σ) act −→ σ[(x, 0) 7→ σ(e)] act ≡ w(σ(e1)) : r(σ( −→ f )) (x[e1] := e, σ) act −→ σ[(x, σ(e1)) 7→ σ(e)] σ(e) 6= 1 act ≡ b(σ(e)) : r(σ( −→ f )) (While e Do c oD , σ) act −→ σ σ(e) = 1 act ≡ b(σ(e)) : r(σ( −→ f )) (While e Do c oD , σ) act −→ (c;While e Do c oD , σ) σ(e) = 1 ? i = 1 : i = 2 act ≡ b(σ(e)) : r(σ( −→ f )) (If e then c1 else c2 fi , σ) act −→ (ci, σ) Fig. 6. Syntax and Labeled Operational semantics sensitive information. In order to model the latter category, we shall enrich the simple language from section 2 with arrays: c ::= x := e | x[e1] := e | skip | c1; c2 | If e then c1 else c2 fi | While e Do c oD To simplify notations, we assume that array indexes e1 are basic expressions (not referring to arrays) and that XO does not contain arrays. Moreover as in [4], a state or store σ maps array variables v and indices i ∈ N to values σ(v, i). The labeled semantics of While programs is listed in Figure 6. In all rules, we denote −→ f = (fi)i, the set of all indexes occurring in e (i.e., e contains sub-expressions of the form xi[fi]). The labels on the execution steps correspond to the information which is leaked to the environment (r() for a read access on memory, w() for a write access and b() for a branch operation). In the rules for (If) and (While) the valuations of branch conditions are leaked. Also, all indexes to program variables read and written at each statement are exposed. We give in Figure 7 the new typing rules. As above, we denote −→ f = (fi)i, the set of all indexes occurring in e. We add a fresh variable xl, that is not used in programs, in order to capture the unintended leakage. Its type is always growing up and it mirrors the information leaked by each command. In rule (As1”) we take a conservative approach and we consider that the type of an array variable is the lub of all its cells. The information leaked by the assignment x[e1] := e is the index e1 plus the set −→ f = (fi)i of all indexes occurring in e. Moreover, the new type of the array variable x mirrors the fact that now the value of x depends also on the index e1 and on the right-hand side e. Definition 4. An execution is a sequence of visible actions: a1 −→ a2 −→ . . . an −→. A program c is (XI , XO)-constant time when all its executions starting with XI-equivalent stores that lead to finally XO-equivalent stores, are identical. Following [4], given a set X of program variables, two stores σ and ρ are X- equivalent when σ(x, i) = ρ(x, i) for all x ∈ X and i ∈ N. Two executions a1 −→ . . . an −→ and b1 −→ . . . bm −→ are identical iff n = m and aj = bj for all 1 ≤ j ≤ n. We can reduce the (XI , XO)-constant time security of a command c to the (XI , XO, {xl})-security (see section 2.7) of a corresponding command ω(c), ob- tained by adding a fresh variable xl to the program variables fv(c), and then 20 Cristian Ene, Laurent Mounier, and Marie-Laure Potet x 6∈ XO As1’ p ⊢ct α Γ{x := e}Γ [x 7→ p ⊔ Γ [α](fv(e))][xl 7→ Γ (xl) ⊔ Γ [α](fv( −→ f )))] x 6∈ XO p1 = (Γ [α](fv(e1), fv(e)) pl = (Γ [α](fv(e1), fv( −→ f )) Ast’ p ⊢ctα Γ{x[e1] := e}Γ [x 7→ p ⊔ Γ (x) ⊔ p1][xl 7→ Γ (xl) ⊔ pl] x ∈ XO \ fv(e) Γ1 = Γ ⊳α x As2’ p ⊢ctα Γ{x := e}Γ1[x 7→ p ⊔ Γ1[α](fv(e))][xl 7→ Γ1(xl) ⊔ Γ1[α](fv( −→ f )))] x ∈ XO ∩ fv(e) Γ1 = Γ ⊳α x As3’ p ⊢ctα Γ{x := e}Γ1[x 7→ p ⊔ Γ (x) ⊔ Γ1[α](fv(e) \ x)][xl 7→ Γ1(xl) ⊔ Γ1[α](fv( −→ f )))] Skip p ⊢ctα Γ{skip}Γ p ⊢ctα Γ{c1}Γ1 p ⊢ ct α Γ1{c2}Γ2 Seq p ⊢ctα Γ{c1; c2}Γ2 p0 ⊑r p1 Γ ⊑r Γ ′ p1 ⊢ ct α Γ ′{c}Γ ′1 Γ ′ 1 ⊑r Γ1 Sub p0 ⊢ ct α Γ{c}Γ1 pl = Γ [α](fv(e)) p ′ = (pl, Γ ) ⊳α (def O(c1) ∪ def O(c2)) p ⊔ p′ ⊢ctα Γ [xl 7→ Γ (xl) ⊔ pl]{ci}Γi Γ ′ = Γ1 ⊳α def O(c2) ⊔ Γ2 ⊳α def O(c1) If p ⊢ctα Γ{If e then c1 else c2 fi }Γ ′ pl = Γ [α](fv(e)) pe = Γ1[α](fv(e)) p ⊔ pe ⊢ ct α Γ1[xl 7→ Γ (xl) ⊔ pe]{c}Γ ′ Γ [xl 7→ Γ (xl) ⊔ pl] ⊔ ((Γ ′[xl 7→ Γ ′(xl) ⊔ pe]) ⊳α def O(c)) ⊑r Γ1 Wh p ⊢ctα Γ{While e Do c oD }Γ1 Fig. 7. Typing Rules for Output Sensitive Constant Time Output-sensitive Information flow analysis 21 • ω(•) x := e xl := xl : r( −→ f ); x := e x[e1] := e xl := xl : w(e1) : r( −→ f ); x[e1] := e skip skip c1; c2 ω(c1);ω(c2) If e then c1 else c2 fi xl := xl : b(e) : r( −→ f ); If e then ω(c1) else ω(c2) fi While e Do c oD xl := xl : b(e) : r( −→ f );While e Do ω(c);xl := xl : b(e) : r( −→ f ) oD Fig. 8. Instrumentation for ω(•) adding recursively before each assignment and each boolean condition predicate, a new assignment to the leakage variable xl that mirrors the leaked information. Let :,b(, )r(, )w() be some new abstract operators. The construction of the in- strumentation ω(•) is shown in Fig. 8. As above, we denote by −→ f = (fi)i the set of all indexes occurring in e. First we can extend the While language with array variables, then we need to extend the typing system from section 2 with a rule corresponding to the new rule Ast′. Then, the following lemma gives the relationship between the type of a program c using the new typing system and the type of the instrumented program ω(c) using the extended typing system from the previous section. Lemma 10. Let c a command such that xl 6∈ fv(c), σ, σ ′ two stores , tr some execution trace and [] the empty trace. 1. p ⊢ctα Γ{c}Γ ′ iff p ⊢α Γ{ω(c)}Γ ′. 2. (c, σ) tr =⇒ σ′ iff (ω(c), σ[xl 7→ []]) =⇒ σ ′[xl 7→ tr]. Now combining Theorem 2 and Lemma 10 we get the following Theorem which proves the soundness of the new typing system. Theorem 3. Let L be the lattice defined in the section 2.7. Let (Γ, α) be defined by Γ (x) = {τx}, for all x ∈ V ar and α(o) = {τo}, for all o ∈ XO and Γ (xl) = ⊥. If p ⊢ctα Γ{c}Γ ′ and Γ ′(xl) ⊑ Γ (XI)⊔α(XO), then c is (XI , XO)- constant time. 4 Application to low-level code We show in this section how the type system we proposed to express output- sensitive constant-time non-interference on the While language can be lifted to a low-level program representation like the LLVM byte code [21]. 4.1 LLVM-IR We consider a simplified LLVM-IR representation with four instructions: assign- ments from an expression (register or immediate value) or from a memory block 22 Cristian Ene, Laurent Mounier, and Marie-Laure Potet r← op(Op,−→v ) assign to r the result of Op applied to operands −→v r← load(v) load in r the value stored at address pointed by v store(v1, v2) store at address pointed by v2 the value v1 cond(r, bthen, belse) branch to bthen if the value of r is true and to bfalse otherwise goto b branch to b Fig. 9. Syntax and informal semantics of simplified LLVM-IR (load), writing to a memory block (store) and (un)conditional jump instructions. We assume that the program control flow is represented by a control-flow graph (CFG) G = (B,→E , binit, bend) where B is the set of basic blocks, →E the set of edges connecting the basic blocks, binit ∈ B the entry point and bend ∈ B the ending point. We denote by Reach(b, b′) the predicate indicating that node b′ is reachable from node b, i.e., there exists a path in G from b to b′. A program is then a (partial) map from control points (b, n) ∈ B × N to instructions where each basic block is terminated by a jump instruction. The memory model con- sists in a set of registers or temporary variables R and a set of memory blocks M (including the execution stack). V al is the set of values and memory block ad- dresses. The informal semantics of our simplified LLVM-IR is given in Figure 9, where r ∈ R and v ∈ R ∪ V al is a register or an immediate value. In the formal operational semantics, execution steps are labeled with leaking data, i.e., addresses of store and load operations and branching conditions. This formal semantics is defined in Figure 10. It is implicitly parameterized by the program p, a configuration is a tuple ((b, n), ρ, µ) where (b, n) ∈ B × N is the control point and ρ : R 7→ V al (resp. µ : M 7→ V al) denote the content of registers (resp. memory). 4.2 Type system First, we introduce the following notations for an LLVM-IR program represented by a CFG G = (B,→E , binit, bend): 1. Function dep : B → 2B associates to each basic block its set of “depending blocks”, i.e., b′ ∈ dep(b) iff b′ dominates b and there is no block b” between b′ and b such that b” post-dominates b′. We recall that a node b1 dominates (resp. post-dominates) a node b2 iff every path from the entry node binit to b2 goes through b1 (resp. every path from b2 to the ending node bend goes through b1). 2. Partial function br : B → R returns the “branching register”, i.e., the register r used to compute the branching condition leading outside b (b is terminated by an instruction cond(r, bthen, belse)). Note that in LLVM branching regis- ters are always fresh and assigned only once before to be used. 3. Function PtsTo : (B×N)× (R∪M) → 2M returns the set of (addresses of) memory blocks pointed to by a given register or memory block at a given Output-sensitive Information flow analysis 23 p(b, n) = r ← op(Op,−→v ) v = Op (J−→v K(ρ,µ)) ((b, n), ρ, µ) −→ ((b, n+ 1), ρ[r → v], µ) p(b, n) = r ← load(v) ad = JvK(ρ,µ) val = µ(ad) ((b, n), ρ, µ) r(ad) −→ ((b, n+ 1), ρ[r → val], µ) p(b, n) = goto b′ ((b, n), ρ, µ) −→ ((b′, 0), ρ, µ) p(b, n) = store(v1, v2) v = Jv1K(ρ,µ) ad = Jv2K(ρ,µ) ((b, n), ρ, µ) w(ad) −→ ((b, n+ 1), ρ, µ[ad→ v]) p(b, n) = cond(r, bthen, belse) JrK(ρ,µ) = 1 ((b, n), ρ, µ) j(1) −→ ((bthen, 0), ρ, µ) p(b, n) = cond(r, bthen, belse) JrK(ρ,µ) = 0 ((b, n), ρ, µ) j(0) −→ ((belse, 0), ρ, µ) Fig. 10. Labeled operational semantics for LLVM-IR control point. For example, bl ∈ PtsTo(b, n)(r) means that at control point (b, n), register r may contain the address of block bl ∈ M . We now define a type system (Figures 11 to 14) that allows to express the output-sensitive constant-time property for LLVM-IR -like programs. The main difference with respect to the rules given at the source level (Figures 4 and 7) is that the control-flow is explicitly given by the CFG, and not by the language syntax. For a LLVM-like program, an environment Γ : R ∪M 7→ L, associates security types to registers and memory blocks. p(b, n) = r ← op(Op,−→v ) τ0 = ⊔ x∈br(dep(b)) Γ [α](x) τ = (Γ [α](−→v ) ⊔ τ0) r 6∈ XO Op1 ⊢α (b, n) : Γ ⇒ Γ [r → τ ] p(b, n) = r ← op(Op,−→v ) τ0 = ⊔ x∈br(dep(b)) Γ [α](x) τ = (Γ [α](−→v ) ⊔ τ0) r ∈ XO Γ1 = (Γ, α) ⊳α r Op2 ⊢α (b, n) : Γ ⇒ Γ1[r → τ ] Fig. 11. assignment from an operation Op 24 Cristian Ene, Laurent Mounier, and Marie-Laure Potet Assignment from an operation Op (Figure 11). In rules Op1 and Op2, the new type τ of the assigned register r is the join of the type of operands −→v and the type of all the branching conditions dominating the current basic block (τ0). Note that since branching registers r are assigned only once in LLVM there is no need to update their dependencies from output variables (using the ⊳α operator), Γ (r) being never changed once r has been assigned. p(b, n) = r ← load(v) τ0 = ⊔ x∈br(dep(b)) Γ [α](x) Am = PtsTo(b, n)(v) τ1 = Γ [α](v) ⊔ τ0 r 6∈ XO τ2 = Γ [α](Am) Ld1 ⊢α (b, n) : Γ ⇒ (Γ [xl → Γ (xl) ⊔ τ1][r → τ2 ⊔ τ1] p(b, n) = r ← load(v) τ0 = ⊔ x∈br(dep(b)) Γ1[α](x) Am = PtsTo(b, n)(v) τ1 = Γ1[α](v) ⊔ τ0 r ∈ XO Γ1 = (Γ, α) ⊳α r τ2 = Γ1[α](Am) Ld2 ⊢α (b, n) : Γ ⇒ Γ1[xl → Γ1(xl) ⊔ τ1][r → τ2 ⊔ τ1] Fig. 12. assignment from a load expression Assignment from a load expression (Figure 12). Rules Ld1 and Ld2 up- date Γ in a similar way as Op1 and Op2, the main difference being that since some of the memory locations accessed when dereferencing v (i.e., PtsTo(b, n)(v)) are in Am (i.e., potentially in the cache) the dependencies of v are added to the type of the leakage variable xl. p(b, n) = store(v1, v2) τ0 = ⊔ x∈br(dep(b)) Γ [α](x) Am = PtsTo(b, n)(v2) A0 = Am ∩X0 τ1 = Γ1[α](v2) ⊔ τ0 Γ1 = (Γ, α) ⊳α A0 τ2 = Γ1[α](v1) St ⊢α (b, n) : Γ ⇒ Γ1[xl → Γ1(xl) ⊔ τ1][vs∈Am → Γ (vs) ⊔ τ2 ⊔ τ1] Fig. 13. store instruction Store instruction (Figure 13). Rule St updates the dependencies of all mem- ory locations pointed to by v2 by adding the types of v1 and v2 itself. In addition, the type of the leakage variable xl is also updated with the dependencies of v2 and with the dependencies of all branching registers that influenced the execu- tion flow to reach the current block b. Conditional and unconditional jump (Figure 14). Rule CJmp indicates that the leakage variable type is augmented with the type of the branching Output-sensitive Information flow analysis 25 p(b, n) = cond(r, bthen, belse) CJmp ⊢α (b, n) : Γ ⇒ Γ [xl → Γ (xl) ⊔ Γ [α](r)] p(b, n) = goto b′ Jmp ⊢α (b, n) : Γ ⇒ Γ Fig. 14. conditional and unconditional jump condition register. Unconditional jumps (Rule Jmp) leave the environment un- changed. 4.3 Well typed LLVM programs are output-sensitive constant-time The following definition is adapted from [6]. Definition 5. An LLVM-IR program p is well typed with respect to an initial environment Γ0 and final environment Γ ′ (written ⊢α p : Γ0 ⇒ Γ ′) , if there is a family of well-defined environments {(Γ )(b,n) | (b, n) ∈ (B,N)}, such that for all nodes (b, n) and all its successors (b′, n′), there exists a type environment γ and A ⊆ XO such that ⊢α (b, n) : Γ(b,n) ⇒ γ and (γ ⊳α A) ⊑r Γ(b′,n′). In the above definition the set A is mandatory in order to prevent dependency cycles between variables in XO. The following Theorem is the counterpart of Theorem 3. It shows the sound- ness of our type system for LLVM-IR programs with respect to output-sensitive constant-time. Theorem 4. Let L be the lattice from the section 2.7. Let (Γ, α) be defined by Γ (x) = {τx}, for all x ∈ R ∪M , α(o) = {τo}, for all o ∈ XO and Γ (xl) = ⊥. If ⊢α p : Γ ⇒ Γ ′ and Γ ′(xl) ⊑ Γ (XI)⊔α(XO), then p is (XI , XO)- constant time. 4.4 Example We illustrate below the effect of the LLVM-IR typing rules on a short exam- ple. The C code of this example is given on Figure 15, and the corresponding (simplified) LLVM-IR on Figure 16. int p [ 1 0 ] , q [ 1 0 ] ; // g l o b a l v a r i a b l e s int main ( ) { int x , y ; p [ x ] = q [ y ] ; return 0 ; // output va l ue i s always 0 } Fig. 15. A C code example 26 Cristian Ene, Laurent Mounier, and Marie-Laure Potet 1 @q = common g l oba l 2 @p = common g l oba l 3 %x = alloca i32 4 %y = alloca i32 5 6 %1 = load i32∗ %y 7 %2 = getelementptr @q, 0 , %1 8 %3 = load %2 9 %4 = load %x 10 %5 = getelementptr @p, 0 , %4 11 store %3, %5 Fig. 16. The simplified LLVM-IR code of Figure 15 In LLVM-IR, instructions alloca and global allow to declare temporary and global variables and their value correspond to memory addresses. For a sake of simplicity we choose to not define specific typing rules for these instructions, they are taken into account only in building the initial environment. First, we assume that xl denotes the leakage variable and that the con- tent of C variables p, q, x and y are stored in memory blocks b0 to b3, i.e. at the initial control point, PtsTo(@p) = b0, P tsT o(@q) = b1, P tsT o(%x) = b2, P tsT o(%y) = b3. Now we consider the following initial environment (produced by lines 1-4 in Figure 16): Γ0(@p) = Γ0(@q) = Γ0(%x) = Γ0(%y) = ⊥ Γ0(b0) = P, Γ0(b1) = Q,Γ0(b2) = X,Γ0(b3) = Y, Γ0(xl) = ⊥ This initial environment captures the idea that the values of variables @p, @q, %x, %y are addresses (of memory blocks corresponding to the “high-level” C variables p, q, x and y) and hence their security type is ⊥, and the memory blocks b0 to b3 correspond to the C variables p, q, x and y, and this is mirrored in the initial environment Γ0. Moreover, initially, nothing is leaked yet. We then update Γ0 by applying our typing rules in sequence to each instruc- tion of the LLVM-IR representation. Note that the getelementptr instruction, which is specific to LLVM, allows to compute an address corresponding to an indexed access in a buffer. Hence, it is treated by our typing system as an arith- metic (Op) instruction. %1 = load %y Γ1 = Γ0[xl → Γ0(xl) ⊔ Γ0(%y),%1 → Γ0(%y) ⊔ Γ0(PtsTo(%y))] = Γ0[xl → ⊥,%1 → Y ] Output-sensitive Information flow analysis 27 %2 = getelementptr @q, 0, %1 PtsTo(%2) = b1 Γ2 = Γ1[%2 → Γ1(@q) ⊔ Γ1(0) ⊔ Γ1(%1)] = Γ1[%2 → Y ] %3 = load %2 Γ3 = Γ2[xl → Γ2(xl) ⊔ Γ2(%2),%3 → Γ0(%2) ⊔ Γ0(PtsTo(%2))] = Γ2[xl → Y,%3 → Y ⊔Q] %4 = load %x Γ4 = Γ3[xl → Γ3(xl) ⊔ Γ3(%x),%4 → Γ3(%x) ⊔ Γ3(PtsTo(%x))] = Γ3[%4 → X ] %5 = getelementptr @p, 0, %4 PtsTo(%5) = b0 Γ5 = Γ4[%5 → Γ4(@p) ⊔ Γ4(0) ⊔ Γ4(%4)] = Γ4[%5 → X ] store %3, %5 Γ6 = Γ5[xl → Γ5(xl) ⊔ Γ5(%5), P tsT o(%5) → Γ5(PtsTo(%5)) ⊔ Γ5(%3) ⊔ Γ5(%5)] = Γ5[xl → Y ⊔X, b0 → P ⊔ Y ⊔Q ⊔X ] Making all the replacements, we get that the final environment is: Γ6 = [xl → Y ⊔X, b0 → P ⊔ Y ⊔Q ⊔X, b1 → Q, b2 → X, b3 → Y,@p → ⊥,@q → ⊥, %x → ⊥,%y → ⊥,%1 → Y,%2 → Y,%3 → Y ⊔Q,%4 → X,%5 → X ] In this final environment Γ6, variable xl depends on the initial types X and Y assigned to memory blocks b2 and b3. This means that the addresses accessed when reading (resp. writing) buffer p (resp. q) may leak to an attacker. Hence, if one of the variables x or y is a secret, since neither x nor y is an output value, then this program is not output sensitive constant-time, which may lead to a security issue. 4.5 Implementation We are developing a prototype tool implementing the type system for LLVM programs. This type system consists in computing flow-sensitive dependency relations between program variables. Def. 5 provides the necessary conditions under which the obtained result is sound (Theorem 4). We give some technical indications regarding our implementation. 28 Cristian Ene, Laurent Mounier, and Marie-Laure Potet Output variables XO are defined as function return values and global vari- ables; we do not currently consider arrays nor pointers in XO. Control depen- dencies cannot be deduced from the syntactic LLVM level, we need to explic- itly compute the dominance relation between basic blocks of the CFG (the dep function). Def. 5 requires the construction of a set A ⊆ XO to update the environment produced at each control locations in order to avoid circular de- pendencies (when output variable are assigned in alternative execution paths). To identify the set of basic blocks belonging to such alternative execution paths leading to a given block, we use the notion of Hammock regions [15]. More pre- cisely, we compute function Reg : (B × B × (→E)) → 2 B, returning the set of Hammock regions between a basic block b and its immediate dominator b′ with respect to an incoming edge ei of b. Thus, Reg(b ′, b, (c, b)) is the set of blocks belonging to CFG paths going from b′ to b without reaching edge ei = (c, b): Reg(b′, b, (c, b)) = {bi | b ′ →E b1 · · · →E bn →E b∧∀i ∈ [1, n−1]. ¬Reach(bi, c)}. Fix-point computations are implemented using Kildall’s algorithm. To better handle real-life examples we are currently implementing the PtsTo function, an inter-procedural analysis, and a more precise type analysis combining both over- and under-approximations of variable dependencies (see section 6). 5 Related Work Information flow. There is a large number of papers on language-based se- curity aiming to prevent undesired information flows using type systems (see [27]). An information-flow security type system statically ensures noninterfer- ence, i.e. that sensitive data may not flow directly or indirectly to public chan- nels [31,24,30,29]. The typing system presented in section 2 builds on ideas from Hunt and Sands’ As attractive as it is, noninterference is too strict to be useful in practice, as it prevents confidential data to have any influence on observable, public output: even a simple password checker function violates noninterference. Relaxed defi- nitions of noninterference have been defined in order to support such intentional downward information flows [28]. Li and Zdancewic [22] proposed an expressive mechanism called relaxed noninterference for declassification policies that sup- ports the extensional specification of secrets and their intended declassification. A declassification policy is a function that captures the precise information on a confidential value that can be declassified. For the password checker example, the following declassification policy λp.λx.h(p) == x, allows an equality comparison with the hash of password to be declassified (and made public), but disallows arbitrary declassifications such as revealing the password. The problem of information-flow security has been studied also for low level languages. Barthe and Rezk [8,9] provide a flow sensitive type system for a sequential bytecode language. As it is the case for most analyses, implicit flows are forbidden, and hence, modifications of parts of the environment with lower security type than the current context are not allowed. Genaim and Spoto present in [16] a compositional information flow analysis for full Java bytecode. Output-sensitive Information flow analysis 29 Information flow applied to detecting side-channel leakages. Information- flow analyses track the flow of information through the program but often ignore information flows through side channels. Side-channel attacks extract sensitive information about a program’s state through its observable use of resources such as time or memory. Several approaches in language-based security use se- curity type systems to detect timing side-channels [1,18]. Agat [1] presents a type system sensitive to timing for a small While-language which includes a trans- formation which takes a program and transforms it into an equivalent program without timing leaks. Molnar et al [23] introduce the program counter model, which is equivalent to path non-interference, and give a program transformation for making programs secure in this model. FlowTracker [26] allows to statically detect time-based side-channels in LLVM programs. Relying on the assumption that LLVM code is in SSA form, they com- pute control dependencies using a sparse analysis [13] without building the whole Program Dependency Graph. Leakage at assembly-level is also considered in [6]. They propose a fine-grained information-flow analysis for checking that assembly programs generated by CompCert are constant-time. Moreover, they consider a stronger adversary which controls the scheduler and the cache. All the above works do not consider publicly observable outputs. The work that is closest to ours is [4], where the authors develop a formal model for constant-time programming policies. The novelty of their approach is that it is distinguishing not only between public and private input values, but also between private and publicly observable output values. As they state, this distinction poses interesting technical and theoretical challenges. Moreover, constant-time implementations in cryptographic libraries like OpenSSL include optimizations for which paths and addresses can depend not only on public input values, but also on publicly observable output values. Considering only input values as non- secret information would thus incorrectly characterize those implementations as non-constant-time. They also develop a verification technique based on the self-composition based approach [7]. They reduce the constant time security of a program P to safety of a product program Q that simulates two parallel executions of P. The tool operates at the LLVM bytecode level. The obtained bytecode program is transformed into a product program which is verified by the Boogie verifier [5] and its SMT tool suite. Their approach is complete only if the public output is ignored. Otherwise, their construction relies on identifying the branches whose conditions can only be declared benign when public outputs are considered. For all such branches, the verifier needs to consider separate paths for the two simulated executions, rather than a single synchronized path and in the worst case this can deteriorate to an expensive product construction. 6 Conclusion and Perspectives In this paper we proposed a static approach to check if a program is output- sensitive constant-time, i.e., if the leakage induced through branchings and/or memory accesses do not overcome the information produced by (regular) observ- 30 Cristian Ene, Laurent Mounier, and Marie-Laure Potet able outputs. Our verification technique is based on a so-called output-sensitive non-interference property, allowing to compute the dependencies of a leakage variable from both the initial values of the program inputs and the final values of its outputs. We developed a type system on a high-level While language, and we proved its soundness. Then we lifted this type system to a basic LLVM-IR and we developed a prototype tool operating on this intermediate representation, showing the applicability of our technique. This work could be continued in several directions. One limitation of our method arising in practice is that even if the two snippets xl = h; o = h and o = h;xl = o are equivalent, only the latter can be typed by our typing sys- tem. We are currently extending our approach by considering also an under- approximation β(•) of the dependencies between variables and using “symbolic dependencies” also for non-output variables. Then the safety condition from Theorem 2 can be improved to something like ”∃V such that (Γ ′(xl) ⊳α V ) ⊑ (Γ (XI)⊳α V ) ⊔ (β ′(XO)⊳α V ) ⊔ α(XO)”. In the above example, we would ob- tain Γ ′(xl) = α(h) = β ′(o) ⊑ α(o) ⊔ β′(o), meaning that the unwanted maximal leakage Γ ′(xl) is less than the minimal leakage β ′(o) due to the normal output. From the implementation point of view, further developments are needed in or- der to extend our prototype to a complete tool able to deal with real-life case studies. This may require to refine our notion of arrays and to take into account arrays and pointers as output variables. We could also consider applying a sparse analysis, as in FlowTracker [26]. It may happen that such a pure static analysis would be too strict, rejecting too much “correct” implementations. To solve this issue, a solution would be to combine it with the dynamic verification technique proposed in [4]. Thus, our analysis could be used to find automatically which branching conditions are benign in the output-sensitive sense, which could re- duce the product construction of [4]. Finally, another interesting direction would be to adapt our work in the context of quantitative analysis for program leakage, like in [14]. References 1. Agat, J.: Transforming out timing leaks. In: Proceedings of the 27th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. pp. 40– 53. ACM (2000) 2. Al Fardan, N.J., Paterson, K.G.: Lucky thirteen: Breaking the tls and dtls record protocols. In: Security and Privacy (SP), 2013 IEEE Symposium on. pp. 526–540. IEEE (2013) 3. Albrecht, M.R., Paterson, K.G.: Lucky microseconds: A timing attack on amazon’s s2n implementation of tls. In: Annual International Conference on the Theory and Applications of Cryptographic Techniques. pp. 622–643. Springer (2016) 4. Almeida, J.B., Barbosa, M., Barthe, G., Dupressoir, F., Emmi, M.: Verify- ing constant-time implementations. In: 25th USENIX Security Symposium (USENIX Security 16). pp. 53–70. USENIX Association, Austin, TX (2016), https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/almeida https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/almeida Output-sensitive Information flow analysis 31 5. Barnett, M., Chang, B.Y.E., DeLine, R., Jacobs, B., Leino, K.R.M.: Boogie: A modular reusable verifier for object-oriented programs. In: FMCO. vol. 5, pp. 364– 387. Springer (2005) 6. Barthe, G., Betarte, G., Campo, J., Luna, C., Pichardie, D.: System-level non- interference for constant-time cryptography. In: Proceedings of the 2014 ACM SIGSAC Conference on Computer and Communications Security. pp. 1267–1279. ACM (2014) 7. Barthe, G., D’Argenio, P.R., Rezk, T.: Secure information flow by self-composition. In: Computer Security Foundations Workshop, 2004. Proceedings. 17th IEEE. pp. 100–114. IEEE (2004) 8. Barthe, G., Rezk, T.: Secure information flow for a sequential java virtual machine. In: TLDI’05: Types in Language Design and Implementation. Citeseer (2003) 9. Barthe, G., Rezk, T., Basu, A.: Security types preserving compilation. Computer Languages, Systems & Structures 33(2), 35–59 (2007) 10. Bernstein, D., Lange, T., Schwabe, P.: The security impact of a new cryptographic library. Progress in Cryptology–LATINCRYPT 2012 pp. 159–176 (2012) 11. Blazy, S., Pichardie, D., Trieu, A.: Verifying constant-time implementations by ab- stract interpretation. In: European Symposium on Research in Computer Security. pp. 260–277. Springer (2017) 12. Brumley, D., Boneh, D.: Remote timing attacks are practical. Computer Networks 48(5), 701–716 (2005) 13. Choi, J.D., Cytron, R., Ferrante, J.: Automatic construction of sparse data flow evaluation graphs. In: Proceedings of the 18th ACM SIGPLAN-SIGACT Sympo- sium on Principles of Programming Languages. pp. 55–66. POPL ’91, ACM (1991) 14. Doychev, G., Köpf, B., Mauborgne, L., Reineke, J.: Cacheaudit: A tool for the static analysis of cache side channels. ACM Trans. Inf. Syst. Secur. 18(1), 4:1–4:32 (Jun 2015). https://doi.org/10.1145/2756550, http://doi.acm.org/10.1145/2756550 15. Ferrante, J., Ottenstein, K., Warren, J.: The program dependence graph and its use in optimization. TOPLAS 9(3), 319–349 (1987) 16. Genaim, S., Spoto, F.: Information flow analysis for java bytecode. In: Verification, Model Checking, and Abstract Interpretation. pp. 346–362. Springer (2005) 17. Gullasch, D., Bangerter, E., Krenn, S.: Cache games–bringing access-based cache attacks on aes to practice. In: Security and Privacy (SP), 2011 IEEE Symposium on. pp. 490–505. IEEE (2011) 18. Hedin, D., Sands, D.: Timing aware information flow security for a javacard- like bytecode. Electronic Notes in Theoretical Computer Science 141(1), 163–182 (2005) 19. Hunt, S., Sands, D.: Binding time analysis: A new perspective. In: In Proceed- ings of the ACM Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM’91). pp. 154–164. ACM Press (1991) 20. Hunt, S., Sands, D.: On flow-sensitive security types. In: ACM SIGPLAN Notices. vol. 41, pp. 79–90. ACM (2006) 21. Lattner, C., Adve, V.: Llvm: A compilation framework for lifelong program anal- ysis & transformation. In: Proceedings of the International Symposium on Code Generation and Optimization: Feedback-directed and Runtime Optimization. CGO ’04, IEEE Computer Society, Washington, DC, USA (2004) 22. Li, P., Zdancewic, S.: Downgrading policies and relaxed noninterference. In: Pro- ceedings of POPL. vol. 40, pp. 158–170. ACM (2005) 23. Molnar, D., Piotrowski, M., Schultz, D., Wagner, D.: The program counter security model: Automatic detection and removal of control-flow side channel attacks. In: ICISC. vol. 3935, pp. 156–168. Springer (2005) https://doi.org/10.1145/2756550 http://doi.acm.org/10.1145/2756550 32 Cristian Ene, Laurent Mounier, and Marie-Laure Potet 24. Myers, A.C.: Jflow: Practical mostly-static information flow control. In: Proceed- ings of the 26th ACM SIGPLAN-SIGACT symposium on Principles of program- ming languages. pp. 228–241. ACM (1999) 25. Nation, J.B.: Notes on lattice theory (1998) 26. Rodrigues, B., Quintão Pereira, F.M., Aranha, D.F.: Sparse representation of im- plicit flows with applications to side-channel detection. In: Proceedings of the 25th International Conference on Compiler Construction. pp. 110–120. ACM (2016) 27. Sabelfeld, A., Myers, A.C.: Language-based information-flow security. IEEE Jour- nal on selected areas in communications 21(1), 5–19 (2003) 28. Sabelfeld, A., Sands, D.: Declassification: Dimensions and principles. Journal of Computer Security 17(5), 517–548 (2009) 29. Swamy, N., Chen, J., Chugh, R.: Enforcing stateful authorization and information flow policies in fine. In: ESOP. pp. 529–549. Springer (2010) 30. Vaughan, J.A., Zdancewic, S.: A cryptographic decentralized label model. In: Se- curity and Privacy, 2007. SP’07. IEEE Symposium on. pp. 192–206. IEEE (2007) 31. Volpano, D., Irvine, C., Smith, G.: A sound type system for secure flow analysis. Journal of computer security 4(2-3), 167–187 (1996) Output-sensitive Information flow analysis
1cybersec
arXiv
Review the result of git-merge before the actual merge. <p>Is there a way to review the result of a merge between two branches before actually merging them ? </p> <p>When attempting to merge branch A to branch B, I usually checkout a temporary branch from B, merge it with branch A, then I'd create a diff patch, or just checkout to that temporary branch and check whether everything is working fine before merging A to B.</p> <p>Does git provide a command or a feature that would accomplishes this?</p>
0non-cybersec
Stackexchange
Smallest $n$ such that $p^n \nmid (p^2-1)!$. <p>Maybe trivial for number theorists, but not for me: is the title meaningful to ask for (<span class="math-container">$p$</span> is a prime)? If so, what's the answer? Thanks</p>
0non-cybersec
Stackexchange
How to make MBP use USB Ethernet first and when disconnected, use WI-FI?. <p>The Wi-Fi where I work is spotty at times and spotty in certain locations (like where my cube is :-( ). I won't get into why it's still like this after months of complaining but I want to use the USB Ethernet at my desk since it's more reliable and then fail over to Wi-Fi if I unplug the USB to go to meetings or something.</p> <p>I found this <a href="https://apple.stackexchange.com/questions/98815/how-does-the-mac-choose-which-connection-to-use-when-both-wifi-and-ethernet-are">link on the apple stackexchange site</a> but it's not doing what I think it should be doing, which is connect in the order specified in System Preferences. It appears that it's connecting to both and using both sources (Wi-Fi more than USB).</p> <p>In this screenshot, we can see my System Preferences. USB is first, Wi-Fi is second. <a href="https://i.stack.imgur.com/3RdUS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3RdUS.png" alt="this screenshot"></a></p> <p>In this screenshot, we can see via iStat Menus that both interfaces are receiving traffic, although, most traffic has been going thru Wi-Fi even though I've been plugged into USB for about the past 45 min to 1 hr. Hopefully there's a way to connect strictly via USB when I'm at my desk and Wi-Fi when I move around.</p> <p><a href="https://i.stack.imgur.com/YEyPd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YEyPd.png" alt="this screenshot"></a></p>
0non-cybersec
Stackexchange
My Nintendo has launched.
0non-cybersec
Reddit
Optional stopping theorem question. <blockquote> <blockquote> <p><span class="math-container">$X_n$</span> is an irreducible and aperiodic Markov chain with transition matrix <span class="math-container">$P$</span>. There is a function <span class="math-container">$f$</span> s.t. <span class="math-container">$Pf(x)\leq\alpha f(x)$</span> for <span class="math-container">$x\notin B$</span>, <span class="math-container">$B$</span> a finite set and <span class="math-container">$\alpha&lt;1$</span>. <span class="math-container">$f(x)&gt;M$</span> on <span class="math-container">$x\notin B$</span>. Show <span class="math-container">$$E_x(\tau_B)&lt;\infty$$</span></p> </blockquote> </blockquote> <p>I can show that <span class="math-container">$Y_n:= \alpha^{-n}f(X_n)$</span> is a super-martingale off of <span class="math-container">$B$</span> and let <span class="math-container">$\tau = \tau_B$</span>. So by optional stopping:</p> <p><span class="math-container">$$\begin{align} f(x)\geq E_x[Y_{n\wedge \tau}]&amp;= E_x[f(X_{\tau\wedge n}\frac{1}{\alpha^{\tau\wedge n}})] \\ \implies f(x) &amp;\geq \liminf_{n\to \infty} E_x[f(X_{\tau\wedge n}\frac{1}{\alpha^{\tau\wedge n}})] \\ &amp;\geq E_x[\liminf_{n\to \infty} f(X_{\tau\wedge n}\frac{1}{\alpha^{\tau\wedge n}})] \text{ By Fatou's lemma} \\ &amp;\geq E_x M(1/\alpha)^\infty.1_{\tau=\infty} + E_x (1/\alpha)^\tau f(X_\tau) .1_{\tau&lt;\infty} \end{align} $$</span></p> <p>Since <span class="math-container">$\alpha&lt;1$</span>, I can see that <span class="math-container">$P(\tau = \infty)= 0$</span> but not sure how to go from <span class="math-container">$\infty&gt;f(x)&gt;E_x [(1/\alpha)^\tau f(X_\tau) .1_{\tau&lt;\infty}]$</span> to saying <span class="math-container">$E_x(\tau)&lt;\infty$</span>?</p>
0non-cybersec
Stackexchange
Do you think fifty shades of grey would still be popular if the roles/gender were reversed ?. I like for example you have the rich female CEO who dommes a male journalist. Alternatively, Anastasia is the dominant one and Christian is the submissive one.
0non-cybersec
Reddit
A bowl of matches.
0non-cybersec
Reddit
Storing unicode UTF-8 string in std::string. <p>In response to discussion in </p> <p><a href="https://stackoverflow.com/questions/4169948/cross-platform-strings-and-unicode-in-c">Cross-platform strings (and Unicode) in C++</a></p> <p><a href="https://stackoverflow.com/questions/2722951/how-to-deal-with-unicode-strings-in-c-c-in-a-cross-platform-friendly-way">How to deal with Unicode strings in C/C++ in a cross-platform friendly way?</a></p> <p>I'm trying to assign a <code>UTF-8</code> string to a <code>std::string</code> variable in <code>Visual Studio 2010</code> environment</p> <p><code>std::string msg = "महसुस";</code></p> <p>However, when I view the string view debugger, I only see "?????" I have the file saved as Unicode (UTF-8 with Signature) and i'm using character set "use unicode character set"</p> <p>"महसुस" is a nepali language and it contains 5 characters and will occupy 15 bytes. But visual studio debugger shows msg size as 5</p> <p>My question is:</p> <p><strong>How do I use std::string to just store the utf-8 without needing to manipulate it</strong>?</p>
0non-cybersec
Stackexchange
My dog and goose are best friends. My goose constantly grooms my dog..
0non-cybersec
Reddit
what is the geometrical interpretation to positive definite matrix. <p>What is the geometrical interpretation of positive definite matrix ? (not necessarily symmetric)</p> <p>if $A$ is positive definite, what does it do to a vector $x$ (i.e. $Ax$)?</p>
0non-cybersec
Stackexchange
I get a permission denied (public key) when I try to scp in ssh. <p>I can login to the remote server via ssh and navigate through it's file system, but as soon as I try to scp a file from the server to my laptop I get an error message.</p> <p>Example:</p> <pre><code>user@server:/file$ scp -r user@server: /file/ /My/Home/Dir [I Hit Enter] Permission denied (publickey) </code></pre> <p>Why am I getting this error, and how can I resolve this.<br> Thanks</p>
0non-cybersec
Stackexchange
Anyone else had this prob? I'm on the insider build on Windows10 (v1909). &#x200B; [Installing the media feature pack didn't do anything](https://preview.redd.it/q5pa4uhbs6241.png?width=1152&format=png&auto=webp&s=db28cba81c8027934924fbead454bad5f6619d31)
0non-cybersec
Reddit
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
Cleaning out the natives section at work, when I spotted this guy..
0non-cybersec
Reddit
Does sending mail on behalf of another domain (using a Sender: header) increase chances of being marked as spam?. <p>Our marketing department is contracting with a service that will send email to prospective customers on our behalf. From what I'm gathering from their documentation, it sounds like they do so via the Sender header (i.e. the From header contains an address in our domain, and the Sender header contains one from their domain). This places a "via" or "on behalf of" tag in the display of some mail clients.</p> <p>They give us the option of installing a DKIM record in our domain and having them send emails directly from our domain with their servers. (Presumably we'd also have to add them to our SPF, though they didn't mention that.)</p> <p>I understand the general implications of all this, but one claim they make in trying to push the direct-send option is that the "via" or "on behalf of" messages are more likely to be marked as spam. Is this actually true in practice? </p> <p>In other words, are messages with a Sender header different from the From header more likely to be marked as spam than one sent with only a From header (assuming SPF records don't get in the way)?</p>
1cybersec
Stackexchange
In Theory: Nintendo's next-gen hardware - and the strategy behind it.
0non-cybersec
Reddit
How to convert a pandas MultiIndex DataFrame into a 3D array. <p>Suppose I have a MultiIndex DataFrame:</p> <pre><code> c o l u major timestamp ONE 2019-01-22 18:12:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:13:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:14:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:15:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:16:00 0.00008 0.00008 0.00008 0.00008 TWO 2019-01-22 18:12:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:13:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:14:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:15:00 0.00008 0.00008 0.00008 0.00008 2019-01-22 18:16:00 0.00008 0.00008 0.00008 0.00008 </code></pre> <p>I want to generate a NumPy array from this DataFrame with a 3-dimensional, given the dataframe has 15 categories in the major column, 4 columns and one time index of length 5. I would like to create a numpy array with a shape of <strong>(4,15,5)</strong> denoting <strong>(columns, categories, time_index)</strong> respectively.</p> <p>should create an array:</p> <pre><code>array([[[8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05], [8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05]], [[8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05], [8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05]], [[8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05], [8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05]], [[8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05], [8.e-05, 8.e-05, 8.e-05, 8.e-05, 8.e-05]]]) </code></pre> <p>One used to be able to do this with pd.Panel:</p> <pre><code>panel = pd.Panel(items=[columns], major_axis=[categories], minor_axis=[time_index], dtype=np.float32) ... </code></pre> <p><strong>How would I be able to most effectively accomplish this with a multi index dataframe?</strong> <strong>Thanks</strong></p>
0non-cybersec
Stackexchange
End(V) and End(V)xEnd(V) are isomorphic. <p>Let R=End(V) be the ring of all linear endomorphisms of an infinite dimension complex vector space V with countable basis $\{e_{1},e_{2},...\}$ . Prove that R and RxR are isomorphic as left R-modules.</p>
0non-cybersec
Stackexchange
Current solutions to preload, cache, or otherwise play audio without lag / delay on mobile Safari in HTML5? Perhaps iOS 5+. <p>There are a ton of SO posts on audio, HTML5, and mobile Safari, such as these:</p> <p><a href="https://stackoverflow.com/questions/4799369/reusing-html5-audio-object-in-mobile-safari">Reusing HTML5 Audio Object in Mobile Safari</a> <a href="https://stackoverflow.com/questions/2841966/autoplay-an-audio-file-on-mobile-safari">Autoplay an Audio File on Mobile Safari</a> <a href="https://stackoverflow.com/questions/5758719/preloading-html5-audio-in-mobile-safari">Preloading HTML5 Audio in Mobile Safari</a> <a href="https://stackoverflow.com/questions/2970062/will-html5-support-the-access-of-offline-cached-audio/3035000#comment9507730_3035000">Will HTML5 support the access of offline cached audio?</a></p> <p>However, they all are outdated.</p> <p>We prefer solutions to support iOS 3+, but we will take anything that works -- even if it's restricted to iOS 5.</p> <p>Anyone have the definitive answer as things stand today, or testers on iOS 5 have any insights?</p> <ul> <li>Can audio files be cached in mobile Safari? If so, what are the limitations?</li> <li>Is there a way to minimize lag or delay between pressing a button and playing a sound?</li> </ul> <p>Thanks!</p>
0non-cybersec
Stackexchange
My buddy bought these at a yard sale for $2, but what are they?.
0non-cybersec
Reddit
Erdogan loses hold over Turkish capital, Istanbul disputed.
0non-cybersec
Reddit
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
SQL 2008 Performance Reports. <p>Does anybody know of DMV's or reports that will show the historical performance of the stored procedures on the server? Also if that data is stored in a table or tables, what is the retention period and can it be adjusted?</p> <p>Thanks for your time... </p>
0non-cybersec
Stackexchange
Relation between two functions defined by and integral. <p>Let us consider the two functions <span class="math-container">$$F(x) = \int\limits_x^1 {h(s - x,s)ds - } \int\limits_{1 - x}^1 {h(2 - s - x,s)ds} $$</span><span class="math-container">$$G(x) = \int\limits_0^x {h(x - s,s)ds - } \int\limits_0^{1 - x} {h(x + s,s)ds} $$</span> Where <span class="math-container">$h$</span> is some regular function. Note that <span class="math-container">$F(0)=-G(0)$</span>, and <span class="math-container">$F(1)=-G(1)$</span>. But I can not find a general relation between these two functions. I will be grateful to yiur helps. Thank you.</p>
0non-cybersec
Stackexchange
Found this in my house, I think I got it free from a college exhibit a while back. It slides back and forth to reveal that small hole, and there seems to be an adhesive/tape on the back. A little less than an inch long..
0non-cybersec
Reddit
How do you check if processor.max_cstate is set correctly using terminal/tilix?. <p>I have a ryzen cpu and my cpu has been freezing/crashing a lot over the years and I couldnt' find a solution until recently and I'm told setting the max_cstate should solve my issue. </p> <p><strong>But how do I check if I set <code>processor.max_cstate</code> correctly from the terminal/tilix?</strong></p> <p>Current cpu: AMD Ryzen 3 1200 Quad-Core Processor</p> <p>OS: Ubuntu Desktop 20.04</p>
0non-cybersec
Stackexchange
The Song for Fernando Torres when he joined Chelsea. Sad to watch..
0non-cybersec
Reddit
Fade out animation to the right. <p>I have bullets that fly in from the left and stop. I'd like to continue to the right and slowly fade out. Can anyone assist with this please? I'm also open to vb code.</p>
0non-cybersec
Stackexchange
How to achieve state normalization in Vuex?. <p>I am developing an app also using Vuex and just hit a situation where dealing with nested objects will be a pain, so I am trying to normalize(flatten) the state as much as possible like the example below:</p> <pre><code>users: { 1234: { ... }, 46473: { name: 'Tom', topics: [345, 3456] } }, userList: [46473, 1234] </code></pre> <p>My question is: <strong>What's the "best" way to achieve the above when your API response looks like this</strong>:</p> <pre><code>data: [ {id: 'u_0001', name: 'John', coments: [{id: 'c_001', body: 'Lorem Ipsum'}, {...}], {id: 'u_0002', name: 'Jane', coments: [{id: 'c_002', body: 'Lorem Ipsum'}, {...}], {...} ] </code></pre> <p>Assuming for the sake of the example that <code>comments</code> is a submodule of <code>users</code>:</p> <p><strong>Option 1:</strong></p> <pre><code>// action on the user module export const users = ({ commit, state }, users) =&gt; { commit(SET_USERS, users) commit('comments/SET_COMMENTS', users) } // mutation on the user module [types.SET_USERS] (state, users) { state.users = users.reduce((obj, user) =&gt; { obj[user.id] = { id: user.id, name: user.name, comments: user.comments.map(comment =&gt; comment.id) } return obj }, {}) state.userIds = users.map(user =&gt; user.id) }, // mutation on the comments module [types.SET_COMMENTS] (state, users) { let allComments = [] users.forEach(user =&gt; { let comments = user.comments.reduce((obj, comment) =&gt; { obj[comment.id] = comment return obj }, {}) allComments.push(comments) }) state.comments = ...allComments }, </code></pre> <p>IMO this option is good because you don't have to worry about resetting the state everytime you change pages(SPA/Vue-Router), avoiding the scenario where for some reason <code>id: u_001</code> no longer exists, because the state is overridden every time the mutations are called, but it feels odd to pass the <code>users array</code> to both mutations.</p> <p><strong>Option 2:</strong></p> <pre><code>// action on the user module export const users = ({ commit, state }, users) =&gt; { // Here you would have to reset the state first (I think) // commit(RESET) users.forEach(user =&gt; { commit(SET_USER, user) commit('comments/SET_COMMENTS', user.comments) }) } // mutation on the user module [types.SET_USER] (state, user) { state.users[user.id] = { id: user.id, name: user.name, comments: user.comments.map(comment =&gt; comment.id) } state.userIds.push(user.id) }, // mutation on the comments module [types.SET_COMMENTS] (state, comments) { comments.forEach(comment =&gt; { Vue.set(state.comments, comment.id, comment) }) state.commentsIds.push(...comments.map(comment =&gt; comment.id) }, </code></pre> <p>In this situation there's the need to reset state or you will have repeated/old values everytime you leave and re-renter the page. Wich is kinda annoying and more propicious to bugs or inconsistent behaviors.</p> <p><strong>Conclusion</strong> How are you guys tackling such scenarios and advices/best practices? Answers are very appreciated since I'm stuck on these things.</p> <p>Also, I'm trying to avoid 3r party libraries like the Vue ORM, normalizr, etc because the needs are not that complex.</p> <p>Thank you,</p> <p>PS: The code might have errors since I just wrote it without testing, please focus on the big picture.</p>
0non-cybersec
Stackexchange
Network scanning scope limited in Windows Server 2012. <p><strong>What I need ?:</strong> View all the computers of the network neighborhood (including all network segments, 192.168.1.x , 192.168.2.x , 192.168.3.x , etc)</p> <p><strong>What is my problem ?:</strong> When I open network neighboorhood in windows server 2012 I can see computers in my network segment (192.168.1.x) but I can't see the rest of the computers in other segments ( 192.168.2.x , 192.168.3.x , etc)</p> <p><strong>How is my Network ?:</strong> * We don't use Domain Controller * We use a Mikrotik Router as the main router (each port manage 1 segment) * We use nxfilter for internet surfing permits</p> <p><strong>What I already did ?</strong> * use "add route" command with no success</p> <p>Any idea ?, Thank you very much</p>
0non-cybersec
Stackexchange
Jud McMillian, Indiana politician, blames Canada for phone scandal.
0non-cybersec
Reddit
How to use spot instance with amazon elastic beanstalk?. <p>I have one infra that use amazon elastic beanstalk to deploy my application. I need to scale my app adding some spot instances that EB do not support.</p> <p>So I create a second autoscaling from a launch configuration with spot instances. The autoscaling use the same load balancer created by beanstalk.</p> <p>To up instances with the last version of my app, I copy the user data from the original launch configuration (created with beanstalk) to the launch configuration with spot instances (created by me).</p> <p>This work fine, but:</p> <ol> <li><p>how to update spot instances that have come up from the second autoscaling when the beanstalk update instances managed by him with a new version of the app?</p> </li> <li><p>is there another way so easy as, and elegant, to use spot instances and enjoy the benefits of beanstalk?</p> </li> </ol> <p><strong>UPDATE</strong></p> <p>Elastic Beanstalk add support to spot instance since 2019... see: <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2019-11-25-spot.html</a></p>
0non-cybersec
Stackexchange
Getting login year data with the &#39;last&#39; command on linux. <p>On Solaris, there the command 'fwtmp' provide the year information from the wtmp logs. For example:</p> <pre><code>host # /usr/lib/acct/fwtmp &lt; /var/adm/wtmpx &gt; tmp_wtmpx_file host # head -1 tmp_wtmpx_file user123 sshd 1258 7 0000 0000 1226072918 230489 0 29 host123.desktop.ourhost.com Fri Nov 7 09:48:38 2008 </code></pre> <p>On Linux, the 'last' outputs the data without the year information, and I don't seem to be able to find a utility similar to 'fwtmp' on Linux to add the year data. The 'lastlog' command includes year in the output, but only looks up the users that are in the passwd file (not against ldap or other user databases by default). Is there a utility on Linux that will output the year along with the other data from 'last'?</p>
0non-cybersec
Stackexchange
Hidden Truecrypt container. How does one recognize a hidden Truecrypt container? I got multiple part files for a zip archive, but running binwalk on them reveals that they contain extra weird information, like Cisco Microcodes, StuffIT Archives and MySQL MISAM Compressed data. Almost certainly these aren't actual valid data, but rather some components for a larger tc container. Are there any methods for finding if a file is a valid tc containers? I tried TCHunt and entropy analysis, but I was wondering if there are any other known methods.
1cybersec
Reddit
Graphics card makers will be “forced to slash prices” after GPU shipments fall by 40%.
0non-cybersec
Reddit
Generating triangular/hexagonal coordinates (xyz). <p>I'm trying to come up with an iterative function that generates xyz coordinates for a hexagonal grid. With a starting hex position (say 0,0,0 for simplicity), I want to calculate the coordinates for each successive "ring" of hexagons, as illustrated here: </p> <p><img src="https://i.imgur.com/AJoDm.gif" /></p> <p>So far, all I've managed to come up with is this (example in javascript): </p> <pre class="lang-js prettyprint-override"><code>var radius = 3 var xyz = [0,0,0]; // for each ring for (var i = 0; i &lt; radius; i++) { var tpRing = i*6; var tpVect = tpRing/3; // for each vector of ring for (var j = 0; j &lt; 3; j++) { // for each tile in vector for(var k = 0; k &lt; tpVect; k++) { xyz[0] = ???; xyz[1] = ???; xyz[2] = ???; console.log(xyz); } } } </code></pre> <p>I know each ring contains six more points than the previous and each 120&deg; vector contains one additional point for each step from the center. I also know that <code>x + y + z = 0</code> for all tiles. But how can I generate a list of coordinates that follow the sequence below? </p> <pre><code> 0, 0, 0 0,-1, 1 1,-1, 0 1, 0,-1 0, 1,-1 -1, 1, 0 -1, 0, 1 0,-2, 2 1,-2, 1 2,-2, 0 2,-1,-1 2, 0,-2 1, 1,-2 0, 2,-2 -1, 2,-1 -2, 2, 0 -2, 1, 1 -2, 0, 2 -1,-1, 2 </code></pre>
0non-cybersec
Stackexchange
Unexplained 503 errors when uploading huge file to Google Drive. <p>I'm trying to upload a rather huge file (~1TB) to Google Drive using their <a href="https://developers.google.com/drive/web/manage-uploads#resumable" rel="nofollow noreferrer">resumable uploads</a> feature. I upload the file in 16MB chunks. This job has been running for a couple of days successfully already; I'm uploading over a very slow link and I want it to run robustly for even weeks.</p> <p>For this particular upload, after around 60GB are uploaded fine, I repeatedly see the following error; I do an exponential backoff to retry; it's capped to retry every two minutes after each failure.</p> <p>The request and response look like this (the request is passed to an <a href="https://godoc.org/golang.org/x/oauth2/google" rel="nofollow noreferrer">OAuth'd <code>http.Client</code></a>, so the <code>Authorization</code> header isn't included):</p> <pre><code>2015/04/18 09:26:28 Attempt 663 failed for this chunk: expected status 308, but got 503 tried this request: 2015/04/18 09:26:28 &amp;{PUT https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable&amp;upload_id=AEnB2UqOogB7qWwFhp7afkT-uYYGWodnUo5GNXpNbhvxceY2C01JZgz0m79zQi_LzAY1zGwkrv4fcE6Jh9NWNhpvwQqvePW0-A HTTP/1.1 1 1 map[Content-Range:[bytes 62730010624-62746787839/*]] {0xc2104256c0} 16777216 [] false www.googleapis.com map[] map[] &lt;nil&gt; map[] &lt;nil&gt;} got this response: 2015/04/18 09:26:28 &amp;{503 Service Unavailable 503 HTTP/1.1 1 1 map[Content-Length:[0] Date:[Sat, 18 Apr 2015 07:28:47 GMT] Server:[UploadServer ("Built on Apr 9 2015 13:51:25 (1428612685)")] Content-Type:[text/html; charset=UTF-8] Alternate-Protocol:[443:quic,p=1]] 0xc2100e8ba0 0 [] true map[] 0xc2104228f0} </code></pre> <p>The response body is empty. Interestingly, I see these errors in the Google Developers Console's dashboard (the error count is increasing). However, I can't find detailed reports on what went wrong anywhere -- neither in the "Monitoring" tabs or in the detailed API usage report for the Drive API.</p> <p>That means the errors are correctly assigned to my account (which rules out auth problems), and the error is with this specific upload (another upload of a different file works) and not the uploader code in general.</p> <p>Therefore, I suspect this is Google's bug and not mine.</p> <p>What is going on here?</p>
0non-cybersec
Stackexchange
Here's my cat Bianca, she loves to explore and to sleep..
0non-cybersec
Reddit
Finitely many minimal elements. <p>I've been working on various exercises to get a better understanding of some topics for an upcoming course. </p> <p>I have a relation $R$ on $\mathbb{N} \times \mathbb{N}$ defined as follows: $(x_0, x_1) R (y_0, y_1)$ if and only if $x_0 \leq y_0$ and $x_1 \leq y_1$. The exercise asks to show that $R$ is well-founded on $\mathbb{N}$ but is not a total order. I was able to show this successfully.</p> <p>Then, it asks to show that every non-empty subset $X \subset \mathbb{N} \times \mathbb{N}$ contains only finitely many $R$-minimal elements, and, for each $n \in \mathbb{N}$, there is such an $X$ with exactly $n$ $R$-minimal elements. In a relation $R$, and a set $X$, $y \in X$ is said to be $R$-minimal in $X$ if and only if</p> <p>$$ \neg \exists z ( z \in X \wedge zRy)$$</p> <p>It seems like it should be very obvious to show that there are only finitely many $R$-minimal elements, but I can't formally come up with a valid argument. If a non-empty subset contained infinitely many $R$-minimal subsets, I'm thinking it would somehow lead to a contradiction.</p> <p>Any help would be greatly appreciated.</p>
0non-cybersec
Stackexchange
Loungin'.
0non-cybersec
Reddit
What effect did World War 2 have on the Earth's environment?. I was watching footage of D-Day and got to thinking about if there was ever a measurement made of the destructive forces of the war on things like the atmosphere, oceans, rivers, farmland, etc. With all of the vehicles used (aircraft, boats, tanks) and ammunition including nuclear weapons, is there measurable spike in atmospheric damage or ocean pollution? And does it compare with daily use of fuel now? For example with all of the fuel spilled by ships being destroyed in the Atlantic was there any noticeable destruction of beaches and marine life even years after the war ended? I had read once that the fall of the Aztec and Inca empires caused a mini ice age from the abrupt drop in population and farming and was wondering if there were any similar effects that have been measured in World War 2.
0non-cybersec
Reddit
What book changed the way you see the world?.
0non-cybersec
Reddit
Yeah that got doctor who fans scared..
0non-cybersec
Reddit
Validate .csproj files in solution. <p>I'd like to be able to validate my <code>.csproj</code> files either as they are added to the solution, or when they are built on our CI build server.</p> <p>Validation would mean checking, for example:</p> <ul> <li>that the path and project file name match conventions</li> <li>that the assembly name and namespace match naming conventions</li> <li>that the platform target is correct</li> <li>that the output paths are correct (Release and Debug)</li> <li>that the warnings level is correct and warnings are treated as errors</li> <li>that certain files are present in the project (<code>AssemblyInfo.cs</code> etc).</li> <li>that assemblies have been correctly referenced</li> <li>etc</li> </ul> <p>Another useful feature would be the ability to ignore certain projects, or better still, to be able to define project groupings, with each group having its own validation rules.</p> <p>This seems to me to be a problem that many others must have, however I have not yet found any tool which could help simplify or automate this process. I'd imagine it to be something like StyleCop or FxCop perhaps.</p> <p>Does such a tool exist or must I create my own custom build step?</p> <p>(I am also using ReSharper, so would consider plugins, although this might make validation on the build server more difficult.)</p>
0non-cybersec
Stackexchange
Spring RestTemplate - async vs sync restTemplate. <p>I wrote the following code to test the performance of both the sync RestTemplate and AsyncRestTemplate. I just ran it a few times manually on POSTMAN.</p> <p>We are just passing 10 references into a GET call so that we can return 10 links:</p> <p><strong>RestTemplate - synchronous and returns in 2806ms:</strong></p> <pre><code>ArrayList&lt;String&gt; references = new ArrayList&lt;&gt;(); ArrayList&lt;String&gt; links = new ArrayList&lt;&gt;(); RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); for (int i = 0; i &lt; 10; i++) { ResponseEntity&lt;String&gt; resource = restTemplate.getForEntity(references.get(i), String.class); links.add(resource.getBody().toString()); } </code></pre> <p><strong>RestTemplate - asynchronous and returns in 2794ms:</strong></p> <pre><code>//Creating a synchronizedList so that when the async resttemplate returns, there will be no concurrency issues List&lt;String&gt; links = Collections.synchronizedList(new ArrayList&lt;String&gt;()); //CustomClientHttpRequestFactory just extends SimpleClientHttpRequestFactory but disables automatic redirects in SimpleClientHttpRequestFactory CustomClientHttpRequestFactory customClientHttpRequestFactory = new CustomClientHttpRequestFactory(); //Setting the ThreadPoolTaskExecutor for the Async calls org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor pool = new org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor(); pool.setCorePoolSize(5); pool.setMaxPoolSize(10); pool.setWaitForTasksToCompleteOnShutdown(true); pool.initialize(); //Setting the TaskExecutor to the ThreadPoolTaskExecutor customClientHttpRequestFactory.setTaskExecutor(pool); ArrayList&lt;String&gt; references = new ArrayList&lt;&gt;(); ArrayList&lt;String&gt; links = new ArrayList&lt;&gt;(); AsyncRestTemplate asyncRestTemplate = new AsyncRestTemplate(customClientHttpRequestFactory); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); for (int i = 0; i &lt; 10; i++) { Future&lt;ResponseEntity&lt;String&gt;&gt; resource = asyncRestTemplate.getForEntity(references.get(i), String.class); ResponseEntity&lt;String&gt; entity = resource.get(); //this should start up 10 threads to get the links asynchronously links.add(entity.getBody().toString()); } </code></pre> <p>In most cases, both methods actually return back the results with a very similar time, averaging 2800ms in both async and sync calls.</p> <p>Am I doing something incorrect as I would have expected the async call to be much faster?</p>
0non-cybersec
Stackexchange
How to keep all my passwords, browsing data, e-mails, content etc. only for myself, and away from Apple?. <p>I just bought my first Apple product (iPhone) a few days ago and from the moment I switched on I have been asked to use the Apple ID and iCloud for pretty much everything.</p> <p>I have a concern, i.e. if I have an Apple ID registered with my real name, address, etc. will Apple and/or iCloud always know all my browsing data, my emails, email passwords, etc.?</p> <p>If yes, is there a way to be completely "cut off from the cloud"?</p> <p>I am not feeling completely secure enough to check my normal e-mail from the iphone until I am 100% sure nobody (at least at Apple) can read it.</p> <p>What steps can I take to ensure that my data is least exposed to the world/Apple?</p> <p>e.g. would using fake personal data help?</p> <p>If you ask why, well, there's nothing much I want to hide except some nighttime activities I don't want anybody to know about - for obvious reasons :-)</p>
0non-cybersec
Stackexchange
IMEI number formatting in Excel. <p>I'm trying to format IMEI numbers in Excel according to RIM (Blackberry) conventions: XXXXXX.XX.XXXXXX.X</p> <p>I enter them in excel without any periods and use the "special format" cell properties so it displays right. This works kind of: <code>######-##-######-#</code></p> <p>However, when I replace the dashes with periods (<code>######.##.######.#</code>) Excel automatically changes it to <code>###.###.###.###.###</code>, 5 groups of 3. It does this too when I prepend it with a space.</p> <p>Does anyone know how to disable this behaviour or a workaround?</p>
0non-cybersec
Stackexchange
YSK that Costco's Kirkland Signature brand line of spirits are made by name brand distilleries, with only slight variances in recipe and style. I bought some Kirkland brand bourbon from Costco and I was surprised at the quality of it, having expected something along the lines of a "well" whiskey. As a longtime bartender, I wondered where they're getting their product. After a little research online, it seems likely that their bourbon is the by-product of Knob Creek or Jim Beam Black, perhaps the batches with too much flavor variance. It is made by Buffalo Trace, in the style of Knob Creek/Jim Beam Black/Old Grandad. Their vodka is supposedly an almost identical recipe to Grey Goose, their tequila is probably made by Sauza, and their wines are mostly high quality from large wine producers. In many states, you can walk right in to a Costco and buy alcohol without even having a membership, though you may have to go through the trouble of talking to a manager about it as this rule varies according to state law. Anyway, Kirkland Signature is a pretty good value, with decent product, and can save you some big money for your next party!
0non-cybersec
Reddit
Can I hook into the end of the document but *after* the `\clearpage`?. <p>The code for <code>\enddocument</code> begins:</p> <pre><code>\def\enddocument{% \let\AtEndDocument\@firstofone \@enddocumenthook \@checkend{document}% \clearpage \begingroup </code></pre> <p>I'd like to put something <em>after</em> that <code>\clearpage</code>. What's the simplest way to do that? Alternatively, I could put an extra <code>\clearpage</code> into the code that I want to dump there. Is there a problem with issuing more <code>\clearpage</code>s than strictly necessary? And would it cause problems having a <code>\clearpage</code> before the <code>\@checkend{document}</code> (could there be interactions with other stuff using the end document hook)?</p> <p>The specific use case is (with apologies to those who thought I might be asking a <em>serious</em> question) TikZ/PGF. As TeX processes a document with PGF stuff then it stores up some stuff that needs to be put at the start of the document. It does this with a token register <code>\pgfutil@everybye</code> which gets invoked with an <code>\AtEndDocument{\the\pgfutil@everybye}</code>. This works fine <em>except</em> if stuff is added to this list in the headers and footers of the last page - these don't seem to get added to the list in time to be added to the document (this came to light in looking at <a href="https://tex.stackexchange.com/q/51792/86">defining a fading-style directly in the fill command</a> where the questioner wanted to define a fading in a header. There were various issues with this, and this appears to be a fairly important one.)</p>
0non-cybersec
Stackexchange
Considering switching from Xbox One to PS4. I was wondering if I could get any input from players with both consoles or a ps4. The main things holding me back from switching are that mostly all of my friends have an xbox and it would probably be pretty expensive to switch over. I don't mind my Xbox but in general I've had a lot of problems with it. (Two broke controllers, kinect barely ever works, the console randomly messes up). Also PS4 has more of the games I want- I NEED a decent mlb game, the uncharted series looks great, and I'm really interested in the new spiderman game announced at e3 by insomniac because I loved sunset overdrive. A few minor things I like about xbox are EA access & free games with gold, but I could live without them for sure. Also, I think I might be able to get a close friend of mine to switch over with me. Any advice would be awesome thanks for reading. TL;DR- have a few problems with my xbox, want some ps4 exclusives but don't want to leave my friends. Do I switch?
0non-cybersec
Reddit
So tell me about yourself....
0non-cybersec
Reddit
Reused abstraction principle in C#. <p>In our C# MVC application we have a lot of interfaces that map 1 to 1 with the objects that implement them. ie: basically, for each object created, an "extract interface" operation has been performed.</p> <p>The interfaces are used by Moq to generate mock objects for our unit tests. But that's the one and only time the interfaces are re-used. </p> <p>No concrete objects in our system implement multiple interfaces.</p> <p>Can anyone tell me if this is going to cause problems down the road? And if so, what would they be?</p> <p>I was thinking, re our app that there is a lot of duplication, for example in these 2 interfaces (Edit: in our SERVICES layer) the only thing that differs is the method name and the type of parameter they take, but semantically they do the same thing with the repositories they send messages to: </p> <pre><code>interface ICustomer { void AddCustomer(Customer toAdd); void UpdateCustomer(Customer toUpdate); Customer GetById(int customerId); } interface IEmployee { void AddEmployee(Employee toBeAdded); void UpdateEmployee(Employee toUpdate); Employee GetById(int employeeId); } </code></pre> <p>and that's where I think the reused abstraction principle would come in, ie to transform the code to something like:</p> <pre><code>public interface IEmployee: IAdd&lt;Employee&gt;, IUpdate&lt;Employee&gt;, IFinder&lt;Employee&gt; </code></pre> <p>This isn't about the repository pattern - this is about interfaces <em>in any layer</em> that look like they share semantically identical behaviours. Is it worth deriving common interfaces for these operations and making "sub-interfaces" inherit from them?</p> <p>At least it would keep the signatures of the methods consistent. But what other benefits would this give me? (Liskov substitution Principle aside)</p> <p>Right now, the names of the methods and the return types are all over the place. </p> <p>I read Mark Seemann's blog about the Reused abstractions Principle but I didn't understand it, to be frank. Maybe I'm just stupid :) I also read Fowler's definition of Header Interfaces.</p>
0non-cybersec
Stackexchange
Upgrading to UEFI motherboard while keeping old hard drive. <p>I want to upgrade my motherboard+CPU, but have no desire to reinstall my Ubuntu system (Ubuntu is the sole OS in the hard drive). My current MB uses BIOS, but the new one will almost certainly use UEFI. What should I do before the upgrade to make sure everything will go smoothly?</p>
0non-cybersec
Stackexchange
How to make Windows 10 recognize my monitors size properly?. <p>I have one 4K 32'' monitor, and two 24'' 1080p monitors. </p> <p>Windows thinks the 24'' monitors fit right on top of the 32'' inches one, but in reality they don't and the "extended" desktop is all messed up because of that. See the image:</p> <p><a href="https://i.stack.imgur.com/udSBU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/udSBU.png" alt="enter image description here"></a></p> <p>How to make windows understand that my secondary monitors are larger and have a lower ppi?</p> <p>If not possible, are there any applications that could help with this?</p>
0non-cybersec
Stackexchange
Insufferable Marketing Solutions more like it..
0non-cybersec
Reddit
git cherry pick a range of sequently commits including merge. <p>I can cherry pick a range of sequent commit .</p> <p></p> <p>for example</p> <p></p> <p>on branch master,I want to cherry-pick changes from d4fd8cad to HEAD of develop </p> <p>git cherry-pick d4fd8cad..develop</p> <p> There is an errorr</p> <p> error: Commit 885c9e07264ac6b5d3960... is a merge but no -m option was given.</p> <p> fatal: cherry-pick failed </p> <p>how can I use the -m option ?</p>
0non-cybersec
Stackexchange
c++17 filesystem::remove_all with wildcard path. <p>I want to delete all files, folders and subfolders but not the parent folder.</p> <p>So I tried to use filesystem::remove_all with a wildcard, but this doesn't seems to work.</p> <pre><code>filesystem::removeall(&quot;pathtofolder/*&quot;); </code></pre> <p>There is no exception, but it doesn't delete anything.</p> <p>Are wildcards are not allowed?</p> <p>Do I really need to call for each file and folder inside of <code>pathtofolder</code> the <code>removeall</code> method?</p>
0non-cybersec
Stackexchange